-cambios en validacion de uso de Secciones Almacen, Serie,Lote, Caducidad

This commit is contained in:
rrene
2020-05-13 12:34:06 -07:00
parent e80335be56
commit 552154d81d
25 changed files with 8255 additions and 5106 deletions

View File

@@ -128,22 +128,6 @@ Partial Class Inventarios_TraspasoAlmacen
End Set
End Property
Private Property DtSeccionAlmacen As DataTable
Get
Return CType(ViewState("DtSeccionAlmacen"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtSeccionAlmacen") = value
End Set
End Property
Private Property IndexSeccionAlmacen As Integer
Get
Return CType(ViewState("IndexSeccionAlmacen"), Integer)
End Get
Set(value As Integer)
ViewState("IndexSeccionAlmacen") = value
End Set
End Property
Private Property CantidadTotal As Decimal
Get
Return CType(ViewState("CantidadTotal"), Decimal)
@@ -227,10 +211,9 @@ Partial Class Inventarios_TraspasoAlmacen
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then DivEmitirTimbrado.Visible = True
CantidadTotal = 0
IndexSeccionAlmacen = 0
CvePS = 0
CreaDtSeccionAlmacen()
CargaDdlAlmacen()
TipoSeccionAlmacen = 0
Else
@@ -265,7 +248,7 @@ Partial Class Inventarios_TraspasoAlmacen
dt.Columns.Add("Observaciones")
dt.Columns.Add("SerieLote")
dt.Columns.Add("Lote")
dt.Columns.Add("Batch")
dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
'dt.Columns.Add("PU", Type.GetType("System.Double"))
'dt.Columns.Add("Total", Type.GetType("System.Double"))
@@ -532,7 +515,7 @@ Partial Class Inventarios_TraspasoAlmacen
End If
End If
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), If(TxtnBatch.Visible, TxtnBatch.Text, "-1"))
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, -1, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), MinFecha)
If Valido Then
AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, ""), If(TxtnLote.Visible, TxtnLote.Text, ""), If(TxtnBatch.Visible, TxtnBatch.Text, ""), FuncionalidadSinSerie)
@@ -540,11 +523,11 @@ Partial Class Inventarios_TraspasoAlmacen
End If
End Sub
Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Boolean
Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, CveSeccionAlmacen As Integer, SerieLote As String, Lote As String, Fechacaducidad As Date) As Boolean
Dim Retorno = True
Dim Inv As New ClsInventarios
Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch, PendientePorSurtir:=1)
Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=SerieLote, Lote:=Lote, FechaCaducidad:=Fechacaducidad, PendientePorSurtir:=1)
Inv.Dispose()
If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(SerieLote <> "-1", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then
@@ -560,7 +543,7 @@ Partial Class Inventarios_TraspasoAlmacen
Return Retorno
End Function
Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional SerieLote As String = "", Optional Lote As String = "", Optional Batch As String = "", Optional Limpia As Boolean = True)
Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional SerieLote As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True)
If Cantidad <= 0 Then
Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
@@ -583,7 +566,7 @@ Partial Class Inventarios_TraspasoAlmacen
registro.Item("Observaciones") = Observaciones
registro.Item("SerieLote") = SerieLote
registro.Item("Lote") = Lote
registro.Item("Batch") = Batch
registro.Item("FechaCaducidad") = FechaCaducidad
registro.Item("CveClasificacion") = CveClasificacion
registro.Item("CveAF") = -1
registro.Item("EstatusExistencia") = "1"
@@ -745,13 +728,6 @@ Partial Class Inventarios_TraspasoAlmacen
End If
Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad")
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero
Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero
@@ -796,20 +772,10 @@ Partial Class Inventarios_TraspasoAlmacen
Else
Dim Cont As Integer = 0
For Each Dr As DataRow In DtMovimientos.Rows
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For
Else
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
Exit For
End If
Next
End If
End If
Cont += 1
Next
@@ -861,20 +827,10 @@ Partial Class Inventarios_TraspasoAlmacen
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Dim Cont As Integer = 0
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
Exit For
Else
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
Exit For
End If
Next
End If
End If
Cont += 1
Next
@@ -1048,7 +1004,7 @@ Partial Class Inventarios_TraspasoAlmacen
Else
For Each Dr As DataRow In DtMovimientos.Rows
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For
@@ -1129,7 +1085,6 @@ Partial Class Inventarios_TraspasoAlmacen
TxtGastoIndirecto.Text = ""
TxtPlaca.Text = ""
TxtEspecifUnidad.Text = ""
DtSeccionAlmacen.Rows.Clear()
TxtResponsableCarga.Text = ""
TxtResponsableRecibio.Text = ""
TxtIdentificacion.Text = ""
@@ -1282,10 +1237,6 @@ Partial Class Inventarios_TraspasoAlmacen
e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad")))
End If
If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then
e.Row.FCLinkButton("lnkRemove").Visible = False
e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
End If
'If If(e.Row.DBCampo("SerieLote").ToString = "", "-1", e.Row.DBCampo("SerieLote").ToString) <> "-1" Then
' TxtnSerieLote.Visible = True
' ThSerieLote.Visible = True
@@ -1307,7 +1258,7 @@ Partial Class Inventarios_TraspasoAlmacen
' ThBatch.Visible = True
' TdBatch.Visible = True
' GvDatos.Columns(6).Visible = True
' e.Row.Cells(6).Text = e.Row.DBCampo("Batch").ToString
'Else
' e.Row.Cells(5).Text = ""
' e.Row.Cells(6).Text = ""
@@ -1415,7 +1366,6 @@ Partial Class Inventarios_TraspasoAlmacen
RegistraScript("$('#DivTransitorio').hide(500);$('#DivGastoIndirecto').hide(500);$('#DivDocChofer').hide(500);")
End If
UpModalSeccionAlmacen.Update()
SiguienteFolio(If(ChkTransitorio.Checked, 9, 8))
End Sub
Protected Sub BtnCargaTransitorios_Click(sender As Object, e As EventArgs)
@@ -1449,8 +1399,6 @@ Partial Class Inventarios_TraspasoAlmacen
'Dt.Dispose()
End If
DtSeccionAlmacen.Rows.Clear()
If TxtFolioRecepcion.Text = "" Then
BtnRecibir.Visible = False
BtnCancelarTraspaso.Visible = False
@@ -1567,7 +1515,7 @@ Partial Class Inventarios_TraspasoAlmacen
Exit For
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, GvRow.DataKey("CveAF").ToEntero, -1, GvRow.DataKey("SerieLote").ToString, Lote:=GvRow.DataKey("Lote"), Batch:=GvRow.DataKey("Batch"), CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, GvRow.DataKey("CveAF").ToEntero, -1, SerieLote:=GvRow.DataKey("SerieLote").ToString, Lote:=GvRow.DataKey("Lote"), FechaCaducidad:=GvRow.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
Exit For
@@ -1577,28 +1525,6 @@ Partial Class Inventarios_TraspasoAlmacen
End If
Next
'If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
' For Each Dr As DataRow In ObjInventario.DtResultados.Rows
' CveMovimientoDetalleSalida = Dr("CveMovimientoDetalle").ToString.ToEntero
' Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble
' Dim PrecioUnitario As Double = Dr("PU").ToString.ToDouble
' If CveMovimientoDetalleSalida <= 0 Then
' ErrorMovInv = True
' TextoError = "Ocurrió un error al guardar los movimientos de salida"
' Exit For
' End If
' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PrecioUnitario, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then
' ErrorMovInv = True
' TextoError = "Ocurrió un error al guardar los movimientos de entrada"
' Exit For
' End If
' importe += Cantidad * PrecioUnitario
' Next
'Else
' ErrorMovInv = True
' TextoError = "Ocurrió un error al obtener los movimientos de salida"
'End If
'VIRTUAL ENTRADA
@@ -1708,12 +1634,6 @@ Partial Class Inventarios_TraspasoAlmacen
Exit Sub
End If
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
If ValidaMovtos <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Dim ObjInventario As New ClsInventarios
Dim Dtt As DataTable = Nothing
@@ -1772,20 +1692,10 @@ Partial Class Inventarios_TraspasoAlmacen
Exit For
End If
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("PU").ToString.ToDecimal, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, SerieLote:=gvr.DataKey("SerieLote").ToString, Lote:=gvr.DataKey("Lote").ToString, Batch:=gvr.DataKey("Batch").ToString) Then
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("PU").ToString.ToDecimal, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, SerieLote:=gvr.DataKey("SerieLote").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For
Else
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
Exit For
End If
Next
End If
End If
ElseIf cantidadDisponibleValidacion < 0 Then
TextoError = String.Format("Se exceden la cantidad disponibles para {0}", gvr.DataKey("PS").ToString)
@@ -2017,7 +1927,7 @@ Partial Class Inventarios_TraspasoAlmacen
txtCantidad.Text = "1"
Dim Valido = ValidaExistencia(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim)
Dim Valido = ValidaExistencia(1, CvePSSerieLote, CveUMSerieLote, -1, TxtSeriePS.Text.Trim, "-1", MinFecha)
If Valido Then
AgregarPS(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim)
@@ -2546,211 +2456,6 @@ Partial Class Inventarios_TraspasoAlmacen
End Try
End Sub
#End Region
#Region "SECCION ALMACEN"
Private Sub CreaDtSeccionAlmacen()
DtSeccionAlmacen = New DataTable
DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal))
DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer))
DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer))
DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer))
DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer))
DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String))
DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String))
DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer))
End Sub
Private Sub CargaDdlAlmacen()
DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlSeccionAlmacenOrigen.DataBind()
DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlSeccionAlmacenDestino.DataBind()
End Sub
Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
If Not DdlAlmacenOrigen.SelectedValue.ToEntero > 0 Then
Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen origen.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then
' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
If ChkTransitorio.Checked Then
GvSeccion.Columns(2).Visible = False
DivSeccionAlmacenDestino.Visible = False
Else
GvSeccion.Columns(2).Visible = True
DivSeccionAlmacenDestino.Visible = True
End If
DivSeccionAlmacenOrigen.Visible = True
GvSeccion.Columns(1).Visible = True
CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal
IndexSeccionAlmacen = gvRow.RowIndex
CvePS = gvRow.DataKey("CvePS").ToEntero
TipoSeccionAlmacen = 1
CargaSeccionAlmacen()
RegistraScript("$('#DModalSeccionAlmacen').modal()")
End Sub
Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
If Not DdlAlmacenRecepcion.SelectedValue.ToEntero > 0 Then
Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
DivSeccionAlmacenOrigen.Visible = False
DivSeccionAlmacenDestino.Visible = True
GvSeccion.Columns(1).Visible = False
GvSeccion.Columns(2).Visible = True
CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal
IndexSeccionAlmacen = gvRow.RowIndex
CvePS = gvRow.DataKey("CvePS").ToEntero
TipoSeccionAlmacen = 2
CargaSeccionAlmacen()
RegistraScript("$('#DModalSeccionAlmacen').modal()")
End Sub
Private Sub CargaSeccionAlmacen()
Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}")
GvSeccion.DataBind()
TxtCantidadSeccion.Text = ""
DdlSeccionAlmacenOrigen.SelectedIndex = 0
DdlSeccionAlmacenDestino.SelectedIndex = 0
Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion
If CantidadRestante = 0 Then
RVTxtCantidad.MaximumValue = "1"
TxtCantidadSeccion.Enabled = False
Else
RVTxtCantidad.MaximumValue = CantidadRestante.ToString
TxtCantidadSeccion.Enabled = True
End If
If TipoSeccionAlmacen = 1 Then
If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
DdlAlmacenOrigen.Enabled = False
DdlAlmacenOrigen.ToolTip = "Cuenta con sección almacen"
ChkTransitorio.Enabled = False
ChkTransitorio.ToolTip = "Cuenta con sección almacen"
GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = False
GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
Else
DdlAlmacenOrigen.Enabled = True
DdlAlmacenOrigen.ToolTip = ""
ChkTransitorio.Enabled = True
ChkTransitorio.ToolTip = ""
GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = True
GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = ""
End If
UpDatos.Update()
ElseIf TipoSeccionAlmacen = 2 Then
If CantidadTotalSeccion > 0 Then
GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False
GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen"
Else
GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True
GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = ""
End If
UpDatosRecepcion.Update()
End If
UpModalSeccionAlmacen.Update()
End Sub
Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
If TipoSeccionAlmacen = 1 Then
Dim ObjInv As New ClsInventarios
Dim CantidadDisponible As Decimal = 0
If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenOrigen.SelectedValue.ToEntero,
CvePS, UsuarioActual.CveEmpresa) Then
If ObjInv.DtResultados.Rows.Count > 0 Then
CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal
End If
End If
ObjInv.Dispose()
CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.SelectedValue}").SUMD("CantidadSeccionAlmacen")
If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then
Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: <b>{CantidadDisponible}</b>", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Dim Row As DataRow = Nothing
DtSeccionAlmacen.AcceptChanges()
Row = DtSeccionAlmacen.NewRow
Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal
Row("IndexSeccionAlmacen") = IndexSeccionAlmacen
Row("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero
Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text
Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero
Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text
Row("CvePS") = CvePS
Row("Consec") = DtSeccionAlmacen.Rows.Count + 1
Row("TipoSeccionAlmacen") = TipoSeccionAlmacen
DtSeccionAlmacen.Rows.Add(Row)
DtSeccionAlmacen.AcceptChanges()
CargaSeccionAlmacen()
End Sub
Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
Dim Index As Integer = 0
For Each Dr As DataRow In DtSeccionAlmacen.Rows
If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then
Exit For
End If
Index += 1
Next
DtSeccionAlmacen.Rows.RemoveAt(Index)
DtSeccionAlmacen.AcceptChanges()
CargaSeccionAlmacen()
End Sub
'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
' If Not CveVentaSurtir > 0 Then
' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' Dim ObjInv As New ClsInventarios
' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
' End If
' ObjInv.Dispose()
' GvVerSeccionesAlmacen.DataBind()
' UpVerSeccionesAlmacen.Update()
' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
'End Sub
#End Region
Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs)
@@ -2867,6 +2572,8 @@ Partial Class Inventarios_TraspasoAlmacen
Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal()
Dim SerieLote As String = RowExcel("SerieLote").ToString()
Dim Observaciones As String = RowExcel("Observaciones").ToString()
Dim FechaCaducidad As Date = MinFecha
Dim Lote As String = "-1"
If CveProducto > 0 Then
@@ -2892,7 +2599,7 @@ Partial Class Inventarios_TraspasoAlmacen
End If
If Valido Then
Valido = ValidaExistencia(Cantidad, CveProducto, CveUnidadMedida, If(Not String.IsNullOrEmpty(SerieLote), SerieLote, "-1"), "-1", "-1")
Valido = ValidaExistencia(Cantidad, CveProducto, CveUnidadMedida, -1, If(Not String.IsNullOrEmpty(SerieLote), SerieLote, "-1"), Lote, FechaCaducidad)
End If
If Valido Then