-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

@@ -176,8 +176,6 @@ Partial Class Inventarios_ResguardoMaterial
CantidadTotal = 0
IndexSeccionAlmacen = 0
CvePS = 0
CreaDtSeccionAlmacen()
CargaDdlAlmacen()
TipoSeccionAlmacen = 0
End Sub
@@ -783,16 +781,6 @@ Partial Class Inventarios_ResguardoMaterial
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
TieneError = True
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
TieneError = True
MensajeError = "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
@@ -812,16 +800,7 @@ Partial Class Inventarios_ResguardoMaterial
TieneError = True
MensajeError = "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
TieneError = True
MensajeError = "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
@@ -849,16 +828,7 @@ Partial Class Inventarios_ResguardoMaterial
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
TieneError = True
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("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
TieneError = True
MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
Exit For
End If
Next
End If
End If
End If
Cont += 1
@@ -880,16 +850,7 @@ Partial Class Inventarios_ResguardoMaterial
TieneError = True
MensajeError = "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 = 2").Rows
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
TieneError = True
MensajeError = "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
@@ -1010,206 +971,6 @@ Partial Class Inventarios_ResguardoMaterial
UpFiltraLiberacion.Update()
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 DdlAlmacen.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
GvSeccion.Columns(2).Visible = True
DivSeccionAlmacenDestino.Visible = True
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 DdlAlmacenLiberacion.SelectedValue.ToEntero > 0 Then
Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
DivSeccionAlmacenOrigen.Visible = True
DivSeccionAlmacenDestino.Visible = True
GvSeccion.Columns(1).Visible = True
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 CantidadTotalSeccion > 0 Then
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
Else
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = ""
End If
If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
DdlAlmacen.Enabled = False
DdlAlmacen.ToolTip = "Cuenta con sección almacen"
Else
DdlAlmacen.Enabled = True
DdlAlmacen.ToolTip = ""
End If
UpGenerales.Update()
ElseIf TipoSeccionAlmacen = 2 Then
If CantidadTotalSeccion > 0 Then
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen"
Else
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = ""
End If
If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
DdlAlmacenLiberacion.Enabled = False
DdlAlmacenLiberacion.ToolTip = "Cuenta con sección almacen"
Else
DdlAlmacenLiberacion.Enabled = True
DdlAlmacenLiberacion.ToolTip = ""
End If
UpGridLiberacion.Update()
UpFiltraLiberacion.Update()
End If
UpModalSeccionAlmacen.Update()
End Sub
Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
Dim ObjInv As New ClsInventarios
Dim CantidadDisponible As Decimal = 0
If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, If(TipoSeccionAlmacen = 1, DdlAlmacen.SelectedValue.ToEntero, DdlAlmacenLiberacion.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} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").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
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
Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click