diff --git a/Inventarios/PaquetesArmadoDesarmado.aspx b/Inventarios/PaquetesArmadoDesarmado.aspx index d3859b2fd..9012804bb 100644 --- a/Inventarios/PaquetesArmadoDesarmado.aspx +++ b/Inventarios/PaquetesArmadoDesarmado.aspx @@ -116,43 +116,12 @@
| Paquete: | -
- |
-
| Cantidad: | -
- |
-
|
- - |
- |
| Almacén: | -
- |
-
| Fecha: | -
- |
-
| Observaciones: | -
- |
-
| Observaciones: | +
+ |
+
| Paquete: | -
- |
-
| Cantidad: | -
- |
-
|
- - |
- |
| Almacén: | -
- |
-
| Fecha: | -
- |
-
| Observaciones: |
diff --git a/Inventarios/PaquetesArmadoDesarmado.aspx.vb b/Inventarios/PaquetesArmadoDesarmado.aspx.vb
index ab0db1e2a..58b60df16 100644
--- a/Inventarios/PaquetesArmadoDesarmado.aspx.vb
+++ b/Inventarios/PaquetesArmadoDesarmado.aspx.vb
@@ -268,12 +268,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
End If
UpSeriesPaqueteArmado.Update()
- LbPaqueteArmado.Text = DdlPaqueteArmado.SelectedItem.Text
CvePaqueteArmado = DdlPaqueteArmado.SelectedValue.ToEntero
- LbCantidadArmado.Text = TxtCantidadArmado.Text
- 'LbAlmacenArmado.Text = DdlAlmacenArmado.SelectedItem.Text
CveAlmacenArmado = DdlAlmacenArmado.SelectedValue.ToEntero
- 'LbFechaArmado.Text = TxtFechaArmado.Text
GvDatosArmado.DataSource = DtDatos
GvDatosArmado.DataBind()
@@ -364,12 +360,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
End If
UpSeriesPaqueteDesarmado.Update()
- LbPaqueteDesarmado.Text = DdlPaqueteDesarmado.SelectedItem.Text
CvePaqueteDesarmado = DdlPaqueteDesarmado.SelectedValue.ToEntero
- LbCantidadDesarmado.Text = TxtCantidadDesarmado.Text
- LbAlmacenDesarmado.Text = DdlAlmacenDesarmado.SelectedItem.Text
CveAlmacenDesarmado = DdlAlmacenDesarmado.SelectedValue.ToEntero
- LbFechaDesarmado.Text = TxtFechaDesarmado.Text
GvDatosDesarmado.DataSource = DtDatos
GvDatosDesarmado.DataBind()
@@ -449,7 +441,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
End If
Next
Case 2 ' DESARMADO
- If LbCantidadDesarmado.Text.ToEntero <> DtSeriesDesarmado.Rows.Count Then
+ If TxtCantidadDesarmado.Text.ToEntero <> DtSeriesDesarmado.Rows.Count Then
Alert("Es necesario indicar las series del paquete a desarmar.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -467,224 +459,32 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
Dim FolioSalida As Integer = 0
Dim CveMovimientoEntrada As Integer = 0
Dim FolioEntrada As Integer = 0
- Dim Fecha As Date = If(Tipo = 1, TxtFechaArmado.Text.ToDate, LbFechaDesarmado.Text.ToDate)
+ Dim Fecha As Date = If(Tipo = 1, TxtFechaArmado.Text.ToDate, TxtFechaDesarmado.Text.ToDate)
Dim DtDetalle As New DataTable
Dim ConcepPrePoliza1 = "ARMPAQ1"
Dim ConcepPrePoliza2 = "ARMPAQ2"
-
- Dim Concepto As String = "ARMPAQ2"
Dim Modulo As String = "ARMPAQ1/ARMPAQ2"
+
Try
+ Select Case (Tipo)
+ Case 1 ' ARMADO
- Catch ex As Exception
+ 'SALIDA COMPONENTES
+ CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenArmado, 5, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ1")
+ FolioSalida = ObjInventario.Folio
- End Try
- Select Case (Tipo)
- Case 1 ' ARMADO
-
- 'SALIDA COMPONENTES
- CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenArmado, 5, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ1")
- FolioSalida = ObjInventario.Folio
-
- If CveMovimientoSalida <= 0 Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
- Exit Select
- End If
-
- For Each Gvr As GridViewRow In GvDatosArmado.Rows
- If Gvr.DataKey("Cantidad").ToString.ToDouble > 0 Then
- Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text)
- Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text)
- Dim CveSeccionAlmacen As Integer = Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero()
- If CBool(Gvr.DataKey("AplicaSerie")) Then
- For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
- If Not ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=Fecha.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr("Serie").ToString, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) >= 1 Then
- MensajeError = String.Format("El Producto {0} con Serie: {1} no tiene existencia suficiente", Dr("PS"), Dr("Serie"))
- TieneError = True
- Exit For
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1,
- CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
- MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida. Por favor vuelva a intentar."
- TieneError = True
- Exit For
- End If
- Next
-
- If TieneError Then
- Exit For
- End If
-
- Else
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
- Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
- FechaCaducidad:=FechaCaducidad.ToDate) Then
- MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
- TieneError = True
- Exit For
- End If
- End If
- End If
- Next
-
- 'ENTRADA PAQUETE
- If Not TieneError Then
- CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenArmado, 19, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ2")
- FolioEntrada = ObjInventario.Folio
-
- If CveMovimientoEntrada <= 0 Then
- MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
- TieneError = True
- Else
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
- Dim PUTemp As Decimal = 0
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- PUTemp += Dr("PU").ToString.ToDecimal * Dr("Cantidad").ToString.ToDecimal
- Next
- PUTemp = PUTemp / LbCantidadArmado.Text.ToDecimal
- Dim CvePSTemp = CvePaqueteArmado
- Dim CveSeccionAlmacen As Integer = -1
- Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimero("")
-
- Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
- Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
- If AplicaSeccion Then
- CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenArmado, CvePaqueteArmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
- End If
-
-
- If AplicaSerie Then
- Dim ContadorPaquete = 1
- Dim DtSeriesComponentes As New DataTable
- For Each Gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
- 'AGREGA MOVTO DETALLE DE LA ENTRADA DEL PAQUETE
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Gvr.FCTextBox("TxtSerie").Text.Trim) Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada"
- Exit For
- End If
-
- 'INGRESA EN TABLA DE CONTROL DE PAQUETES CON SERIE
- For Each Gvr2 As GridViewRow In GvDatosArmado.Rows
- If CBool(Gvr2.DataKey("AplicaSerie")) Then
- DtSeriesComponentes = New DataTable
- DtSeriesComponentes = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Copy
- Dim CantidadComponente = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Rows.Count / LbCantidadArmado.Text.ToEntero
-
- For index As Integer = (ContadorPaquete - 1) * CantidadComponente.ToEntero To (ContadorPaquete * CantidadComponente.ToEntero) - 1
- If Not ObjInventario.AddPaqueteRelacionSeries(CvePSTemp, Gvr.FCTextBox("TxtSerie").Text.Trim, DtSeriesComponentes.Rows(index)("CvePS").ToString.ToEntero, DtSeriesComponentes.Rows(index)("Serie").ToString) Then
- TieneError = True
- Exit For
- End If
- Next
- End If
- Next
-
- ContadorPaquete = ContadorPaquete + 1
- Next
- Else
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, LbCantidadArmado.Text.ToDecimal, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen) Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los detalles del movimiento de entrada"
- End If
- End If
-
- Else
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los movimientos de entrada"
- End If
- End If
- End If
+ If CveMovimientoSalida <= 0 Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
+ Exit Select
+ End If
-
-
- Case 2 'DESARMADO
-
-
- 'SALIDA PAQUETE
- CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 20, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ3")
- FolioSalida = ObjInventario.Folio
-
- If CveMovimientoSalida <= 0 Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
- Exit Select
- End If
-
- Dim CvePSTemp As Integer = CvePaqueteDesarmado
- Dim CveSeccionAlmacen As Integer = -1
- Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimero("")
-
- Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
- 'Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
- 'If AplicaSeccion Then
- ' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
- 'End If
- If AplicaSerie Then
- For Each Gvr As GridViewRow In GvSeriesPaqueteDesarmado.Rows
- 'AGREGA MOVTO DETALLE DE LA SALIDA DEL PAQUETE
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=-3, Serie:=Gvr.DataKey("Serie").ToString) Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
- Exit For
- End If
-
- 'ELIMINA EN TABLA DE CONTROL DE PAQUETES CON SERIE
- If Not ObjInventario.RemovePaqueteRelacionSeries(CvePSTemp, Gvr.DataKey("Serie").ToString) Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
- Exit For
- End If
- Next
- Else
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, TxtCantidadDesarmado.Text.ToDecimal, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=CveSeccionAlmacen) Then
- TieneError = True
- MensajeError = "Ocurrió un error al guardar los movimientos de salida"
- End If
- End If
-
-
- 'ENTRADA COMPONENTES
- If Not TieneError Then
- CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 4, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ4")
- FolioEntrada = ObjInventario.Folio
-
- If CveMovimientoEntrada <= 0 Then
- MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
- TieneError = True
- Else
- For Each Gvr As GridViewRow In GvDatosDesarmado.Rows
- 'If Gvr.DataKey("Cantidad").ToString.ToDouble > 0 Then
- ' If CBool(Gvr.DataKey("AplicaSeccion")) Then
- ' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
- ' End If
-
- ' If CBool(Gvr.DataKey("AplicaSerie")) Then
- ' For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
- ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString) Then
- ' MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada. Por favor vuelva a intentar."
- ' TieneError = True
- ' Exit For
- ' End If
- ' Next
- ' Else
- ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, CveSeccionAlmacen:=CveSeccionAlmacen) Then
- ' MensajeError = "Ocurrió un error al guardar los detalles del movimiento de entrada. Por favor vuelva a intentar."
- ' TieneError = True
- ' Exit For
- ' End If
- ' End If
- 'End If
-
+ For Each Gvr As GridViewRow In GvDatosArmado.Rows
+ If Gvr.DataKey("Cantidad").ToString.ToDouble > 0 Then
Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text)
Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text)
- If CBool(Gvr.DataKey("AplicaSeccion")) Then
- CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
- End If
-
+ Dim CveSeccionAlmacen As Integer = Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero()
If CBool(Gvr.DataKey("AplicaSerie")) Then
For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
If Not ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=Fecha.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr("Serie").ToString, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) >= 1 Then
@@ -693,8 +493,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
Exit For
End If
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1,
- CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1,
+ CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida. Por favor vuelva a intentar."
TieneError = True
Exit For
@@ -706,61 +506,229 @@ Partial Class Inventarios_PaquetesArmadoDesarmado
End If
Else
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
- Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
- FechaCaducidad:=FechaCaducidad.ToDate) Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
+ Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
+ FechaCaducidad:=FechaCaducidad.ToDate) Then
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
TieneError = True
Exit For
End If
- End If
- Next
- End If
- End If
-
- ConcepPrePoliza1 = "ARMPAQ3"
- ConcepPrePoliza1 = "ARMPAQ4"
-
- End Select
+ End If
+ End If
+ Next
- 'CONTABILIZAR MOVIMIENTOS
- If Not TieneError Then
- Dim ImportePrePoliza As Decimal = 0D
+ 'ENTRADA PAQUETE
+ If Not TieneError Then
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenArmado, 19, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ2")
+ FolioEntrada = ObjInventario.Folio
- If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
- ImportePrePoliza = ObjInventario.DtResultados.SUMD("Total")
- End If
+ If CveMovimientoEntrada <= 0 Then
+ MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
+ TieneError = True
+ Else
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ Dim PUTemp As Decimal = 0
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ PUTemp += Dr("PU").ToString.ToDecimal * Dr("Cantidad").ToString.ToDecimal
+ Next
+ PUTemp = PUTemp / TxtCantidadArmado.Text.ToDecimal
+ Dim CvePSTemp = CvePaqueteArmado
+ Dim CveSeccionAlmacen As Integer = -1
+ Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimero("")
+
+ Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
+ Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
+ If AplicaSeccion Then
+ CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenArmado, CvePaqueteArmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
+ End If
- Dim MovAlmacen As Boolean = True
+ If AplicaSerie Then
+ Dim ContadorPaquete = 1
+ Dim DtSeriesComponentes As New DataTable
+ For Each Gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
+ 'AGREGA MOVTO DETALLE DE LA ENTRADA DEL PAQUETE
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Gvr.FCTextBox("TxtSerie").Text.Trim) Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada"
+ Exit For
+ End If
- Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 19).ToEntero
+ 'INGRESA EN TABLA DE CONTROL DE PAQUETES CON SERIE
+ For Each Gvr2 As GridViewRow In GvDatosArmado.Rows
+ If CBool(Gvr2.DataKey("AplicaSerie")) Then
+ DtSeriesComponentes = New DataTable
+ DtSeriesComponentes = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Copy
+ Dim CantidadComponente = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Rows.Count / TxtCantidadArmado.Text.ToEntero
- If OrigenMov = 1 Then
- MovAlmacen = True
- Else
- MovAlmacen = False
- End If
+ For index As Integer = (ContadorPaquete - 1) * CantidadComponente.ToEntero To (ContadorPaquete * CantidadComponente.ToEntero) - 1
+ If Not ObjInventario.AddPaqueteRelacionSeries(CvePSTemp, Gvr.FCTextBox("TxtSerie").Text.Trim, DtSeriesComponentes.Rows(index)("CvePS").ToString.ToEntero, DtSeriesComponentes.Rows(index)("Serie").ToString) Then
+ TieneError = True
+ Exit For
+ End If
+ Next
+ End If
+ Next
- Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(Modulo, 74, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- 'Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}").ToEntero
+ ContadorPaquete = ContadorPaquete + 1
+ Next
+ Else
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, TxtCantidadArmado.Text.ToDecimal, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen) Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los detalles del movimiento de entrada"
+ End If
+ End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza2, ConcepPrePoliza2, CveMovimientoAlmacen:=CveMovimientoEntrada, CveSubProyecto:=-1, Contabilizable:=True) Then
- TieneError = True
- End If
+ Else
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los movimientos de entrada"
+ End If
+ End If
+ End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza1, ConcepPrePoliza1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=True) Then
- TieneError = True
- End If
- If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=6) Then
- If ObjConta.ValorPolizaDescuadre > 0 Then
- GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+
+ Case 2 'DESARMADO
+
+
+ 'SALIDA PAQUETE
+ CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 20, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ3")
+ FolioSalida = ObjInventario.Folio
+
+ If CveMovimientoSalida <= 0 Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
+ Exit Select
+ End If
+
+ Dim CvePSTemp As Integer = CvePaqueteDesarmado
+ Dim CveSeccionAlmacen As Integer = -1
+ Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimero("")
+
+ Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
+ 'Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
+ 'If AplicaSeccion Then
+ ' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
+ 'End If
+ If AplicaSerie Then
+ For Each Gvr As GridViewRow In GvSeriesPaqueteDesarmado.Rows
+ 'AGREGA MOVTO DETALLE DE LA SALIDA DEL PAQUETE
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=-3, Serie:=Gvr.DataKey("Serie").ToString) Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
+ Exit For
+ End If
+
+ 'ELIMINA EN TABLA DE CONTROL DE PAQUETES CON SERIE
+ If Not ObjInventario.RemovePaqueteRelacionSeries(CvePSTemp, Gvr.DataKey("Serie").ToString) Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
+ Exit For
+ End If
+ Next
+ Else
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, TxtCantidadDesarmado.Text.ToDecimal, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=CveSeccionAlmacen) Then
+ TieneError = True
+ MensajeError = "Ocurrió un error al guardar los movimientos de salida"
+ End If
+ End If
+
+
+ 'ENTRADA COMPONENTES
+ If Not TieneError Then
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 4, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ4")
+ FolioEntrada = ObjInventario.Folio
+
+ If CveMovimientoEntrada <= 0 Then
+ MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
+ TieneError = True
+ Else
+ For Each Gvr As GridViewRow In GvDatosDesarmado.Rows
+
+ Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text)
+ Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text)
+ If CBool(Gvr.DataKey("AplicaSeccion")) Then
+ CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
+ End If
+
+ If CBool(Gvr.DataKey("AplicaSerie")) Then
+ For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
+ If Not ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=Fecha.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr("Serie").ToString, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) >= 1 Then
+ MensajeError = String.Format("El Producto {0} con Serie: {1} no tiene existencia suficiente", Dr("PS"), Dr("Serie"))
+ TieneError = True
+ Exit For
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1,
+ CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
+ MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida. Por favor vuelva a intentar."
+ TieneError = True
+ Exit For
+ End If
+ Next
+
+ If TieneError Then
+ Exit For
+ End If
+
+ Else
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
+ Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
+ FechaCaducidad:=FechaCaducidad.ToDate) Then
+ MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
+ TieneError = True
+ Exit For
+ End If
+ End If
+ Next
+ End If
+ End If
+
+ ConcepPrePoliza1 = "ARMPAQ3"
+ ConcepPrePoliza2 = "ARMPAQ4"
+ Modulo = "ARMPAQ3/ARMPAQ4"
+ End Select
+
+ 'CONTABILIZAR MOVIMIENTOS
+ If Not TieneError Then
+ Dim ImportePrePoliza As Decimal = 0D
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
+ ImportePrePoliza = ObjInventario.DtResultados.SUMD("Total")
+ End If
+
+ Dim MovAlmacen As Boolean = True
+
+ Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 19).ToEntero
+
+ If OrigenMov = 1 Then
+ MovAlmacen = True
+ Else
+ MovAlmacen = False
+ End If
+
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(Modulo, 74, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Modulo, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza2, ConcepPrePoliza2, CveMovimientoAlmacen:=CveMovimientoEntrada, CveSubProyecto:=-1, Contabilizable:=True) Then
TieneError = True
End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza1, ConcepPrePoliza1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=True) Then
+ TieneError = True
+ End If
+
+ If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=6) Then
+ If ObjConta.ValorPolizaDescuadre > 0 Then
+ GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+ TieneError = True
+ End If
+ End If
End If
- End If
-
+ Catch ex As Exception
+ TieneError = True
+ OnError("Ocurrió un error al generar el movimiento", ex)
+ End Try
+
If Not TieneError Then
Dim Msg As New StringBuilder
Msg.AppendFormat(" El Movimiento de salida se registro con el Folio: {1}", CveMovimientoSalida, FolioSalida) @@ -778,6 +746,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado End If ObjInventario.Dispose() 'elimino la instancia + ObjConta.Dispose() End Sub Private Sub Limpia(Tipo As Integer) @@ -792,12 +761,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado DivSeriesPaqueteArmado.Visible = False GvDatosArmado.Columns(4).Visible = False - LbPaqueteArmado.Text = "" CvePaqueteArmado = -1 - LbCantidadArmado.Text = "" - 'LbAlmacenArmado.Text = "" CveAlmacenArmado = -1 - 'LbFechaArmado.Text = "" TxtObservacionesArmado.Text = "" UpGeneralesArmado.Update() @@ -806,12 +771,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado UpSeriesPaqueteArmado.Update() 'Else - LbPaqueteDesarmado.Text = "" CvePaqueteDesarmado = -1 - LbCantidadDesarmado.Text = "" - LbAlmacenDesarmado.Text = "" CveAlmacenDesarmado = -1 - LbFechaDesarmado.Text = "" TxtObservacionesDesarmado.Text = "" UpGeneralesDesarmado.Update() @@ -1133,7 +1094,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Dt.Columns.Add("Serie", GetType(String)) For Each Row As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CType(sender, LinkButton).CommandArgument.ToEntero)).Rows - If i > LbCantidadArmado.Text.ToEntero Then + If i > TxtCantidadArmado.Text.ToEntero Then Exit For End If @@ -1164,7 +1125,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado 'VERIFICA EXISTENCIAS Dim ObjInventarios As New ClsInventarios Dim CveUMTemp = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimeroValor("CveUM").ToEntero - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=LbFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) + Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) If Existencia < 1 Then Alert($"No hay existencia suficiente con la Serie definida ""{Serie}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) @@ -1190,7 +1151,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado TxtSerieDesarmado.Text = "" - If DtSeriesDesarmado.Rows.Count >= LbCantidadDesarmado.Text.ToEntero Then + If DtSeriesDesarmado.Rows.Count >= TxtCantidadDesarmado.Text.ToEntero Then BtnAgregarSerieDesarmado.Enabled = False Else BtnAgregarSerieDesarmado.Enabled = True @@ -1216,7 +1177,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado dtTemp.Dispose() - If DtSeriesDesarmado.Rows.Count >= LbCantidadDesarmado.Text.ToEntero Then + If DtSeriesDesarmado.Rows.Count >= TxtCantidadDesarmado.Text.ToEntero Then BtnAgregarSerieDesarmado.Enabled = False Else BtnAgregarSerieDesarmado.Enabled = True |