273 lines
11 KiB
VB.net
273 lines
11 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Inventarios_RepAnomalias
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
Public Property CveInventarioFisico As Integer
|
|
Get
|
|
Return CType(ViewState("CveInventarioFisico"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveInventarioFisico") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveAlmacen As Integer
|
|
Get
|
|
Return CType(ViewState("CveAlmacen"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacen") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveSubProyecto As Integer
|
|
Get
|
|
Return CType(ViewState("CveSubProyecto"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyecto") = value
|
|
End Set
|
|
End Property
|
|
Public Property EsAvance As Boolean
|
|
Get
|
|
Return CType(ViewState("EsAvance"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsAvance") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
CveInventarioFisico = If(Request("CveInventarioFisico") IsNot Nothing AndAlso Request("CveInventarioFisico").ToEntero() > 0, Request("CveInventarioFisico").ToEntero(), -1).ToString
|
|
EsAvance = If(Request("EsAvance") IsNot Nothing, CBool(Request("EsAvance").ToEntero), False)
|
|
|
|
If CveInventarioFisico > 0 Then
|
|
CargaDatos(CveInventarioFisico)
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
|
|
Private Sub CargaDatos(CveInventarioFisico As Integer)
|
|
Dim Inventario As New ClsInventarios
|
|
Dim dt As DataTable = Nothing
|
|
|
|
If Inventario.GetInventarioFisico(CveInventarioFisico, UsuarioActual.CveEmpresa, -1, -1) Then
|
|
lbTitulo.Text = Inventario.InventarioFisico
|
|
lbObservaciones.Text = Inventario.Observaciones
|
|
lbSubProyecto.Text = Inventario.SubProyectoInventario
|
|
lbEstatus.Text = Inventario.Estatus
|
|
lbFechaI.Text = Inventario.FechaI
|
|
lbFechaF.Text = Inventario.FechaF
|
|
CveSubProyecto = Inventario.CveSubProyectoInventario
|
|
|
|
If Inventario.Estatus = "Finalizado" Then
|
|
btnFin.Visible = False
|
|
End If
|
|
|
|
If EsAvance Then
|
|
If Inventario.GetInventarioFisicoResultadosAvance(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
dt = Inventario.DtResultados
|
|
End If
|
|
Else
|
|
If Inventario.GetInventarioFisicoResultados(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
dt = Inventario.DtResultados
|
|
End If
|
|
End If
|
|
|
|
If Inventario.GetInventarioFisicoDetallesAlmacen(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dta As DataTable = Inventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dta IsNot Nothing AndAlso dta.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dta.Rows
|
|
str.AppendFormat("{0},", dr("almacen"))
|
|
Next
|
|
End If
|
|
LblAlmacenes.Text = str.ToString
|
|
End If
|
|
If Inventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dta As DataTable = Inventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dta IsNot Nothing AndAlso dta.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dta.FiltraParametros("Incluye = 1").Rows
|
|
str.AppendFormat("{0},", dr("Clasificacion"))
|
|
Next
|
|
LblClasif.Text = str.ToString
|
|
str.Clear()
|
|
For Each dr As DataRow In dta.FiltraParametros("Incluye = 0").Rows
|
|
str.AppendFormat("{0},", dr("Clasificacion"))
|
|
Next
|
|
LblClasificacionesExcluidas.Text = str.ToString
|
|
End If
|
|
|
|
End If
|
|
If Inventario.GetInventarioFisicoDetallesProductosServicios(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dta As DataTable = Inventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dta IsNot Nothing AndAlso dta.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dta.FiltraParametros("Incluye = 1").Rows
|
|
str.AppendFormat("{0},", dr("CodigoPS"))
|
|
Next
|
|
LblProductos.Text = If(str.ToString <> "", str.ToString, "Todos")
|
|
str.Clear()
|
|
For Each dr As DataRow In dta.FiltraParametros("Incluye = 0").Rows
|
|
str.AppendFormat("{0},", dr("CodigoPS"))
|
|
Next
|
|
LblProductosExcluidos.Text = str.ToString
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
Inventario.Dispose()
|
|
|
|
GvS.DataSource = dt.FiltraParametros("Diferencia < 0")
|
|
GvS.DataBind()
|
|
GvF.DataSource = dt.FiltraParametros("Diferencia > 0")
|
|
GvF.DataBind()
|
|
|
|
Dim Script = ""
|
|
If (GvF.Rows.Count > 0) Then
|
|
GvF.UseAccessibleHeader = True
|
|
GvF.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
Script = "OrdenarGVF();"
|
|
End If
|
|
|
|
If (GvS.Rows.Count > 0) Then
|
|
GvS.UseAccessibleHeader = True
|
|
GvS.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
Script += "OrdenarGVS();"
|
|
End If
|
|
|
|
RegistraScript(Script)
|
|
|
|
UPAnomalias.Update()
|
|
UpdateGvS.Update()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " FINALIZAR "
|
|
Protected Sub btnFin_Click(sender As Object, e As EventArgs) Handles btnFin.Click
|
|
Dim Inventarios As New ClsInventarios
|
|
Inventarios.IniciaTransacSQL()
|
|
If Inventarios.AddInventarioFisicoResultados(CveInventarioFisico, UsuarioActual.CveUsuario) Then
|
|
If Inventarios.UpdateInventarioFisicoEstatus(CveInventarioFisico, 3, UsuarioActual.CveEmpresa) Then
|
|
Dim url As String = ("/Inventarios/RepAnomalias.aspx?CveInventarioFisico=" + CveInventarioFisico.ToString)
|
|
Alert("Ha finalizado el Inventario Físico. Sera enviado al reporte de anomalías", TipoMensaje.MsgInformacion, " window.location=""" + url + """")
|
|
Inventarios.Commit()
|
|
Else
|
|
Inventarios.RollBack()
|
|
End If
|
|
Else
|
|
Inventarios.RollBack()
|
|
End If
|
|
Inventarios.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
Protected Sub GV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvF.RowDataBound, GvS.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("Costo") = "-1" Then
|
|
e.Row.Cells(8).Text = "0"
|
|
End If
|
|
|
|
e.Row.FCLabel("Lblc").Text = e.Row.RowIndex + 1
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#Region " IMPRIMIR "
|
|
'Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
' GvF.ExportToExcel("IF_Faltantes_" & Now.ToShortDateString())
|
|
'End Sub
|
|
'Protected Sub LnkExportaSobrantes_Click(sender As Object, e As EventArgs) Handles LnkExportaSobrantes.Click
|
|
' GvS.ExportToExcel("IF_Sobrantes_" & Now.ToShortDateString())
|
|
'End Sub
|
|
|
|
Private Sub LnkPDF_Click(sender As Object, e As EventArgs) Handles LnkPDF.Click
|
|
ImprimirbytesPDF(Impimir, Formato:="PDF")
|
|
End Sub
|
|
Protected Function Impimir() As Byte()
|
|
Dim retorno As Byte() = Nothing
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepAnomalias.rdlc", UsuarioActual.Empresa.Ruta))
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim params As New List(Of ReportParameter)
|
|
Dim lrds As New List(Of ReportDataSource)
|
|
Dim Inventario As New ClsInventarios
|
|
|
|
|
|
Dim dtS As DataTable = Nothing
|
|
Dim dtF As DataTable = Nothing
|
|
|
|
If Inventario.GetInventarioFisico(CveInventarioFisico, UsuarioActual.CveEmpresa, -1, -1) Then
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("Titulo", Inventario.InventarioFisico))
|
|
params.Add(New ReportParameter("Observaciones", Inventario.Observaciones))
|
|
params.Add(New ReportParameter("Almacen", LblAlmacenes.Text))
|
|
params.Add(New ReportParameter("Estatus", Inventario.Estatus))
|
|
params.Add(New ReportParameter("FechaInicio", Inventario.FechaI))
|
|
params.Add(New ReportParameter("FechaFin", Inventario.FechaF))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
If EsAvance Then
|
|
If Inventario.GetInventarioFisicoResultadosAvance(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
dtS = Inventario.DtResultados.FiltraParametros("Diferencia <0")
|
|
dtF = Inventario.DtResultados.FiltraParametros(" Diferencia > 0")
|
|
End If
|
|
Else
|
|
If Inventario.GetInventarioFisicoResultados(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
dtS = Inventario.DtResultados.FiltraParametros("Diferencia <0")
|
|
dtF = Inventario.DtResultados.FiltraParametros(" Diferencia > 0")
|
|
End If
|
|
End If
|
|
|
|
Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = dtS}
|
|
lrds.Add(rds)
|
|
Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = dtF}
|
|
lrds.Add(rds2)
|
|
|
|
End If
|
|
retorno = StreamPDF("Empresas/Grales/Formatos/RepAnomalias.rdlc", lrds, params, "Reporte Anomalías", "PDF", MR:=Nothing)
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
GvF.ExportToExcel("Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString)
|
|
End Sub
|
|
|
|
Private Sub ImgExcel2_Click(sender As Object, e As EventArgs) Handles ImgExcel2.Click
|
|
GvS.ExportToExcel("Reporte de Inventario Fisico - Productos que Sobran " & Now.ToShortDateString)
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
End Class
|