SMS 2024.02.08 Paquetes. verificar la existencia del producto, considerando lote/caducidad
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO.Packaging
|
||||
Imports Extensiones
|
||||
Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Inherits ClsPaginas
|
||||
@@ -89,12 +90,32 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property AplicaSerie As Boolean
|
||||
Private Property AplicaLotePaquete As Boolean
|
||||
Get
|
||||
Return CType(ViewState("AplicaSerie"), Boolean)
|
||||
Return CType(ViewState("AplicaLotePaquete"), Boolean)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("AplicaSerie") = value
|
||||
ViewState("AplicaLotePaquete") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property AplicaCaducidadPaquete As Boolean
|
||||
Get
|
||||
Return CType(ViewState("AplicaCaducidadPaquete"), Boolean)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("AplicaCaducidadPaquete") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property AplicaSeriePaquete As Boolean
|
||||
Get
|
||||
Return CType(ViewState("AplicaSeriePaquete"), Boolean)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("AplicaSeriePaquete") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
@@ -245,6 +266,12 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
|
||||
#Region " PROCESAR - VERIFICAR EXISTENCIAS "
|
||||
Protected Sub BtnVerificarExistenciasArmado_Click(sender As Object, e As EventArgs)
|
||||
|
||||
|
||||
AplicaSeriePaquete = False
|
||||
AplicaLotePaquete = False
|
||||
AplicaCaducidadPaquete = False
|
||||
|
||||
TipoMovimiento = 1
|
||||
Limpia(TipoMovimiento)
|
||||
|
||||
@@ -289,24 +316,43 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
If ErrorExistencias Then
|
||||
Alert(TextoExistencias, TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
AplicaSerie = CBool(drP("AplicaSerie"))
|
||||
AplicaSeriePaquete = CBool(drP("AplicaSerie"))
|
||||
AplicaLotePaquete = CBool(drP("AplicaLote"))
|
||||
AplicaCaducidadPaquete = CBool(drP("AplicaCaducidad"))
|
||||
BtnGuadarArmado.Visible = True
|
||||
End If
|
||||
|
||||
If AplicaSerie Then
|
||||
|
||||
|
||||
|
||||
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
||||
DivSeriesPaqueteArmado.Visible = True
|
||||
Dim Dt As New DataTable
|
||||
Dt.Columns.Add("Row", GetType(Integer))
|
||||
Dt.Columns.Add("Serie", GetType(String))
|
||||
Dt.Columns.Add("Lote", GetType(String))
|
||||
Dt.Columns.Add("FechaCaducidad", GetType(Date))
|
||||
|
||||
For index = 1 To TxtCantidadArmado.Text.ToEntero
|
||||
Dim Row = Dt.NewRow
|
||||
Row("Row") = index
|
||||
Row("Serie") = ""
|
||||
Row("Lote") = ""
|
||||
Row("FechaCaducidad") = MinFecha
|
||||
Dt.Rows.Add(Row)
|
||||
Next
|
||||
|
||||
GvSeriesPaqueteArmado.Columns(1).Visible = AplicaSeriePaquete
|
||||
GvSeriesPaqueteArmado.Columns(2).Visible = AplicaLotePaquete
|
||||
GvSeriesPaqueteArmado.Columns(3).Visible = AplicaCaducidadPaquete
|
||||
|
||||
GvSeriesPaqueteArmado.DataSource = Dt
|
||||
GvSeriesPaqueteArmado.DataBind()
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
UpSeriesPaqueteArmado.Update()
|
||||
|
||||
CvePaqueteArmado = DdlPaqueteArmado.SelectedValue.ToEntero
|
||||
@@ -328,10 +374,16 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
UpGeneralesArmado.Update()
|
||||
End Sub
|
||||
Protected Sub BtnVerificarExistenciasDesarmado_Click(sender As Object, e As EventArgs)
|
||||
|
||||
|
||||
DvDesArmadoCaducidad.Visible = False
|
||||
DvDesArmadoLote.Visible = False
|
||||
DvDesArmadoSerie.Visible = False
|
||||
|
||||
DtDatosDetalle.Clear()
|
||||
BtnGuadarDesarmado.Visible = False
|
||||
TotalDesarmado.Visible = False
|
||||
AplicaSerie = False
|
||||
AplicaSeriePaquete = False
|
||||
TxtSerieDesarmado.Text = ""
|
||||
CvePaqueteDesarmado = -1
|
||||
TipoMovimiento = 2
|
||||
@@ -362,7 +414,9 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Alert($"No hay existencia suficiente del paquete <b>""{DdlPaqueteDesarmado.SelectedItem.Text}""</b> para desarmar. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
Else
|
||||
AplicaSerie = CBool(drP("AplicaSerie"))
|
||||
AplicaSeriePaquete = CBool(drP("AplicaSerie"))
|
||||
AplicaLotePaquete = CBool(drP("AplicaLote"))
|
||||
AplicaCaducidadPaquete = CBool(drP("AplicaCaducidad"))
|
||||
End If
|
||||
|
||||
|
||||
@@ -391,13 +445,23 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Next
|
||||
End If
|
||||
|
||||
If AplicaSerie Then
|
||||
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
||||
|
||||
DvDesArmadoCaducidad.Visible = AplicaSeriePaquete
|
||||
DvDesArmadoLote.Visible = AplicaLotePaquete
|
||||
DvDesArmadoSerie.Visible = AplicaCaducidadPaquete
|
||||
|
||||
GvSeriesPaqueteDesarmado.Columns(1).Visible = AplicaSeriePaquete
|
||||
GvSeriesPaqueteDesarmado.Columns(2).Visible = AplicaLotePaquete
|
||||
GvSeriesPaqueteDesarmado.Columns(3).Visible = AplicaCaducidadPaquete
|
||||
|
||||
DivSeriesPaqueteDesarmado.Visible = True
|
||||
CreaDtSeriesDesarmado()
|
||||
DtSeriesDesarmado.Clear()
|
||||
|
||||
GvSeriesPaqueteDesarmado.DataSource = DtSeriesDesarmado
|
||||
GvSeriesPaqueteDesarmado.DataBind()
|
||||
|
||||
End If
|
||||
UpSeriesPaqueteDesarmado.Update()
|
||||
|
||||
@@ -454,42 +518,118 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Case 1 ' ARMADO
|
||||
For Each gvr As GridViewRow In GvDatosArmado.Rows
|
||||
If gvr.DataKey("AplicaSerie") = "True" Then
|
||||
If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
||||
Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
|
||||
''If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
||||
'' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
'' Exit Sub
|
||||
''End If
|
||||
'If gvr.FCTextBox("TxtSerie") Then
|
||||
|
||||
'End If
|
||||
|
||||
'If gvr.FCTextBox("TxtSerie").Text.Trim = "" Then
|
||||
' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
'End If
|
||||
|
||||
End If
|
||||
|
||||
If gvr.DataKey("AplicaLote") = "True" Then
|
||||
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
||||
Alert("Es necesario ingresas todos los lotes de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
If gvr.DataKey("AplicaCaducidad") = "True" Then
|
||||
|
||||
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
||||
Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
Case 2 ' DESARMADO
|
||||
For Each gvr As GridViewRow In GvDatosDesarmado.Rows
|
||||
|
||||
If gvr.DataKey("AplicaSerie") = "True" Then
|
||||
If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
||||
|
||||
'If gvr.DataKey("AplicaSerie") = "True" Then
|
||||
' 'If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
||||
' ' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
' ' Exit Sub
|
||||
' 'End If
|
||||
'End If
|
||||
|
||||
If gvr.FCTextBox("Serie").Text.Trim = "" Then
|
||||
Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If gvr.DataKey("AplicaLote") = "True" Then
|
||||
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
||||
Alert("Es necesario ingresas todos los lotes de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
If gvr.DataKey("AplicaCaducidad") = "True" Then
|
||||
|
||||
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
||||
Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
End Select
|
||||
|
||||
'VALIDA SI EL PAQUETE ES DE SERIE QUE SE INGRESEN TODAS LAS SERIES (CANTIDAD)
|
||||
If AplicaSerie Then
|
||||
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
||||
Select Case (Tipo)
|
||||
Case 1 ' ARMADO
|
||||
For Each gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
|
||||
If gvr.FCTextBox("TxtSerie").Text.Trim = "" Then
|
||||
Alert("Es necesario indicar las series del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
|
||||
If AplicaSeriePaquete Then
|
||||
If gvr.FCTextBox("TxtSerie").Text.Trim = "" Then
|
||||
Alert("Es necesario indicar las series del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
If AplicaLotePaquete Then
|
||||
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
||||
Alert("Es necesario indicar los lotes del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
If AplicaCaducidadPaquete Then
|
||||
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
||||
Alert("Es necesario indicar fechas de caducidad validas del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
Case 2 ' DESARMADO
|
||||
|
||||
If TxtCantidadDesarmado.Text.ToEntero <> DtSeriesDesarmado.Rows.Count Then
|
||||
Alert("Es necesario indicar las series del paquete a desarmar.", TipoMensaje.MsgAdvertencia)
|
||||
Alert("Es necesario indicar las series, lotes o Fecha de caducidad del paquete a desarmar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
End Select
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim TextoError As New StringBuilder
|
||||
If Tipo = 1 Then
|
||||
Dim ObjInventarioVal As New ClsInventarios
|
||||
@@ -572,7 +712,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
End If
|
||||
|
||||
|
||||
Exit Sub
|
||||
|
||||
|
||||
|
||||
Dim ObjInventario As New ClsInventarios
|
||||
@@ -669,12 +809,17 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
End If
|
||||
|
||||
|
||||
If AplicaSerie Then
|
||||
If AplicaSeriePaquete Then
|
||||
Dim ContadorPaquete = 1
|
||||
Dim DtSeriesComponentes As New DataTable
|
||||
For Each Gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
|
||||
'AGREGA MOVTO DETALLE DE LA ENTRADA DEL PAQUETE
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Gvr.FCTextBox("TxtSerie").Text.Trim) Then
|
||||
|
||||
Dim Serie As String = Gvr.FCTextBox("TxtSerie").Text.Trim
|
||||
Dim Lote As String = Gvr.FCTextBox("TxtLote").Text.Trim
|
||||
Dim FechaCaducidad As Date = If(Gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha, MinFecha, Gvr.FCTextBox("TxtCaducidad").Text.ToDate)
|
||||
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Then
|
||||
TieneError = True
|
||||
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada"
|
||||
Exit For
|
||||
@@ -736,10 +881,17 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
'If AplicaSeccion Then
|
||||
' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
|
||||
'End If
|
||||
If AplicaSerie Then
|
||||
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
||||
|
||||
|
||||
For Each Gvr As GridViewRow In GvSeriesPaqueteDesarmado.Rows
|
||||
|
||||
Dim Serie As String = If(AplicaSeriePaquete, Gvr.DataKey("Serie").Trim, "-1")
|
||||
Dim Lote As String = If(AplicaLotePaquete, Gvr.DataKey("Lote").Trim, "-1")
|
||||
Dim FechaCaducidad As Date = If(AplicaCaducidadPaquete, Gvr.DataKey("FechaCaducidad").Trim.ToDate, MinFecha)
|
||||
|
||||
'AGREGA MOVTO DETALLE DE LA SALIDA DEL PAQUETE
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=-3, Serie:=Gvr.DataKey("Serie").ToString) Then
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=-3, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Then
|
||||
TieneError = True
|
||||
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
|
||||
Exit For
|
||||
@@ -751,6 +903,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
Else
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, TxtCantidadDesarmado.Text.ToDecimal, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=CveSeccionAlmacen) Then
|
||||
@@ -878,7 +1031,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Private Sub Limpia(Tipo As Integer)
|
||||
|
||||
DtDatosDetalle.Clear()
|
||||
AplicaSerie = False
|
||||
AplicaSeriePaquete = False
|
||||
|
||||
|
||||
'If Tipo = 1 Then
|
||||
@@ -1441,6 +1594,11 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Dt.Columns.Add("Row", GetType(Integer))
|
||||
Dt.Columns.Add("Serie", GetType(String))
|
||||
|
||||
'Dim DrPS As DataRow = Nothing
|
||||
'DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=_DdlPaqueteArmado.SelectedValue.ToEntero).FiltroPrimero("")
|
||||
'Dim AplicaSerie
|
||||
|
||||
|
||||
For Each Row As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CType(sender, LinkButton).CommandArgument.ToEntero)).Rows
|
||||
If i > TxtCantidadArmado.Text.ToEntero Then
|
||||
Exit For
|
||||
@@ -1456,6 +1614,9 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
|
||||
GvSeriesPaqueteArmado.DataSource = Dt
|
||||
GvSeriesPaqueteArmado.DataBind()
|
||||
|
||||
|
||||
|
||||
UpSeriesPaqueteArmado.Update()
|
||||
End Sub
|
||||
|
||||
@@ -1465,15 +1626,23 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
DtSeriesDesarmado = New DataTable
|
||||
DtSeriesDesarmado.Columns.Add("Row", GetType(Integer))
|
||||
DtSeriesDesarmado.Columns.Add("Serie", GetType(String))
|
||||
DtSeriesDesarmado.Columns.Add("Lote", GetType(String))
|
||||
DtSeriesDesarmado.Columns.Add("FechaCaducidad", GetType(Date))
|
||||
|
||||
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub BtnAgregarSerieDesarmado_Click(sender As Object, e As EventArgs)
|
||||
Dim Serie = TxtSerieDesarmado.Text.Trim
|
||||
Dim Serie As String = If(AplicaSeriePaquete, TxtSerieDesarmado.Text.Trim, "-1")
|
||||
Dim Lote As String = If(AplicaLotePaquete, TxtLoteDesarmado.Text.Trim, "-1")
|
||||
Dim FechaCaducidad As Date = If(AplicaCaducidadPaquete, TxtDesarmadoCaducidad.Text.ToDate, MinFecha)
|
||||
|
||||
'VERIFICA EXISTENCIAS
|
||||
Dim ObjInventarios As New ClsInventarios
|
||||
Dim CveUMTemp = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimeroValor("CveUM").ToEntero
|
||||
Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente))
|
||||
Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie,
|
||||
CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, FechaCaducidad:=FechaCaducidad)
|
||||
|
||||
If Existencia < 1 Then
|
||||
Alert($"No hay existencia suficiente con la Serie definida <b>""{Serie}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
@@ -1495,9 +1664,15 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
|
||||
Dim Row = DtSeriesDesarmado.NewRow
|
||||
Row("Row") = DtSeriesDesarmado.MAX("Row").ToEntero + 1
|
||||
Row("Serie") = TxtSerieDesarmado.Text.Trim
|
||||
Row("Lote") = TxtLoteDesarmado.Text.Trim
|
||||
Row("FechaCaducidad") = TxtDesarmadoCaducidad.Text.ToDate
|
||||
|
||||
DtSeriesDesarmado.Rows.Add(Row)
|
||||
|
||||
TxtSerieDesarmado.Text = ""
|
||||
TxtLoteDesarmado.Text = ""
|
||||
TxtDesarmadoCaducidad.Text = ""
|
||||
|
||||
|
||||
If DtSeriesDesarmado.Rows.Count >= TxtCantidadDesarmado.Text.ToEntero Then
|
||||
BtnAgregarSerieDesarmado.Enabled = False
|
||||
|
||||
Reference in New Issue
Block a user