- sugiere la fecha de caducidad y lote

This commit is contained in:
rrene
2020-11-18 22:46:57 -07:00
parent 284844b3f4
commit 81bbd18766

View File

@@ -270,7 +270,7 @@ Partial Class Inventarios_EntregaAlmacen
InicializaValores() InicializaValores()
CargaParametrosAD() CargaParametrosAD()
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then DdlAlmacen.AutoPostBack = True If UsuarioActual.CveEmpresa.Contiene(72, 80, 146, 119) Then DdlAlmacen.AutoPostBack = True
If UsuarioActual.Empresa.Funcionalidad(281).ToEntero() = 1 Then If UsuarioActual.Empresa.Funcionalidad(281).ToEntero() = 1 Then
@@ -833,7 +833,7 @@ Partial Class Inventarios_EntregaAlmacen
CargaGvDatos() CargaGvDatos()
End Sub End Sub
Private Sub CargaGvDatos() Private Sub CargaGvDatos(Optional CveAlmacen As Integer = -1)
If DtDatos IsNot Nothing Then If DtDatos IsNot Nothing Then
@@ -849,9 +849,12 @@ Partial Class Inventarios_EntregaAlmacen
If AplicaSeccion Then GvDatos.Columns(7).Visible = True If AplicaSeccion Then GvDatos.Columns(7).Visible = True
If AplicaLote Then GvDatos.Columns(8).Visible = True If AplicaLote Then GvDatos.Columns(8).Visible = True
If AplicaCaducidad Then GvDatos.Columns(9).Visible = True If AplicaCaducidad Then GvDatos.Columns(9).Visible = True
GvDatos.Columns(9).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad") GvDatos.Columns(9).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) <> "", UsuarioActual.Empresa.Funcionalidad(147), "")
SugerirFecha() 'SugerirFecha()
If DdlAlmacen.SelectedValue.ToEntero > 0 Then
SugiereLoteCaducidad(DdlAlmacen.SelectedValue.ToEntero)
End If
End If End If
GvDatos.DataSource = DtDatos GvDatos.DataSource = DtDatos
@@ -3749,7 +3752,7 @@ Partial Class Inventarios_EntregaAlmacen
Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacen.SelectedIndexChanged Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacen.SelectedIndexChanged
If DdlAlmacen.SelectedValue <> "-1" Then If DdlAlmacen.SelectedValue <> "-1" Then
CargaGvDatos() CargaGvDatos(DdlAlmacen.SelectedValue.ToEntero)
End If End If
End Sub End Sub
@@ -3822,13 +3825,74 @@ Partial Class Inventarios_EntregaAlmacen
#Region "sugerir caducidad" #Region "sugerir caducidad"
Private Sub SugiereLoteCaducidad(CveAlmacen As Integer)
Dim TempDT As New DataTable
Dim DtLotesCaducidad As New DataTable
TempDT = DtDatos.Clone
Dim CvePSAnterior As Integer = 0
Dim ObjInventarios As New ClsInventarios()
For Each dr As DataRow In DtDatos.Rows
If CBool(dr("AplicaLote")) Then
If CvePSAnterior <> dr("CvePS").ToString.ToEntero Then
CvePSAnterior = dr("CvePS").ToString.ToEntero
If ObjInventarios.GetExistenciasCaducidad(dr("CvePS").ToString.ToEntero, CveAlmacen, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
DtLotesCaducidad.Merge(ObjInventarios.DtResultados)
End If
End If
End If
Next
ObjInventarios.Dispose()
For Each dr As DataRow In DtDatos.Rows
If CBool(dr("AplicaLote")) Then
Dim dtta As DataTable = DtLotesCaducidad.FiltraParametros(String.Format("CvePS = {0}", dr("CvePS")))
If dtta IsNot Nothing AndAlso dtta.Rows.Count > 0 Then
'recorre que cumplan con la cantidad total a llenar
Dim CantidadSurtir As Decimal = dr("CantidadF").ToString.ToDecimal
For Each drl As DataRow In dtta.Rows
If CantidadSurtir < drl("Cantidad").ToString.ToDecimal Then
dr("CantidadF") = CantidadSurtir
dr("CantidadC") = CantidadSurtir
dr("Lote") = drl("Lote")
dr("FechaCaducidad") = drl("FechaCaducidad")
TempDT.ImportRow(dr)
Else
CantidadSurtir -= drl("Cantidad").ToString.ToDecimal
dr("CantidadF") = drl("Cantidad").ToString.ToDecimal
dr("CantidadC") = drl("Cantidad").ToString.ToDecimal
dr("Lote") = drl("Lote")
dr("FechaCaducidad") = drl("FechaCaducidad")
TempDT.ImportRow(dr)
End If
Next
Else
'error, no hay lote sugerido
End If
Else
TempDT.ImportRow(dr)
End If
Next
DtDatos = TempDT
End Sub
Private Sub SugerirFecha() Private Sub SugerirFecha()
Dim ObjInventarios As New ClsInventarios() Dim ObjInventarios As New ClsInventarios()
Dim FechasExcluidas As New List(Of String) Dim FechasExcluidas As New List(Of String)
Dim TempDT As New DataTable Dim TempDT As New DataTable
TempDT = DtDatos.Clone TempDT = DtDatos.Copy
Dim DtAux As New DataTable Dim DtAux As New DataTable
DtAux = DtDatos.Clone DtAux = DtDatos.Clone