si el lote que limite sino es *c, y mensaje de advertencia

This commit is contained in:
2021-07-17 10:46:19 -07:00
parent 53504a7585
commit 3ce17e35de

View File

@@ -537,13 +537,19 @@ Partial Class Inventarios_TraspasoAlmacen
End If
'codigo provisional.
Dim CveSubP As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.selectedvalue.toentero).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
Dim CveSubP As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
If DrPS("AplicaCaducidad").ToString = "True" AndAlso CveSubP.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then
If Not ChkSugiereFechaCaducidad.Checked AndAlso (TxtnFechaCaducidad.Text = "" OrElse TxtnLote.Text = "") Then
Alert("Falta Especificar lote/Fecha del producto", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If DrPS("AplicaCaducidad").ToString = "True" AndAlso ChkSugiereFechaCaducidad.checked And CveSubP.Contiene(10276) Then
If DrPS("AplicaCaducidad").ToString = "True" AndAlso ChkSugiereFechaCaducidad.Checked And CveSubP.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then
Dim ObjInventarios As New ClsInventarios
If ObjInventarios.GetExistenciasCaducidad(CveProducto, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.selectedvalue) Then
If ObjInventarios.GetExistenciasCaducidad(CveProducto, DdlAlmacenOrigen.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue) Then
Dim dtt As DataTable = ObjInventarios.DtResultados
If Cantidad > dtt.SUMD("Cantidad") Then
@@ -577,22 +583,20 @@ Partial Class Inventarios_TraspasoAlmacen
tLote = If(TxtnLote.Visible, TxtnLote.Text, "-1")
tCaducidad = If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha)
If CveSubP <> 10276 Then
If Not CveSubP.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then
tLote = "-1"
tCaducidad = MinFecha
End If
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, If(TxtnSerie.Visible, TxtnSerie.Text, "-1"), tLote, tCaducidad)
If Valido Then
If Valido Then
AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(tLote = "-1", "", tLote), FechaCaducidad:=tCaducidad, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
End If
End If
End If
End If
End If
End Sub
@@ -601,21 +605,29 @@ Partial Class Inventarios_TraspasoAlmacen
Dim ExistenciaEspecificada As Decimal
Dim CantidadEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(Serie <> "-1", $" AND Serie = '{Serie}'", "")}")
Dim Existencia As Decimal
Dim Inv As New ClsInventarios
Dim Existencia As Decimal = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), PendientePorSurtir:=1)
If Inv.GetExistenciasProducto(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) Then
'si hay existencia en almacen costeado, lo tengo que sacar
Existencia = Inv.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CVeAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
End If
'Existencia= Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), PendientePorSurtir:=1)
If Existencia > 0 Then
'la primera vez valida, que la existencia global, cumpla, considerando lo pendiente por surtir
'las segunda consulta, que tenga existencia, ya con los parametros especificos
If (FechaCaducidad > MinFecha OrElse Not Serie.Contiene("", "-1") OrElse Not Lote.Contiene("", "-1")) Then
ExistenciaEspecificada = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
Dim StrB As New stringbuilder
StrB.appendformat("CvePS = {0} AND CveUM = {1} ", CvePS, CveUnidadMedida)
If Not Serie.Contiene("", "-1") Then StrB.appendformat(" AND Serie = '{0}' ", Serie)
If Not Lote.Contiene("", "-1") Then StrB.appendformat(" AND Lote = '{0}' ", Lote)
If FechaCaducidad.ToDate > MinFecha Then StrB.appendformat(" AND FechaCaducidad = '{0}' ", FechaCaducidad.ToShortDateString)
Dim CantidadEspecificaEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", StrB.tostring)
If Inv.GetExistenciasProducto(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
ExistenciaEspecificada = Inv.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CVeAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
End If
'ExistenciaEspecificada = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
Dim StrB As New StringBuilder
StrB.AppendFormat("CvePS = {0} AND CveUM = {1} ", CvePS, CveUnidadMedida)
If Not Serie.Contiene("", "-1") Then StrB.AppendFormat(" AND Serie = '{0}' ", Serie)
If Not Lote.Contiene("", "-1") Then StrB.AppendFormat(" AND Lote = '{0}' ", Lote)
If FechaCaducidad.ToDate > MinFecha Then StrB.AppendFormat(" AND FechaCaducidad = '{0}' ", FechaCaducidad.ToShortDateString)
Dim CantidadEspecificaEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", StrB.ToString)
If ExistenciaEspecificada - Cantidad - CantidadEspecificaEnGrid < 0 Then
Alert(String.Format("Solo hay en existencia: {0:#,###.##}", ExistenciaEspecificada), TipoMensaje.MsgAdvertencia)
@@ -837,13 +849,22 @@ Partial Class Inventarios_TraspasoAlmacen
Dim ExistenciaEspecificada As Decimal = 0
CantidadenGrid = DtMovimientos.SUMD("Cantidad", String.Format("CvePS = {0} AND CveUM = {1} {2} {3} {4} ", dr("CvePS"), dr("CveUM"), If(Not dr("Serie").ToString.Contiene("-1", ""), $" AND Serie = '{dr("Serie")}'", ""), tLote, tFechaCaducidad))
Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=1)
If ObjInventario.GetExistenciasProducto(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
'si hay existencia en almacen costeado, lo tengo que sacar
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CVeAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
End If
'Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=1)
Existencia -= CantidadenGrid
'DtMovimientos.SUM("Cantidad", String.Format("CvePS = {0}", dr("CvePS").ToString.ToEntero))
'la primera vez valida, que la existencia global, cumpla, considerando lo pendiente por surtir
'las segunda consulta, que tenga existencia, ya con los parametros especificos
If FechaCaducidad > MinFecha OrElse (Lote <> "-1" AndAlso Lote <> "") Then
ExistenciaEspecificada = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
If ObjInventario.GetExistenciasProducto(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
ExistenciaEspecificada = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CVeAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
End If
'ExistenciaEspecificada = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
Existencia = ExistenciaEspecificada - CantidadenGrid
End If
@@ -865,7 +886,11 @@ Partial Class Inventarios_TraspasoAlmacen
Lote = If(gvr.DataKey("Lote") = "", "-1", gvr.DataKey("Lote"))
FechaCaducidad = If(gvr.DataKey("FechaCaducidad") = "", MinFecha, gvr.DataKey("FechaCaducidad").ToDate)
Existencia = ObjInventario.GetExistenciasPS(gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=1)
If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
'si hay existencia en almacen costeado, lo tengo que sacar
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CVeAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
End If
'Existencia = ObjInventario.GetExistenciasPS(gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=1)
Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero
If Existencia < 0 Then
ErrorExistencia = True
@@ -1551,8 +1576,8 @@ Partial Class Inventarios_TraspasoAlmacen
Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs)
TxtnFechaCaducidad.visible = Not ChkSugiereFechaCaducidad.checked
TxtnLote.visible = Not ChkSugiereFechaCaducidad.checked
TxtnFechaCaducidad.Visible = Not ChkSugiereFechaCaducidad.Checked
TxtnLote.Visible = Not ChkSugiereFechaCaducidad.Checked
End Sub
@@ -1685,11 +1710,11 @@ Partial Class Inventarios_TraspasoAlmacen
End If
If e.Row.DBCampo("AplicaLote").ToString.Trim = "1" Then
e.Row.FCTextBox("TxtLote").visible = True
e.Row.FCTextBox("TxtLote").Visible = True
End If
If e.Row.DBCampo("AplicaCaducidad").ToString.Trim = "1" Then
e.Row.FCTextBox("TxtCaducidad").visible = True
e.Row.FCTextBox("TxtCaducidad").Visible = True
End If
End If
@@ -1702,10 +1727,10 @@ Partial Class Inventarios_TraspasoAlmacen
'FUNCIONALIDAD PISTOLA DE CODIGOS
If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
e.Row.FCTextBox("TxtCantidad").Enabled = False
End If
e.Row.FCTextBox("TxtCantidad").Enabled = False
End If
End If
End Sub
Protected Sub BtnCancelarTraspaso_Click(sender As Object, e As EventArgs)
@@ -1987,9 +2012,9 @@ Partial Class Inventarios_TraspasoAlmacen
Dim tLote As String = gvr.DataKey("Lote").ToString
Dim tFechaCaducidad As Date = gvr.DataKey("FechaCaducidad").ToDate
If CveSubProyectoRecibe = 10276 Then
tLote = gvr.FCTextBox("TxtLote").text
tFechaCaducidad = gvr.FCTextBox("TxtCaducidad").text.todate
If CveSubProyectoRecibe.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then
tLote = gvr.FCTextBox("TxtLote").Text
tFechaCaducidad = gvr.FCTextBox("TxtCaducidad").Text.ToDate
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=tLote, FechaCaducidad:=tFechaCaducidad, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
@@ -2972,7 +2997,7 @@ Partial Class Inventarios_TraspasoAlmacen
Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
Dim excelFile As ExcelFile = excelFile.Load(flatFilePath)
Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath)
Dim unnamed As Integer = 0
Dim cols As Integer