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 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
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
@@ -270,7 +279,7 @@ Partial Class Inventarios_EntregaAlmacen
InicializaValores()
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
@@ -527,7 +536,7 @@ Partial Class Inventarios_EntregaAlmacen
CveVentaAD = -2
CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero())
End Sub
Private Sub CargaVentaPorSurtir(CveVenta As Integer)
Private Sub CargaVentaPorSurtir(CveVenta As Integer, Optional CveAlmacen As Integer = -1)
LbSurtida.Visible = False
CveContrato = -1
CveSubProyecto = -1
@@ -544,14 +553,14 @@ Partial Class Inventarios_EntregaAlmacen
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
DtDatos = ObjInventario.DtResultados
DtDatos.Columns.Add("Consec", GetType(Integer))
DtDatos.Columns.Add("CantidadGV", GetType(Double))
DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
DtDatos = ObjInventario.DtResultados
If Not DtDatos.Columns.Contains("Consec") Then DtDatos.Columns.Add("Consec", GetType(Integer))
If Not DtDatos.Columns.Contains("CantidadGV") Then DtDatos.Columns.Add("CantidadGV", GetType(Double))
If Not DtDatos.Columns.Contains("CantidadTraspaso") Then DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
Dim Index = 1
For Each Dr As DataRow In DtDatos.Rows
Dr("Consec") = Index
@@ -605,43 +614,45 @@ Partial Class Inventarios_EntregaAlmacen
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)
BtnGuardar.Visible = False
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
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString()))
Else
'[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
End If
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
DdlAlmacen.SelectedValue = "-1"
DdlAlmacen.DataBind()
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
If CveAlmacenTraspasoOrigen > 0 Then
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
End If
If Not DtDatos.Columns.Contains("Serie") Then
DtDatos.Columns.Add("Serie", GetType(String))
End If
If Not DtDatos.Columns.Contains("Lote") Then
DtDatos.Columns.Add("Lote", GetType(String))
End If
If Not DtDatos.Columns.Contains("CveSeccion") Then
DtDatos.Columns.Add("CveSeccion", GetType(Integer))
End If
If Not DtDatos.Columns.Contains("FechaCaducidad") Then
DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
End If
If Not DtDatos.Columns.Contains("Seleccionado") Then
DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
End If
If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then
DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
End If
End If
If CveAlmacen <= 0 Then
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
DdlAlmacen.Items.Clear()
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString()))
Else
'[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
End If
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
DdlAlmacen.SelectedValue = "-1"
DdlAlmacen.DataBind()
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
If CveAlmacenTraspasoOrigen > 0 Then
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
End If
End If
If UsuarioActual.CveEmpresa = 119 AndAlso CveSubProyecto = 10276 Then
ValidaLoteCaducidad = True
End If
If Not DtDatos.Columns.Contains("Serie") Then DtDatos.Columns.Add("Serie", GetType(String))
If Not DtDatos.Columns.Contains("Lote") Then DtDatos.Columns.Add("Lote", GetType(String))
If Not DtDatos.Columns.Contains("CveSeccion") Then DtDatos.Columns.Add("CveSeccion", GetType(Integer))
If Not DtDatos.Columns.Contains("FechaCaducidad") Then DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
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
FormaPaqueteria = DtDatos.Rows(0)("FormaPaqueteria").ToString().ToEntero()
Dim FormaPaq As Integer = FormaPaqueteria
@@ -692,7 +703,7 @@ Partial Class Inventarios_EntregaAlmacen
If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then
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()
DdlAlmacen.Items.Clear()
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}")
@@ -719,7 +730,7 @@ Partial Class Inventarios_EntregaAlmacen
ObjInventario.Dispose()
UpGenerales.Update()
CargaGvDatos()
If CveAlmacen <= 0 Then CargaGvDatos()
End Sub
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), "")
'SugerirFecha()
If DdlAlmacen.SelectedValue.ToEntero > 0 Then
SugiereLoteCaducidad(DdlAlmacen.SelectedValue.ToEntero)
If DdlAlmacen.SelectedValue.ToEntero > 0 And CveVentaSurtir > 0 Then
CargaVentaPorSurtir(CveVentaSurtir, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero)
' SugiereLoteCaducidad(DdlAlmacen.SelectedValue.ToEntero)
End If
End If
GvDatos.DataSource = DtDatos
@@ -943,21 +955,25 @@ Partial Class Inventarios_EntregaAlmacen
e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
End If
If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
e.Row.FCTextBox("TxtCaducidad").Visible = True
e.Row.FCLinkButton("LnkCaducidad").Visible = True
Else
e.Row.FCTextBox("TxtCaducidad").Visible = False
e.Row.FCLinkButton("LnkCaducidad").Visible = False
End If
If CBool(e.Row.DBCampo("AplicaLote")) Then
e.Row.FCTextBox("TxtLote").Visible = True
Else
e.Row.FCTextBox("TxtLote").Visible = False
End If
If (ValidaLoteCaducidad) OrElse (UsuarioActual.CveEmpresa <> 119) Then
If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
e.Row.FCTextBox("TxtCaducidad").Visible = True
e.Row.FCLinkButton("LnkCaducidad").Visible = True
e.Row.FCTextBox("TxtCaducidad").readonly = True
Else
e.Row.FCTextBox("TxtCaducidad").Visible = False
e.Row.FCLinkButton("LnkCaducidad").Visible = False
End If
If CBool(e.Row.DBCampo("AplicaLote")) Then
e.Row.FCTextBox("TxtLote").Visible = True
e.Row.FCTextBox("TxtLote").readonly = True
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").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))
@@ -1627,7 +1643,13 @@ Partial Class Inventarios_EntregaAlmacen
Exit For
End If
Next
Next
If (Not ValidaLoteCaducidad) OrElse (UsuarioActual.CveEmpresa <> 119) Then
ValidaSeccion = False
ValidaCaducidad = False
ValidaLote = False
End If
If ValidaSeccion Then
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)
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 CBool(Dr("AplicaSerie")) Then
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
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
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
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
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
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
Exit For