ajustes en manejo de lote/caducidad

This commit is contained in:
2021-03-10 16:24:28 -07:00
parent c6e5ec3af7
commit d54b067b56

View File

@@ -263,6 +263,15 @@ Partial Class Inventarios_EntregaAlmacen
End Set End Set
End Property End Property
Private Property ValidaLoteCaducidad As Boolean
Get
Return CType(ViewState("ValidaLoteCaducidad"), Boolean)
End Get
Set(value As Boolean)
ViewState("ValidaLoteCaducidad") = value
End Set
End Property
#End Region #End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
@@ -270,7 +279,7 @@ Partial Class Inventarios_EntregaAlmacen
InicializaValores() InicializaValores()
CargaParametrosAD() CargaParametrosAD()
If UsuarioActual.CveEmpresa.Contiene(72, 80, 146, 119) Then DdlAlmacen.AutoPostBack = True If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 146, 119) Then DdlAlmacen.AutoPostBack = True
If UsuarioActual.Empresa.Funcionalidad(281).ToEntero() = 1 Then If UsuarioActual.Empresa.Funcionalidad(281).ToEntero() = 1 Then
@@ -527,7 +536,7 @@ Partial Class Inventarios_EntregaAlmacen
CveVentaAD = -2 CveVentaAD = -2
CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero()) CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero())
End Sub End Sub
Private Sub CargaVentaPorSurtir(CveVenta As Integer) Private Sub CargaVentaPorSurtir(CveVenta As Integer, Optional CveAlmacen As Integer = -1)
LbSurtida.Visible = False LbSurtida.Visible = False
CveContrato = -1 CveContrato = -1
CveSubProyecto = -1 CveSubProyecto = -1
@@ -544,14 +553,14 @@ Partial Class Inventarios_EntregaAlmacen
Dim ObjInventario As New ClsInventarios Dim ObjInventario As New ClsInventarios
If ObjInventario.EntregaAlmacenGet(CveVenta) Then If ObjInventario.EntregaAlmacenGet(CveVenta, CveAlmacen) Then
If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
DtDatos = ObjInventario.DtResultados DtDatos = ObjInventario.DtResultados
DtDatos.Columns.Add("Consec", GetType(Integer)) If Not DtDatos.Columns.Contains("Consec") Then DtDatos.Columns.Add("Consec", GetType(Integer))
DtDatos.Columns.Add("CantidadGV", GetType(Double)) If Not DtDatos.Columns.Contains("CantidadGV") Then DtDatos.Columns.Add("CantidadGV", GetType(Double))
DtDatos.Columns.Add("CantidadTraspaso", GetType(Double)) If Not DtDatos.Columns.Contains("CantidadTraspaso") Then DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
Dim Index = 1 Dim Index = 1
For Each Dr As DataRow In DtDatos.Rows For Each Dr As DataRow In DtDatos.Rows
Dr("Consec") = Index Dr("Consec") = Index
@@ -605,43 +614,45 @@ Partial Class Inventarios_EntregaAlmacen
If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then
Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError) Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError)
BtnGuardar.Visible = False BtnGuardar.Visible = False
End If End If
DdlAlmacen.Items.Clear()
If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString() = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION If CveAlmacen <= 0 Then
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString())) DdlAlmacen.Items.Clear()
Else If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString() = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION
'[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018 DdlAlmacen.Items.Clear()
Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "") DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString()))
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}") Else
End If '[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
DdlAlmacen.SelectedValue = "-1" DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
DdlAlmacen.DataBind() End If
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
If CveAlmacenTraspasoOrigen > 0 Then DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen) DdlAlmacen.SelectedValue = "-1"
End If DdlAlmacen.DataBind()
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
If Not DtDatos.Columns.Contains("Serie") Then If CveAlmacenTraspasoOrigen > 0 Then
DtDatos.Columns.Add("Serie", GetType(String)) DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
End If End If
If Not DtDatos.Columns.Contains("Lote") Then End If
DtDatos.Columns.Add("Lote", GetType(String))
End If If UsuarioActual.CveEmpresa = 119 AndAlso CveSubProyecto = 10276 Then
If Not DtDatos.Columns.Contains("CveSeccion") Then ValidaLoteCaducidad = True
DtDatos.Columns.Add("CveSeccion", GetType(Integer)) End If
End If
If Not DtDatos.Columns.Contains("FechaCaducidad") Then If Not DtDatos.Columns.Contains("Serie") Then DtDatos.Columns.Add("Serie", GetType(String))
DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
End If If Not DtDatos.Columns.Contains("Lote") Then DtDatos.Columns.Add("Lote", GetType(String))
If Not DtDatos.Columns.Contains("Seleccionado") Then
DtDatos.Columns.Add("Seleccionado", GetType(Boolean)) If Not DtDatos.Columns.Contains("CveSeccion") Then DtDatos.Columns.Add("CveSeccion", GetType(Integer))
End If
If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then If Not DtDatos.Columns.Contains("FechaCaducidad") Then DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
End If If Not DtDatos.Columns.Contains("Seleccionado") Then DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then
FormaPaqueteria = DtDatos.Rows(0)("FormaPaqueteria").ToString().ToEntero() FormaPaqueteria = DtDatos.Rows(0)("FormaPaqueteria").ToString().ToEntero()
Dim FormaPaq As Integer = FormaPaqueteria Dim FormaPaq As Integer = FormaPaqueteria
@@ -692,7 +703,7 @@ Partial Class Inventarios_EntregaAlmacen
If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then
Dim DtMov As DataTable = DtExistencias.FiltraParametros("CveConcepto = 40", "", {"CveAlmacen"}) Dim DtMov As DataTable = DtExistencias.FiltraParametros("CveConcepto = 40", "", {"CveAlmacen"})
If DtMov.Rows.Count > 0 Then If DtMov.Rows.Count > 0 AndAlso CveAlmacen <= 0 Then
Dim CveAlmacenDev As Integer = DtMov.Rows(0)("CveAlmacen").ToString().ToEntero() Dim CveAlmacenDev As Integer = DtMov.Rows(0)("CveAlmacen").ToString().ToEntero()
DdlAlmacen.Items.Clear() DdlAlmacen.Items.Clear()
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}") DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}")
@@ -719,7 +730,7 @@ Partial Class Inventarios_EntregaAlmacen
ObjInventario.Dispose() ObjInventario.Dispose()
UpGenerales.Update() UpGenerales.Update()
CargaGvDatos() If CveAlmacen <= 0 Then CargaGvDatos()
End Sub End Sub
Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer) Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer)
@@ -853,8 +864,9 @@ Partial Class Inventarios_EntregaAlmacen
'GvDatos.Columns(9).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) <> "", UsuarioActual.Empresa.Funcionalidad(147), "") 'GvDatos.Columns(9).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) <> "", UsuarioActual.Empresa.Funcionalidad(147), "")
'SugerirFecha() 'SugerirFecha()
If DdlAlmacen.SelectedValue.ToEntero > 0 Then If DdlAlmacen.SelectedValue.ToEntero > 0 And CveVentaSurtir > 0 Then
SugiereLoteCaducidad(DdlAlmacen.SelectedValue.ToEntero) CargaVentaPorSurtir(CveVentaSurtir, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero)
' SugiereLoteCaducidad(DdlAlmacen.SelectedValue.ToEntero)
End If End If
End If End If
GvDatos.DataSource = DtDatos GvDatos.DataSource = DtDatos
@@ -943,21 +955,25 @@ Partial Class Inventarios_EntregaAlmacen
e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
End If End If
If CBool(e.Row.DBCampo("AplicaCaducidad")) Then If (ValidaLoteCaducidad) OrElse (UsuarioActual.CveEmpresa <> 119) Then
e.Row.FCTextBox("TxtCaducidad").Visible = True If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
e.Row.FCLinkButton("LnkCaducidad").Visible = True e.Row.FCTextBox("TxtCaducidad").Visible = True
e.Row.FCLinkButton("LnkCaducidad").Visible = True
Else e.Row.FCTextBox("TxtCaducidad").readonly = True
e.Row.FCTextBox("TxtCaducidad").Visible = False Else
e.Row.FCLinkButton("LnkCaducidad").Visible = False e.Row.FCTextBox("TxtCaducidad").Visible = False
End If e.Row.FCLinkButton("LnkCaducidad").Visible = False
End If
If CBool(e.Row.DBCampo("AplicaLote")) Then
e.Row.FCTextBox("TxtLote").Visible = True If CBool(e.Row.DBCampo("AplicaLote")) Then
Else e.Row.FCTextBox("TxtLote").Visible = True
e.Row.FCTextBox("TxtLote").Visible = False e.Row.FCTextBox("TxtLote").readonly = True
End If Else
e.Row.FCTextBox("TxtLote").Visible = False
End If
End If
e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID))
e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString() e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString()
e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("CantidadF"), e.Row.FCButton("BtnDividir").ClientID)) e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("CantidadF"), e.Row.FCButton("BtnDividir").ClientID))
@@ -1627,7 +1643,13 @@ Partial Class Inventarios_EntregaAlmacen
Exit For Exit For
End If End If
Next Next
If (Not ValidaLoteCaducidad) OrElse (UsuarioActual.CveEmpresa <> 119) Then
ValidaSeccion = False
ValidaCaducidad = False
ValidaLote = False
End If
If ValidaSeccion Then If ValidaSeccion Then
Alert("La sección de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia) Alert("La sección de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
@@ -1769,6 +1791,11 @@ Partial Class Inventarios_EntregaAlmacen
FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString() <> "", Dr("FechaCaducidad").ToString().ToDate, MinFecha) FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString() <> "", Dr("FechaCaducidad").ToString().ToDate, MinFecha)
Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1") Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1")
If Not ValidaLoteCaducidad Then
FechaCaducidad = MinFecha
Lote = "-1"
End If
If Dr("CantidadGV").ToString().ToDecimal > 0 Then If Dr("CantidadGV").ToString().ToDecimal > 0 Then
If CBool(Dr("AplicaSerie")) Then If CBool(Dr("AplicaSerie")) Then
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
@@ -2438,7 +2465,7 @@ Partial Class Inventarios_EntregaAlmacen
PU = DtExistencias.FiltroPrimeroValor("PU", $"CveTipoAlmacenDevolucion <> 26 AND CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString().ToEntero()} AND Serie = '{Dr1("Serie").ToString()}'").ToString().ToDecimal PU = DtExistencias.FiltroPrimeroValor("PU", $"CveTipoAlmacenDevolucion <> 26 AND CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString().ToEntero()} AND Serie = '{Dr1("Serie").ToString()}'").ToString().ToDecimal
End If End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), PU, Serie:=Dr1("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString().ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString().ToEntero(), -1)) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), PU, Serie:=Dr1("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString().ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1"), CveSeccionAlmacen:=-3) Then
ErrorMovInv = True ErrorMovInv = True
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.") TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
Exit For Exit For
@@ -2450,7 +2477,7 @@ Partial Class Inventarios_EntregaAlmacen
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString().ToEntero()} AND Serie = '{Dr1("Serie").ToString()}'").ToString().ToDecimal PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString().ToEntero()} AND Serie = '{Dr1("Serie").ToString()}'").ToString().ToDecimal
End If End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString().ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString().ToEntero(), -1)) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString().ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1"), CveSeccionAlmacen:=-3) Then
ErrorMovInv = True ErrorMovInv = True
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.") TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
Exit For Exit For