833 lines
39 KiB
VB.net
833 lines
39 KiB
VB.net
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports GemBox.Spreadsheet
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Inventarios_InventarioFisicoDetalle
|
|
Inherits ClsPaginas
|
|
#Region "Propiedades"
|
|
Public Property DtEquivalencias() As DataTable
|
|
Get
|
|
Return CType(ViewState("dtIFDetalles"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("dtIFDetalles") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveSubProyecto As Integer
|
|
Get
|
|
Return ViewState("CveSubProyecto").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyecto") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveInventarioFisico As Integer
|
|
Get
|
|
Return ViewState("CveInventarioFisico").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveInventarioFisico") = value
|
|
End Set
|
|
End Property
|
|
'Private Property DtDatos As DataTable
|
|
' Get
|
|
' Return DirectCast(ViewState("DtVentas"), DataTable)
|
|
' End Get
|
|
' Set(value As DataTable)
|
|
' ViewState("DtVentas") = value
|
|
' End Set
|
|
'End Property
|
|
Private Property CveAlmacenes As String
|
|
Get
|
|
Return ViewState("CveAlmacenes").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("CveAlmacenes") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
If Request("CveInventarioFisico") IsNot Nothing AndAlso Request("CveInventarioFisico").ToString.ToEntero > 0 Then
|
|
CveInventarioFisico = Request("CveInventarioFisico").ToString.ToEntero
|
|
CargaUsuarios()
|
|
CargaDatos(CveInventarioFisico, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " USUARIOS "
|
|
Private Sub CargaUsuarios()
|
|
ddlUsuario.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 1", "Nombre")
|
|
ddlUsuario.DataBind()
|
|
UPPInventario.Update()
|
|
ddlUsuario.SelectedValue = UsuarioActual.CveUsuario.ToString
|
|
End Sub
|
|
Protected Sub ddlUsuario_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlUsuario.SelectedIndexChanged
|
|
|
|
CargaDatos(CveInventarioFisico, UsuarioActual.CveEmpresa, ddlUsuario.SelectedValue.ToString.ToEntero)
|
|
Dim EsUsuarioActual As Boolean = False
|
|
|
|
If ddlUsuario.SelectedValue = UsuarioActual.CveUsuario.ToString Then
|
|
EsUsuarioActual = True
|
|
End If
|
|
|
|
GvIFD.Columns(6).Visible = EsUsuarioActual OrElse UsuarioActual.TienePermisoProceso(283) ' si el usuario lo registro o si tiene permisos especial
|
|
GvIFD.DataBind()
|
|
|
|
If (GvIFD.Rows.Count > 0) Then
|
|
GvIFD.UseAccessibleHeader = True
|
|
GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
|
|
UPAgregarPro.Update()
|
|
UPPInventario.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos(CveInventarioFisico As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1)
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.GetInventarioFisico(CveInventarioFisico, CveEmpresa, -1, -1) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
Dim CveEstatus = ObjInventario.DtResultados.FiltroPrimeroValor("CveEstatus")
|
|
Select Case CveEstatus
|
|
Case "0" 'NUEVO
|
|
CveSubProyecto = ObjInventario.CveSubProyectoInventario
|
|
lbTitulo.Text = ObjInventario.InventarioFisico
|
|
lbObservaciones.Text = ObjInventario.Observaciones
|
|
lbSubProyecto.Text = ObjInventario.SubProyectoInventario
|
|
lbEstatus.Text = ObjInventario.Estatus
|
|
|
|
lbFechaF.Text = ObjInventario.FechaF
|
|
btnFin.Text = "<i style='color:#26a69a' class='fa fa-play'></i>Iniciar"
|
|
BtnGuardar.Enabled = False
|
|
btnFin.ToolTip = "Inicia el Inventario Físico"
|
|
Case "3" 'FINALIZADO
|
|
GvIFD.Columns(6).Visible = False
|
|
PAgregar.Visible = False
|
|
BtnGuardar.Enabled = False
|
|
BtnGuardar.Visible = False
|
|
btnFin.Visible = False
|
|
CveSubProyecto = ObjInventario.CveSubProyectoInventario
|
|
lbTitulo.Text = ObjInventario.InventarioFisico
|
|
lbObservaciones.Text = ObjInventario.Observaciones
|
|
lbSubProyecto.Text = ObjInventario.SubProyectoInventario
|
|
lbEstatus.Text = ObjInventario.Estatus
|
|
lbFechaI.Text = ObjInventario.FechaI
|
|
lbFechaF.Text = ObjInventario.FechaF
|
|
Case "1", "2" ' EN PROCESO,EN ESPERA
|
|
CveSubProyecto = ObjInventario.CveSubProyectoInventario
|
|
lbTitulo.Text = ObjInventario.InventarioFisico
|
|
lbObservaciones.Text = ObjInventario.Observaciones
|
|
lbEstatus.Text = ObjInventario.Estatus
|
|
lbSubProyecto.Text = ObjInventario.SubProyectoInventario
|
|
lbFechaI.Text = ObjInventario.FechaI
|
|
lbFechaF.Text = ObjInventario.FechaF
|
|
BtnGuardar.Enabled = True
|
|
btnFin.Text = "<i class='fa fa-stop' style='color:#cb5a5e'></i>Finalizar"
|
|
LBAvance.Visible = UsuarioActual.TienePermisoProceso(178) ' si tiene permiso de ver el avance, se activa
|
|
End Select
|
|
GvIFD.Visible = False
|
|
divRegistrados.Visible = False
|
|
DivBuscador.Visible = False
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesAlmacen(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
Dim CveAlmacenesStr As New StringBuilder
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dt.Rows
|
|
str.AppendFormat("{0},", dr("almacen"))
|
|
CveAlmacenesStr.AppendFormat("{0},", dr("CveAlmacen"))
|
|
Next
|
|
End If
|
|
If str.ToString.Length > 500 Then
|
|
LblAlmacenes.Text = str.ToString.Substring(0, 500)
|
|
LblAlmacenes.ToolTip = str.ToString
|
|
Else
|
|
LblAlmacenes.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
|
|
CveAlmacenes = CveAlmacenesStr.ToString.Substring(0, CveAlmacenesStr.Length - 1)
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
str.AppendFormat("{0},", dr("Clasificacion"))
|
|
Next
|
|
If str.ToString.Length > 500 Then
|
|
LblClasif.Text = str.ToString.Substring(0, 29)
|
|
LblClasif.ToolTip = str.ToString
|
|
Else
|
|
LblClasif.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
|
str.AppendFormat("{0},", dr("Clasificacion"))
|
|
Next
|
|
If str.ToString.Length > 500 Then
|
|
LblClasificacionesExcluidas.Text = str.ToString.Substring(0, 500)
|
|
LblClasificacionesExcluidas.ToolTip = str.ToString
|
|
Else
|
|
LblClasificacionesExcluidas.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesProductosServicios(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
str.AppendFormat("{0},", dr("CodigoPS"))
|
|
Next
|
|
If str.ToString.Length > 500 Then
|
|
LblProductos.Text = str.ToString.Substring(0, 500)
|
|
LblProductos.ToolTip = str.ToString
|
|
|
|
Else
|
|
LblProductos.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
|
str.AppendFormat("{0},", dr("CodigoPS"))
|
|
Next
|
|
If str.ToString.Length > 500 Then
|
|
LblProductosExcluidos.Text = str.ToString.Substring(0, 500)
|
|
LblProductosExcluidos.ToolTip = str.ToString
|
|
Else
|
|
LblProductosExcluidos.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesProveedores(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
str.AppendFormat("{0},", dr("RazonSocial"))
|
|
Next
|
|
If str.ToString.Length > 500 Then
|
|
LblProveedores.Text = str.ToString.Substring(0, 500)
|
|
LblProveedores.ToolTip = str.ToString
|
|
Else
|
|
LblProveedores.Text = str.ToString
|
|
End If
|
|
str.Clear()
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetalle(CveInventarioFisico, CveUsuario) Then
|
|
If ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
GvIFDUltimoRegistrado.DataSource = ObjInventario.DtResultados.AsEnumerable.OrderByDescending(Function(k) k!CveInventarioFisicoDetalle).Take(1).CopyToDataTable
|
|
|
|
GvIFDUltimoRegistrado.Columns(4).Visible = ObjInventario.DtResultados.Rows(0)("CveSeccionAlmacen").ToString.ToEntero > 0
|
|
GvIFDUltimoRegistrado.Columns(6).Visible = ObjInventario.DtResultados.Rows(0)("Lote").ToString <> ""
|
|
GvIFDUltimoRegistrado.Columns(7).Visible = ObjInventario.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate > MinFecha
|
|
Else
|
|
GvIFDUltimoRegistrado.DataSource = Nothing
|
|
End If
|
|
'DtDatos = ObjInventario.DtResultados
|
|
End If
|
|
Else
|
|
GvIFD.Columns(6).Visible = False
|
|
PAgregar.Visible = False
|
|
BtnGuardar.Enabled = False
|
|
BtnGuardar.Visible = False
|
|
btnFin.Visible = False
|
|
CveSubProyecto = ObjInventario.CveSubProyectoInventario
|
|
lbTitulo.Text = ObjInventario.InventarioFisico
|
|
lbObservaciones.Text = ObjInventario.Observaciones
|
|
lbSubProyecto.Text = ObjInventario.SubProyectoInventario
|
|
lbEstatus.Text = ObjInventario.Estatus
|
|
lbFechaI.Text = ObjInventario.FechaI
|
|
lbFechaF.Text = ObjInventario.FechaF
|
|
|
|
Alert("Ocurrió un error al obterner el inventario fisico", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
GvIFDUltimoRegistrado.DataBind()
|
|
|
|
'If (GvIFD.Rows.Count > 0) Then
|
|
' GvIFD.UseAccessibleHeader = True
|
|
' GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
' RegistraScript("OrdenarGV();")
|
|
'End If
|
|
|
|
UPAgregarPro.Update()
|
|
UPPInventario.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnVerRegistrados_Click(sender As Object, e As EventArgs)
|
|
GvIFD.Visible = True
|
|
DivBuscador.Visible = True
|
|
divRegistrados.Visible = True
|
|
|
|
Dim Inventario As New ClsInventarios
|
|
If Inventario.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero) Then
|
|
If Inventario.DtResultados.Rows.Count > 0 Then
|
|
GvIFD.Columns(4).Visible = Inventario.DtResultados.MAX("CveSeccionAlmacen", "CveSeccionAlmacen IS NOT NULL").ToEntero > 0
|
|
GvIFD.Columns(5).Visible = Inventario.DtResultados.MAX("SerieLote") <> ""
|
|
GvIFD.Columns(6).Visible = Inventario.DtResultados.MAX("Lote") <> ""
|
|
GvIFD.Columns(7).Visible = Inventario.DtResultados.MAX("FechaCaducidad", "FechaCaducidad IS NOT NULL").ToDate > MinFecha
|
|
GvIFD.DataSource = Inventario.DtResultados '.AsEnumerable.OrderByDescending(Function(k) k!CveInventarioFisicoDetalle).Take(500).CopyToDataTable
|
|
Else
|
|
GvIFD.DataSource = Nothing
|
|
End If
|
|
' DtDatos = Inventario.DtResultados
|
|
LtlTotalRegistros.Text = Inventario.DtResultados.Rows.Count
|
|
End If
|
|
Inventario.Dispose()
|
|
GvIFD.DataBind()
|
|
If (GvIFD.Rows.Count > 0) Then
|
|
GvIFD.UseAccessibleHeader = True
|
|
GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
UPPInventario.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " AGREGAR "
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
|
|
Dim Valido As Boolean = False
|
|
Dim CveProducto As Integer = -1
|
|
Dim CveUnidadMedida As Integer
|
|
Dim Codigo As String = If(TxtCodigo.Text.Trim <> "", TxtCodigo.Text.Trim, "-1").Replace("'", "''") ' scanner cambian los guiones por apostrofes
|
|
Dim CodigoBarras As String = If(TxtCodigoBarras.Text.Trim <> "", TxtCodigoBarras.Text.Trim, "-1").Replace("'", "''") ' scanner cambian los guiones por apostrofes
|
|
Dim Serie As String = TxtCodigoSerie.Text.Trim
|
|
Dim Lote As String = If(TxtLote.Text.Length > 0, TxtLote.Text, "-1")
|
|
Dim FechaCaducidad As String = MinFecha.ToString
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
Dim SeccionAlmacen As String = ""
|
|
|
|
Dim Cantidad = TxtCantidadProducto.Text.ToDouble
|
|
|
|
Dim dr As DataRow
|
|
'dr = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{CodigoBarras}' OR Codigo = '{Codigo}' ")
|
|
dr = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{CodigoBarras}' OR Codigo = '{Codigo}'")
|
|
|
|
|
|
|
|
If dr IsNot Nothing Then
|
|
|
|
CveProducto = dr("CvePS").ToString.ToEntero
|
|
CveUnidadMedida = dr("CveUnidadMedida").ToString.ToEntero
|
|
'Dim AplicaSeccion As Boolean = dr("AplicaSeccion") = "1"
|
|
Dim AplicaCaducidad As Boolean = dr("AplicaCaducidad") = "1"
|
|
Dim AplicaLote As Boolean = dr("AplicaLote") = "1"
|
|
Dim AplicaSerie As Boolean = dr("AplicaSerie") = "1"
|
|
Dim AplicaSeccion As Boolean = dr("AplicaSeccion") = "1"
|
|
|
|
'divSeccionAlmacen.Visible = AplicaSeccion
|
|
divLote.Visible = AplicaLote
|
|
divFechaCaducidad.Visible = AplicaCaducidad
|
|
divSerie.Visible = AplicaSerie
|
|
|
|
UPAgregarPro.Update()
|
|
|
|
If AplicaSerie And Serie = "" Then
|
|
RFVSerie.Enabled = True
|
|
RFVSerie.Visible = True
|
|
RFVSerie.SetFocusOnError = True
|
|
RFVSerie.Validate()
|
|
RFVSerie.ValidationGroup = " "
|
|
Exit Sub
|
|
End If
|
|
If AplicaLote And (Lote = "" Or Lote = "-1") Then
|
|
RFVLote.Enabled = True
|
|
RFVLote.Visible = True
|
|
RFVLote.SetFocusOnError = True
|
|
RFVLote.Validate()
|
|
RFVLote.ValidationGroup = " "
|
|
Exit Sub
|
|
End If
|
|
If AplicaCaducidad Then
|
|
If TxtFechaCaducidad.Text.Trim = "" Then
|
|
RFVCaducidad.Enabled = True
|
|
RFVCaducidad.Visible = True
|
|
RFVCaducidad.SetFocusOnError = True
|
|
RFVCaducidad.Validate()
|
|
RFVCaducidad.ValidationGroup = " "
|
|
Exit Sub
|
|
End If
|
|
FechaCaducidad = If(TxtFechaCaducidad.Text.Length > 0, TxtFechaCaducidad.Text, MinFecha.ToString)
|
|
End If
|
|
'If AplicaSeccion Then
|
|
' Dim ObjInv As New ClsInventarios
|
|
' Dim SeccionesAlmacenDelProducto As New DataTable
|
|
' If ObjInv.GetProductosServiciosAlmacenSeccion(CveProducto, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
' SeccionesAlmacenDelProducto = ObjInv.DtResultados.FiltraParametros(String.Format("CveAlmacen IN ({0})", CveAlmacenes))
|
|
' End If
|
|
' 'Dim SeccionesAlmacenDelProducto As DataTable = (UsuarioActual.CveEmpresa, -1, CveProducto) '.FiltraParametros(String.Format("CveAlmacen IN ({0})", CveAlmacenes))
|
|
' 'Alert(SeccionesAlmacenDelProducto.Rows.Count.ToString)
|
|
' If SeccionesAlmacenDelProducto.Rows.Count = 1 Then
|
|
' CveSeccionAlmacen = SeccionesAlmacenDelProducto.FiltroPrimeroValor("CveSeccionAlmacen")
|
|
' Else
|
|
' divSeccion.Visible = AplicaSeccion
|
|
' If DdlSeccionAlmacen.Items.Count = 0 Then
|
|
' DdlSeccionAlmacen.DataSource = SeccionesAlmacenDelProducto
|
|
' DdlSeccionAlmacen.DataBind()
|
|
' DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' End If
|
|
|
|
' If DdlSeccionAlmacen.SelectedValue = "-1" Then
|
|
' RfvSeccionAlmacen.Enabled = True
|
|
' RfvSeccionAlmacen.Visible = True
|
|
' RfvSeccionAlmacen.SetFocusOnError = True
|
|
' RfvSeccionAlmacen.Validate()
|
|
' RfvSeccionAlmacen.ValidationGroup = " "
|
|
' Exit Sub
|
|
' End If
|
|
' CveSeccionAlmacen = DdlSeccionAlmacen.SelectedValue.ToEntero
|
|
' End If
|
|
' ObjInv.Dispose()
|
|
' SeccionAlmacen = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("SeccionAlmacen", String.Format("CveSeccionAlmacen = {0}", CveSeccionAlmacen))
|
|
'End If
|
|
|
|
RFVSerie.ValidationGroup = "GrpIngresar"
|
|
RFVSerie.Enabled = False
|
|
RFVLote.ValidationGroup = "GrpIngresar"
|
|
RFVLote.Enabled = False
|
|
RFVCaducidad.ValidationGroup = "GrpIngresar"
|
|
RFVCaducidad.Enabled = False
|
|
RfvSeccionAlmacen.ValidationGroup = "GrpIngresar"
|
|
RfvSeccionAlmacen.Enabled = False
|
|
|
|
'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS
|
|
If Serie <> "" And (Serie.ToUpper = dr("Codigo").ToString.ToUpper Or Serie.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then
|
|
Alert($"La serie indicada <b>{Serie}</b> coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Consulto As Boolean = False
|
|
Using Inventarios As New ClsInventarios
|
|
|
|
If Inventarios.AddInventarioFisicoDetalle(CveInventarioFisico, CveProducto, CveUnidadMedida, If(AplicaSerie, 1, Cantidad), Serie, UsuarioActual.CveUsuario,
|
|
CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
|
|
|
|
GvIFDUltimoRegistrado.Columns(4).Visible = CveSeccionAlmacen > 0
|
|
GvIFDUltimoRegistrado.Columns(5).Visible = Serie <> ""
|
|
GvIFDUltimoRegistrado.Columns(6).Visible = Lote <> "-1"
|
|
GvIFDUltimoRegistrado.Columns(7).Visible = FechaCaducidad.ToDate > MinFecha
|
|
|
|
If GvIFDUltimoRegistrado.Rows.Count > 0 Then
|
|
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(0).Text = Now
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(1).Text = dr("CodigoBarras").ToString
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(2).Text = dr("Codigo").ToString
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(3).Text = dr("PSCodigo").ToString
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(4).Text = SeccionAlmacen
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(5).Text = TxtCodigoSerie.Text.Trim
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(6).Text = Lote
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(7).Text = FechaCaducidad
|
|
GvIFDUltimoRegistrado.Rows(0).Cells(8).Text = TxtCantidadProducto.Text.Trim
|
|
Else
|
|
Consulto = True
|
|
If Inventarios.GetInventarioFisicoDetalle(CveInventarioFisico, UsuarioActual.CveUsuario, TopSelect:=1) Then
|
|
If Inventarios.DtResultados.Rows.Count > 0 Then
|
|
GvIFDUltimoRegistrado.DataSource = Inventarios.DtResultados.AsEnumerable.OrderByDescending(Function(k) k!CveInventarioFisicoDetalle).Take(1).CopyToDataTable
|
|
Else
|
|
GvIFDUltimoRegistrado.DataSource = Nothing
|
|
End If
|
|
Else
|
|
Alert("Ocurrió un error al consultar el inventario fisico. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
End If
|
|
TxtCodigoBarras.Text = ""
|
|
TxtCodigoSerie.Text = ""
|
|
TxtCodigo.Text = ""
|
|
TxtCantidadProducto.Text = "1"
|
|
TxtLote.Text = ""
|
|
TxtFechaCaducidad.Text = ""
|
|
divLote.Visible = False
|
|
divFechaCaducidad.Visible = False
|
|
divSerie.Visible = False
|
|
divSeccion.Visible = False
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
Else
|
|
TxtCodigoSerie.Text = ""
|
|
End If
|
|
TxtCodigoBarras.Focus()
|
|
End Using
|
|
|
|
If Consulto Then GvIFDUltimoRegistrado.DataBind()
|
|
Else
|
|
TxtCodigoBarras.Text = ""
|
|
TxtCodigoSerie.Text = ""
|
|
TxtCodigo.Text = ""
|
|
divLote.Visible = False
|
|
divFechaCaducidad.Visible = False
|
|
divSerie.Visible = False
|
|
divSeccion.Visible = False
|
|
TxtLote.Text = ""
|
|
TxtFechaCaducidad.Text = ""
|
|
Alert("No se encontró el producto, favor de escribirlo correctamente.", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
GvIFD.Visible = False
|
|
DivBuscador.Visible = False
|
|
divRegistrados.Visible = False
|
|
|
|
UPPInventario.Update()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " ELIMINAR "
|
|
Protected Sub gvInventarioFisicoDetalle_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvIFD.RowDeleting
|
|
If ddlUsuario.SelectedValue = UsuarioActual.CveUsuario.ToString OrElse UsuarioActual.TienePermisoProceso(283) Then
|
|
Dim Inventarios As New ClsInventarios
|
|
Dim Retorno As Boolean = Inventarios.RemoveInventarioFisicoDetalles(GvIFD.DataKeys(e.RowIndex).Value.ToString.ToEntero())
|
|
|
|
If Retorno Then
|
|
If Inventarios.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero) Then
|
|
GvIFD.DataSource = Inventarios.DtResultados
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
End If
|
|
Inventarios.Dispose()
|
|
GvIFD.DataBind()
|
|
|
|
If (GvIFD.Rows.Count > 0) Then
|
|
GvIFD.UseAccessibleHeader = True
|
|
GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
|
|
UPPInventario.Update()
|
|
UPAgregarPro.Update()
|
|
Else
|
|
Alert("No se puede eliminar un producto registrado por otro usuario.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " FINALIZAR "
|
|
Protected Sub btnFin_Click(sender As Object, e As EventArgs) Handles btnFin.Click
|
|
If btnFin.Text.Contains("Iniciar") Then
|
|
Dim Inventarios As New ClsInventarios
|
|
|
|
Inventarios.UpdateInventarioFisicoEstatus(CveInventarioFisico, 1, UsuarioActual.CveEmpresa)
|
|
Inventarios.Dispose()
|
|
|
|
|
|
CargaDatos(CveInventarioFisico, UsuarioActual.CveEmpresa)
|
|
BtnGuardar.Enabled = True
|
|
|
|
Response.Redirect("~/Inventarios/InventarioFisicoDetalle.aspx?CveInventarioFisico=" + CveInventarioFisico.ToString)
|
|
|
|
Else
|
|
If GvIFDUltimoRegistrado.Rows.Count > 0 Then
|
|
BtnGuardar.Enabled = False
|
|
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()
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
Else
|
|
Inventarios.RollBack()
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
Else
|
|
Inventarios.RollBack()
|
|
End If
|
|
|
|
Inventarios.Dispose()
|
|
|
|
Else
|
|
Alert("Aún no se ha ingresado ningún registro.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
UPAgregarPro.Update()
|
|
UPPInventario.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " VER AVANCE "
|
|
Protected Sub LBAvance_Click(sender As Object, e As EventArgs)
|
|
Response.Redirect($"~/Inventarios/RepAnomalias.aspx?CveInventarioFisico={CveInventarioFisico}&EsAvance=1")
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "I M P R I M I R"
|
|
Private Sub LnkPDF_Click(sender As Object, e As EventArgs) Handles LnkPDF.Click
|
|
Impimir(Formato:="PDF")
|
|
End Sub
|
|
Private Sub LnkPDFResumido_Click(sender As Object, e As EventArgs) Handles LnkPDFResumido.Click
|
|
Impimir(Formato:="PDF", Agrupar:=True)
|
|
End Sub
|
|
Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
|
|
Impimir(Formato:="EXCEL")
|
|
End Sub
|
|
Protected Sub Impimir(Optional Formato As String = "PDF", Optional Agrupar As Boolean = False)
|
|
Dim DtDatos As New DataTable
|
|
Dim ObjInventario As New ClsInventarios()
|
|
If ObjInventario.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue, Agrupar:=Agrupar) Then
|
|
DtDatos = ObjInventario.DtResultados.FiltraParametros("CveInventarioFisico > 0 ").Copy
|
|
End If
|
|
ObjInventario.Dispose()
|
|
|
|
If DtDatos IsNot Nothing Then
|
|
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)
|
|
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("Titulo", lbTitulo.Text))
|
|
params.Add(New ReportParameter("Sucursal", lbSubProyecto.Text))
|
|
params.Add(New ReportParameter("Clasificaciones", LblClasif.Text))
|
|
params.Add(New ReportParameter("Productos", LblProductos.Text))
|
|
params.Add(New ReportParameter("Observaciones", lbObservaciones.Text))
|
|
params.Add(New ReportParameter("Almacen", LblAlmacenes.Text))
|
|
params.Add(New ReportParameter("Estatus", lbEstatus.Text))
|
|
params.Add(New ReportParameter("FechaInicio", lbFechaI.Text))
|
|
params.Add(New ReportParameter("FechaFin", lbFechaF.Text))
|
|
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
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepInventarioFisicoDetalle.rdlc", DtDatos, params, String.Format("Reporte Inventario Físico-{0}", Now.ToDateTime.ToShortDateString), Formato:=Formato)
|
|
|
|
Else
|
|
Alert("No se encontraron resultado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub LnkExcelUniverso_Click(sender As Object, e As EventArgs) Handles LnkExcelUniverso.Click
|
|
Dim IncluyePS, ExcluyePS, IncluyeClasificacion, ExcluyeClasificacion, IncluyeProveedor As New StringBuilder
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
IncluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion"))
|
|
Next
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
|
ExcluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion"))
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesProductosServicios(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
IncluyePS.AppendFormat("{0},", dr("CvePS"))
|
|
Next
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
|
ExcluyePS.AppendFormat("{0},", dr("CvePS"))
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjInventario.GetInventarioFisicoDetallesProveedores(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
|
Dim dt As DataTable = ObjInventario.DtResultados
|
|
Dim str As New StringBuilder
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
|
IncluyeProveedor.AppendFormat("{0},", dr("CveProveedor"))
|
|
Next
|
|
End If
|
|
End If
|
|
Dim dtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
|
|
If IncluyePS.ToString <> "" Then
|
|
dtPS = dtPS.FiltraParametros(String.Format("CvePS IN ({0})", IncluyePS.ToString.TrimEnd(",")))
|
|
End If
|
|
If ExcluyePS.ToString <> "" Then
|
|
dtPS = dtPS.FiltraParametros(String.Format("CvePS NOT IN ({0})", ExcluyePS.ToString.TrimEnd(",")))
|
|
End If
|
|
If IncluyeClasificacion.ToString <> "" Then
|
|
dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion IN ({0})", IncluyeClasificacion.ToString.TrimEnd(",")))
|
|
End If
|
|
If ExcluyeClasificacion.ToString <> "" Then
|
|
dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion NOT IN ({0})", ExcluyeClasificacion.ToString.TrimEnd(",")))
|
|
End If
|
|
If IncluyeProveedor.ToString <> "" Then
|
|
dtPS = dtPS.FiltraParametros(String.Format("CveProveedorCompra IN ({0})", IncluyeProveedor.ToString.TrimEnd(",")))
|
|
End If
|
|
dtPS = dtPS.FiltraParametros("", "PS", {"Codigo", "PS"})
|
|
Dim NombreArchivo As String
|
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
Dim workbook As New ExcelFile()
|
|
Dim worksheet = workbook.Worksheets.Add("Cxp")
|
|
worksheet.InsertDataTable(dtPS, New InsertDataTableOptions() With
|
|
{
|
|
.ColumnHeaders = True,
|
|
.StartRow = 0,
|
|
.StartColumn = 0
|
|
})
|
|
|
|
'worksheet.Columns("B").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
|
'worksheet.Columns("C").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
|
'worksheet.Columns("Q").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
|
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
|
|
|
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
|
For i = 0 To columnCount
|
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
|
Next
|
|
|
|
NombreArchivo = "CxP"
|
|
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub BtnBuscarCodVarras_Click(sender As Object, e As EventArgs)
|
|
Dim CodigoBarras As String = If(TxtConCodigoVarras.Text.Trim <> "", TxtConCodigoVarras.Text.Trim, "-1").Replace("'", "''")
|
|
LblContador.Text = "No se encontraron resultados"
|
|
Using Inventarios As New ClsInventarios
|
|
If Inventarios.GetInventarioFisicoContador(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero, CodigoBarras) Then
|
|
'Cantidad,@CodigoBarras CodigoBarras
|
|
If (Inventarios.DtResultados.Rows.Count > 0) Then
|
|
Dim drow As DataRow = Inventarios.DtResultados.Rows(0)
|
|
If (drow("Cantidad").ToString().ToDouble() > 0) Then
|
|
LblContador.Text = String.Format("Contador={0:##,###.##}", drow("Cantidad"))
|
|
Else
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
End Using
|
|
UpBuscar.Update()
|
|
' UsuarioActual.CveUsuario
|
|
'
|
|
End Sub
|
|
|
|
'Protected Sub TxtCodigoBarras_Change(sender As Object, e As EventArgs)
|
|
' Dim Producto As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoBarras.Text}'")
|
|
|
|
' If Producto IsNot Nothing Then
|
|
' Dim AplicaSeccion As Boolean = Producto("AplicaSeccion") = "1"
|
|
' Dim AplicaCaducidad As Boolean = Producto("AplicaCaducidad") = "1"
|
|
' Dim AplicaLote As Boolean = Producto("AplicaLote") = "1"
|
|
' Dim AplicaSerie As Boolean = Producto("AplicaSerie") = "1"
|
|
|
|
' 'divSeccionAlmacen.Visible = AplicaSeccion
|
|
' divLote.Visible = AplicaLote
|
|
' divFechaCaducidad.Visible = AplicaCaducidad
|
|
' divSerie.Visible = AplicaSerie
|
|
' End If
|
|
|
|
' UPAgregarPro.Update()
|
|
'End Sub
|
|
|
|
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
LimpiarModal()
|
|
HfCveInventarioFisicoDetalle.Value = GvRow.DataKey("CveInventarioFisicoDetalle").ToString
|
|
|
|
HfCvePS.Value = GvRow.DataKey("CvePS").ToString
|
|
HfCveUM.Value = GvRow.DataKey("CveUnidadMedida").ToString
|
|
|
|
TxtSerieLote.Text = GvRow.DataKey("SerieLote").ToString
|
|
TxtLoteEdit.Text = GvRow.DataKey("Lote").ToString
|
|
TxtFechaCaducida.Text = GvRow.DataKey("FechaCaducidad").ToString
|
|
TxtCantidad.Text = GvRow.DataKey("Cantidad").ToString
|
|
UpEditarPS.Update()
|
|
|
|
RegistraScript("$('#ModalEditarPS').modal('show')")
|
|
End Sub
|
|
|
|
|
|
Private Sub LimpiarModal()
|
|
HfCveInventarioFisicoDetalle.Value = ""
|
|
HfCvePS.Value = ""
|
|
HfCveUM.Value = ""
|
|
TxtSerieLote.Text = ""
|
|
TxtLoteEdit.Text = ""
|
|
TxtFechaCaducida.Text = ""
|
|
TxtCantidad.Text = ""
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnGuadarEditarPS_Click(sender As Object, e As EventArgs)
|
|
Dim objInventario As New ClsInventarios
|
|
If Not TxtCantidad.Text.ToEntero > 0 Then
|
|
Alert("La cantidad debe ser mayor a 0", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim serie As String = IIf(TxtSerieLote.Text.ToString = "", "-1", TxtSerieLote.Text.ToString)
|
|
Dim Lote As String = IIf(TxtLoteEdit.Text.ToString = "", "-1", TxtLoteEdit.Text.ToString)
|
|
Dim FechaCaducida As Date = IIf(TxtFechaCaducida.Text.ToString = "", MinFecha, TxtFechaCaducida.Text.ToString.ToDate)
|
|
|
|
If objInventario.UpdateInventarioFisicoDetalles(HfCveInventarioFisicoDetalle.Value.ToEntero, HfCvePS.Value.ToEntero, HfCveUM.Value.ToEntero, TxtCantidad.Text.ToEntero, serie, Lote, FechaCaducida) Then
|
|
If objInventario.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero) Then
|
|
GvIFD.DataSource = objInventario.DtResultados
|
|
End If
|
|
|
|
GvIFD.DataBind()
|
|
|
|
If (GvIFD.Rows.Count > 0) Then
|
|
GvIFD.UseAccessibleHeader = True
|
|
GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
|
|
UPPInventario.Update()
|
|
UPAgregarPro.Update()
|
|
RegistraScript("$('#ModalEditarPS').modal('hide')")
|
|
Alert("Se modico el producto correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al actuliazar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
objInventario.Dispose()
|
|
End Sub
|
|
End Class
|