diff --git a/Inventarios/AjustesSeccionAlmacen.aspx b/Inventarios/AjustesSeccionAlmacen.aspx index 9efda2629..9056f3383 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx +++ b/Inventarios/AjustesSeccionAlmacen.aspx @@ -45,7 +45,7 @@ - + @@ -54,7 +54,7 @@ - + diff --git a/Inventarios/Apartados.aspx b/Inventarios/Apartados.aspx index dc0fbdef7..57bf1f423 100644 --- a/Inventarios/Apartados.aspx +++ b/Inventarios/Apartados.aspx @@ -170,7 +170,13 @@
Producto - Serie - Lote + Serie + + Lote + + F.Caducidad + + Sección Comandos @@ -203,17 +209,26 @@ - + - + - - - - + + + + + + + + + + + + @@ -235,9 +250,12 @@ + + - ssss + + @@ -292,9 +310,11 @@
Cliente
- - - + + + + <%-- + --%>
Vendedor:
@@ -357,7 +377,7 @@
- +
@@ -381,7 +401,7 @@
- + @@ -393,12 +413,16 @@ - + + + - - ssss - - + + + + + +
diff --git a/Inventarios/Apartados.aspx.vb b/Inventarios/Apartados.aspx.vb index faef671d2..db73531dd 100644 --- a/Inventarios/Apartados.aspx.vb +++ b/Inventarios/Apartados.aspx.vb @@ -32,20 +32,20 @@ Partial Class Inventarios_Apartados ViewState("CargadoDeMov") = value End Set End Property - Private Property CvePSSerieLote As Integer + Private Property CvePSSerie As Integer Get - Return CType(ViewState("CvePSSerieLote"), Integer) + Return CType(ViewState("CvePSSerie"), Integer) End Get Set(value As Integer) - ViewState("CvePSSerieLote") = value + ViewState("CvePSSerie") = value End Set End Property - Private Property CveUMSerieLote As Integer + Private Property CveUMSerie As Integer Get - Return CType(ViewState("CveUMSerieLote"), Integer) + Return CType(ViewState("CveUMSerie"), Integer) End Get Set(value As Integer) - ViewState("CveUMSerieLote") = value + ViewState("CveUMSerie") = value End Set End Property Private Property CveCliente As Integer @@ -64,14 +64,7 @@ Partial Class Inventarios_Apartados ViewState("CveVendedor") = value 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) @@ -147,7 +140,7 @@ Partial Class Inventarios_Apartados DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem(" Seleccione ", "-1")) + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione ", "-1")) DdlSubProyectoDesapartado.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) DdlSubProyectoDesapartado.DataBind() @@ -168,11 +161,16 @@ Partial Class Inventarios_Apartados Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) If EsWS Then DdlClientes.setEsWebService(True) + DdlClienteDesapartado.setEsWebService(True) Else DdlClientes.setEsWebService(False) DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) DdlClientes.DataBind() DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + DdlClienteDesapartado.setEsWebService(False) + DdlClienteDesapartado.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClienteDesapartado.DataBind() + DdlClienteDesapartado.ddl.Items.Insert(0, New ListItem("Todos", "-1")) End If @@ -180,9 +178,9 @@ Partial Class Inventarios_Apartados 'DdlCliente.DataBind() 'DdlCliente.Items.Insert(0, New ListItem(" Seleccione ", "-1")) - DdlClienteDesapartado.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - DdlClienteDesapartado.DataBind() - DdlClienteDesapartado.Items.Insert(0, New ListItem(" Todos ", "-1")) + 'DdlClienteDesapartado.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + 'DdlClienteDesapartado.DataBind() + 'DdlClienteDesapartado.Items.Insert(0, New ListItem(" Todos ", "-1")) DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa) DdlVendedor.DataBind() @@ -230,7 +228,11 @@ Partial Class Inventarios_Apartados dt.Columns.Add("CvePS", Type.GetType("System.Int32")) dt.Columns.Add("CveAF", Type.GetType("System.Int32")) dt.Columns.Add("PS") - dt.Columns.Add("SerieLote") + dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacen") + dt.Columns.Add("Serie") + dt.Columns.Add("Lote") + dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime")) dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) dt.Columns.Add("EstatusExistencia") @@ -262,17 +264,40 @@ Partial Class Inventarios_Apartados ElProductoChange() End Sub Private Sub ElProductoChange() - TxtnSerieLote.Visible = False + TxtnSerie.Visible = False If DdlProducto2.SelectedValue.ToEntero > 0 Then - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5 OR AplicaSerie = 1 ", "PSCodigo").Rows.Count > 0 Then - ThSerieLote.Visible = True - TdSerieLote.Visible = True - TxtnSerieLote.Visible = True - GvDatos.Columns(4).Visible = True + Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("") + If drP IsNot Nothing Then + If CBool(drP("AplicaSerie")) Then + ThSerie.Visible = True + TdSerie.Visible = True + TxtnSerie.Visible = True + GvDatos.Columns(4).Visible = True + End If + If CBool(drP("AplicaLote")) Then + ThLote.Visible = True + TdLote.Visible = True + GvDatos.Columns(5).Visible = True + End If + If CBool(drP("AplicaCaducidad")) Then + ThCaducidad.Visible = True + TdCaducidad.Visible = True + GvDatos.Columns(6).Visible = True + End If + If CBool(drP("AplicaSeccion")) Then + ThSeccion.Visible = True + TdSeccionAlmacen.Visible = True + DdlSeccionAlmacen.DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlProducto2.SelectedValue.ToEntero) + DdlSeccionAlmacen.DataBind() + GvDatos.Columns(7).Visible = True + End If + End If + End If + DdlUnidad.Items.Clear() DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) DdlUnidad.DataBind() @@ -380,8 +405,8 @@ Partial Class Inventarios_Apartados If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then TdSeriePS.Visible = True TxtSeriePS.Focus() - CvePSSerieLote = DrPS("CvePS").ToString.ToEntero - CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero + CvePSSerie = DrPS("CvePS").ToString.ToEntero + CveUMSerie = DrPS("CveUnidadMedida").ToString.ToEntero Exit Sub End If @@ -397,10 +422,10 @@ Partial Class Inventarios_Apartados txtCantidad.Text = "1" - Dim Valido = ValidaExistencia(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) + Dim Valido = ValidaExistencia(1, CvePSSerie, CveUMSerie, TxtSeriePS.Text.Trim) If Valido Then - AgregarPS(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) + AgregarPS(1, CvePSSerie, CveUMSerie, Serie:=TxtSeriePS.Text.Trim) Else TxtSeriePS.Text = "" TxtSeriePS.Focus() @@ -426,10 +451,10 @@ Partial Class Inventarios_Apartados Dim FuncionalidadSinSerie = True If CveProducto > 0 Then - If TxtnSerieLote.Visible Then + If TxtnSerie.Visible Then Cantidad = 1 - If TxtnSerieLote.Text = "" Then - Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia) + If TxtnSerie.Text = "" Then + Alert("Serie es necesario", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") Exit Sub End If @@ -438,19 +463,20 @@ Partial Class Inventarios_Apartados End If End If - Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1")) + Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, "-1")) If Valido Then - AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1"), FuncionalidadSinSerie) + AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Text <> "", TxtnSerie.Text, ""), Limpia:=FuncionalidadSinSerie) End If End If End Sub - Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Serie As String = "-1", Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha) As Boolean + Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Serie As String = "-1", + Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha, Optional CveSeccionAlmacen As Integer = -1) 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"), Serie:=Serie) + Dim Existencia As Double = 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) Inv.Dispose() If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(Serie <> "-1", $" AND Serie = '{Serie}'", "")}") < 0 Then @@ -466,7 +492,8 @@ Partial Class Inventarios_Apartados Return Retorno End Function - Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional SerieLote As String = "-1", Optional Limpia As Boolean = True) + Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, + Optional CveSeccionAlmacen As Integer = -1, Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True, Optional SeccionAlmacen As String = "") 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')") @@ -485,10 +512,14 @@ Partial Class Inventarios_Apartados registro.Item("UnidadMedida") = DrUM("UnidadMedida") registro.Item("CvePS") = CvePS registro.Item("PS") = DrPS("PSCodigo") - registro.Item("SerieLote") = SerieLote + registro.Item("Serie") = Serie + registro.Item("Lote") = Lote + registro.Item("FechaCaducidad") = FechaCaducidad registro.Item("CveClasificacion") = CveClasificacion registro.Item("CveAF") = -1 registro.Item("EstatusExistencia") = "1" + registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen + registro.Item("SeccionAlmacen") = If(CveSeccionAlmacen > 0, SeccionAlmacen, "") DtMovimientos.Rows.Add(registro) RegistraScript("playsonidito('beep-07.wav')") @@ -498,16 +529,16 @@ Partial Class Inventarios_Apartados LimpiaAgregar() Else txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString - TxtnSerieLote.Text = "" - TxtnSerieLote.Focus() + TxtnSerie.Text = "" + TxtnSerie.Focus() End If End Sub Private Sub LimpiaAgregar() DdlClasificacion.SelectedValue = "-1" DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) txtCantidad.Text = "" - TxtnSerieLote.Text = "" - TxtnSerieLote.Visible = False + TxtnSerie.Text = "" + TxtnSerie.Visible = False txtCantidad.Focus() If TxtCodigoPS.Visible Then TxtCodigoPS.Focus() @@ -517,12 +548,18 @@ Partial Class Inventarios_Apartados #Region " GV DATOS " Private Sub CargaGvDatos(Optional EscondeSerie As Boolean = True) - If EscondeSerie Then - TxtnSerieLote.Visible = False - ThSerieLote.Visible = False - TdSerieLote.Visible = False - GvDatos.Columns(4).Visible = False - End If + 'If EscondeSerie Then + ' TxtnSerie.Visible = False + ' ThSerie.Visible = False + ' TdSerie.Visible = False + ' GvDatos.Columns(4).Visible = False + 'End If + + GvDatos.Columns(4).Visible = DtMovimientos.MAX("Serie").ToString <> "" + GvDatos.Columns(5).Visible = DtMovimientos.MAX("Lote").ToString <> "" + GvDatos.Columns(6).Visible = DtMovimientos.MAX("FechaCaducidad").ToString.ToDate > MinFecha + GvDatos.Columns(7).Visible = DtMovimientos.MAX("CveSeccionAlmacen").ToString.ToEntero > 0 + GvDatos.DataSource = DtMovimientos GvDatos.DataBind() @@ -541,20 +578,20 @@ Partial Class Inventarios_Apartados e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) End If - If If(e.Row.DBCampo("Serie").ToString = "", "-1", e.Row.DBCampo("Serie").ToString) <> "-1" Then - TxtnSerieLote.Visible = True - ThSerieLote.Visible = True - TdSerieLote.Visible = True - GvDatos.Columns(4).Visible = True - e.Row.Cells(4).Text = e.Row.DBCampo("Serie").ToString - Else - e.Row.Cells(4).Text = "" - End If + 'If If(e.Row.DBCampo("Serie").ToString = "", "-1", e.Row.DBCampo("Serie").ToString) <> "-1" Then + ' TxtnSerie.Visible = True + ' ThSerie.Visible = True + ' TdSerie.Visible = True + ' GvDatos.Columns(4).Visible = True + ' e.Row.Cells(4).Text = e.Row.DBCampo("Serie").ToString + 'Else + ' e.Row.Cells(4).Text = "" + '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 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 End If End Sub @@ -593,12 +630,12 @@ Partial Class Inventarios_Apartados Next Dim TotalCantidad As Double = 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 + '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 ObjInventario As New ClsInventarios @@ -610,8 +647,8 @@ Partial Class Inventarios_Apartados If Not CargadoDeMov Then For Each dr As DataRow In DtMovimientos.Rows - 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"), Serie:=If(dr("Serie").ToString = "", "-1", dr("Serie").ToString)) - Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("Serie").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}") + 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:=dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=If(dr("Serie").ToString = "", "-1", dr("Serie").ToString)) + Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("Serie").ToString <> "-1", $" AND Serie = '{dr("Serie").ToString}'", "")}") 'DtMovimientos.SUM("Cantidad", String.Format("CvePS = {0}", dr("CvePS").ToString.ToEntero)) If Existencia < 0 Then @@ -623,7 +660,7 @@ Partial Class Inventarios_Apartados Next Else For Each gvr As GridViewRow In GvDatos.Rows - 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"), Serie:=If(gvr.DataKey("Serie").ToString = "", "-1", gvr.DataKey("Serie").ToString)) + 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:=gvr.DataKey("CveSeccionAlmacen").ToString.ToEntero, Serie:=If(gvr.DataKey("Serie").ToString = "", "-1", gvr.DataKey("Serie").ToString)) Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero If Existencia < 0 Then ErrorExistencia = True @@ -666,7 +703,7 @@ Partial Class Inventarios_Apartados ErrorMovInv = True Else 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, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For @@ -689,8 +726,12 @@ Partial Class Inventarios_Apartados ErrorMovInv = True Else If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Dim CveSec 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, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then + CveSec = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenDestino.SelectedValue.ToEntero, Dr("CvePS").ToString.ToEntero).FiltroPrimeroValor("CveSeccionAlmacen", "").ToEntero + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=CveSec, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -771,6 +812,13 @@ Partial Class Inventarios_Apartados Protected Sub GvDatosDesapartado_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosDesapartado.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.FCTextBox("TxtCantidad").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) + If CBool(e.Row.DBCampo("AplicaSeccion")) AndAlso DdlAlmacenDestinoDesapartado.SelectedValue.ToEntero > 0 Then + e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True + e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenDestinoDesapartado.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero) + e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() + e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + End If End Sub Protected Sub BtnVerificarExistenciasDesarmado_Click(sender As Object, e As EventArgs) @@ -789,11 +837,15 @@ Partial Class Inventarios_Apartados Dim DtTemp = GetExistenciasDT() If DtTemp IsNot Nothing Then + GvDatosDesapartado.Columns(5).Visible = DtTemp.MAX("Serie").ToString <> "" + GvDatosDesapartado.Columns(6).Visible = DtTemp.MAX("Lote").ToString <> "" + GvDatosDesapartado.Columns(7).Visible = DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha + GvDatosDesapartado.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0 + GvDatosDesapartado.DataSource = DtTemp GvDatosDesapartado.DataBind() UpDatosDesapartado.Update() - DtSeccionAlmacen.Rows.Clear() End If End Sub @@ -856,12 +908,12 @@ Partial Class Inventarios_Apartados End If Next - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> 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 + 'If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + ' If TotalCantidad <> 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 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA Dim CantidadGV = GvDatosDesapartado.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("Cantidad").ToDouble) @@ -889,6 +941,7 @@ Partial Class Inventarios_Apartados Observaciones:=TxtObservacionesDesapartado.Text.Trim, Recibio:="", CveAlmacenDestino:=DdlAlmacenDestinoDesapartado.SelectedValue.ToEntero, CveCliente:=CveCliente, CveVendedor:=CveVendedor) FolioSalida = ObjInventario.Folio + Dim Diccionario As New HybridDictionary Dim Cont As Integer = 0 If CveMovimientoSalida <= 0 Then ErrorMovInv = True @@ -896,10 +949,12 @@ Partial Class Inventarios_Apartados Else For Each Gvr As GridViewRow In GvDatosDesapartado.Rows If Gvr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, Gvr.DataKey("Serie").ToString, CveMovimientoDetalleEntrada:=Gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, CveSeccionAlmacen:=Gvr.DataKey("CveSeccionAlmacen").ToEntero, Serie:=Gvr.DataKey("Serie").ToString, Lote:=Gvr.DataKey("Lote").ToString, FechaCaducidad:=Gvr.DataKey("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For + Else + Diccionario.Add(ObjInventario.CveMovimientoDetalle, Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue) End If End If Cont += 1 @@ -917,8 +972,11 @@ Partial Class Inventarios_Apartados ErrorMovInv = True Else If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Dim i 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("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then + Dim CveSeccionAlmacen As Integer = Diccionario(Dr("CveMovimientoDetalle").ToString.ToEntero).ToString.ToEntero + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -955,6 +1013,12 @@ Partial Class Inventarios_Apartados ObjInventario.Dispose() End Sub + + Private Sub DdlAlmacenDestinoDesapartado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacenDestinoDesapartado.SelectedIndexChanged + + CargaExistencias() + + End Sub #End Region #End Region diff --git a/Inventarios/CatSeccionesAlmacenes.aspx.vb b/Inventarios/CatSeccionesAlmacenes.aspx.vb index 15091d1ca..bf2e601a7 100644 --- a/Inventarios/CatSeccionesAlmacenes.aspx.vb +++ b/Inventarios/CatSeccionesAlmacenes.aspx.vb @@ -62,6 +62,8 @@ Partial Class Inventarios_CatSeccionesAlmacenes Alert("La Seccion se guardó correctamente.", TipoMensaje.MsgInformacion) ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + ObjSeccion.GetSeccionesAlmacenes(UsuarioActual.CveEmpresa, -1) + GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados If ViewState("Orden").ToString() <> String.Empty Then @@ -107,6 +109,7 @@ Partial Class Inventarios_CatSeccionesAlmacenes SeccionTxt.Text = "" DdlAlmacen.SelectedIndex = 0 Alert("La Seccion se actualizo correctamente.", TipoMensaje.MsgInformacion) + ObjSeccion.GetSeccionesAlmacenes(UsuarioActual.CveEmpresa, -1) ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados End If diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 4d6fc54de..a0b2632f5 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -2148,27 +2148,27 @@ Partial Class Inventarios_EntradasSalidas EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) If DdlProducto2.SelectedValue.ToEntero > 0 Then - Dim MetodoInventario As Integer = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimeroValor("Inv_CveMetodoInventario", "").ToEntero ' ("Inv_CveMetodoInventario = 6", "PS") - If MetodoInventario = 5 Then + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("") + If dr IsNot Nothing Then + If CBool(dr("AplicaSerie")) Then - 'LblSerieLote.Visible = True - TxtnSerie.Visible = True - divSerie.Visible = True + 'LblSerieLote.Visible = True + TxtnSerie.Visible = True + divSerie.Visible = True - 'TrSerieLote.Visible = True - 'TrSerieLote2.Visible = True - GvM.Columns(9).Visible = True + 'TrSerieLote.Visible = True + 'TrSerieLote2.Visible = True + + End If + If CBool(dr("AplicaLote")) Then + TxtnLote.Visible = True + divLote.Visible = True + 'TrLote.Visible = True + 'TrLote2.Visible = True + + End If End If - If MetodoInventario = 6 Then - TxtnLote.Visible = True - divLote.Visible = True - 'TrLote.Visible = True - 'TrLote2.Visible = True - GvM.Columns(10).Visible = True - 'TrBatch2.Visible = True - GvM.Columns(11).Visible = True - End If End If DdlUnidad.Items.Clear() @@ -2230,43 +2230,10 @@ Partial Class Inventarios_EntradasSalidas End If If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then - If DtTemp.MAX("Serie").ToString <> "" Then - 'LblSerie.Visible = True - TxtnSerie.Visible = True - 'TrSerieLote.Visible = True - 'TrSerieLote2.Visible = True - GvM.Columns(9).Visible = True - End If - - If DtTemp.MAX("Lote").ToString <> "" Then - TxtnLote.Visible = True - 'TrLote.Visible = True - 'TrLote2.Visible = True - GvM.Columns(10).Visible = True - - 'TxtnBatch.Visible = True - 'TrBatch.Visible = True - 'TrBatch2.Visible = True - 'GvM.Columns(11).Visible = True - End If - If DtTemp.MAX("FechaCaducidad").ToString <> "" Then - - GvM.Columns(11).Visible = True - - 'TxtnBatch.Visible = True - 'TrBatch.Visible = True - 'TrBatch2.Visible = True - 'GvM.Columns(11).Visible = True - End If - - - - If DtTemp.MAX("CveSeccionAlmacen").ToString <> "" Then - 'TxtnBatch.Visible = True - 'TrBatch.Visible = True - 'TrBatch2.Visible = True - GvM.Columns(12).Visible = True - End If + GvM.Columns(9).Visible = DtTemp.MAX("Serie").ToString <> "" + GvM.Columns(10).Visible = DtTemp.MAX("Lote").ToString <> "" + GvM.Columns(11).Visible = DtTemp.MAX("FechaCaducidad").ToString <> "" + GvM.Columns(12).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString <> "" End If diff --git a/Inventarios/EntregaAlmacen.aspx b/Inventarios/EntregaAlmacen.aspx index e9e0c1115..e38673a70 100644 --- a/Inventarios/EntregaAlmacen.aspx +++ b/Inventarios/EntregaAlmacen.aspx @@ -777,7 +777,7 @@ - +
diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index c9d121ee1..c092d7182 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -831,7 +831,7 @@ Partial Class Inventarios_EntregaAlmacen If CBool(e.Row.DBCampo("AplicaSeccion")) Then e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True If DdlAlmacen.SelectedValue.ToEntero > 0 Then - e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) + e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero) e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) End If @@ -1315,10 +1315,10 @@ Partial Class Inventarios_EntregaAlmacen Protected Sub GvLote_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvLote.RowDeleting - Dim keySerieLote As String = e.Keys("Lote").ToString + Dim keyLote As String = e.Keys("Lote").ToString Try For Each dr As DataRow In DtDatosDetalleLote.Rows - If dr("Lote").ToString = keySerieLote Then + If dr("Lote").ToString = keyLote Then dr.Delete() End If Next @@ -2069,7 +2069,7 @@ Partial Class Inventarios_EntregaAlmacen Else If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then 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, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then ErrorMovInv = True TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de entrada") Exit For diff --git a/Inventarios/RecepcionAlmacen.aspx b/Inventarios/RecepcionAlmacen.aspx index f4b956e66..9b96fab08 100644 --- a/Inventarios/RecepcionAlmacen.aspx +++ b/Inventarios/RecepcionAlmacen.aspx @@ -479,7 +479,7 @@ - + @@ -721,23 +721,12 @@ - Serie/Lote: + Serie: - - Fecha Caducidad: - - -   - - - - - - - + @@ -748,8 +737,7 @@ - - + diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 6ec6e2e25..893e3be4c 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -436,7 +436,6 @@ Partial Class Inventarios_RecepcionAlmacen DivRemision.Visible = True End If - TxtFechaCaducidad.Text = Now.ToShortDateString TxtFechaPendientes.Text = Now.ToShortDateString TipoCambio = -1 CreaDtDetalle() @@ -1268,6 +1267,7 @@ Partial Class Inventarios_RecepcionAlmacen e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) End If + e.Row.FCTextBox("TxtDividir").Visible = True Else e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False @@ -1277,6 +1277,7 @@ Partial Class Inventarios_RecepcionAlmacen e.Row.FCTextBox("TxtCaducidad").Visible = True e.Row.FCLinkButton("LnkCaducidad").Visible = True e.Row.FCTextBox("TxtCaducidad").Text = Now.ToShortDateString + e.Row.FCTextBox("TxtDividir").Visible = True Else e.Row.FCTextBox("TxtCaducidad").Visible = False e.Row.FCLinkButton("LnkCaducidad").Visible = False @@ -1446,7 +1447,6 @@ Partial Class Inventarios_RecepcionAlmacen LbProducto.Text = Argumentos(3) LbCantidad.Text = Argumentos(4).FormatoNumero - TxtFechaCaducidad.Text = Now.ToShortDateString() CvePSSerie = Argumentos(0).ToEntero CveUMSerie = Argumentos(1).ToEntero @@ -1638,7 +1638,6 @@ Partial Class Inventarios_RecepcionAlmacen If Tipo = 1 Then TxtSerie.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString End If CargaSerie(Tipo, True) @@ -1752,10 +1751,10 @@ Partial Class Inventarios_RecepcionAlmacen End Sub Protected Sub BtnAddPSLote_Click(sender As Object, e As EventArgs) - AgregaLote(TxtLote.Text.Trim, TxtFechaCaducidad.Text.ToDate, 1) + AgregaLote(TxtLote.Text.Trim, 1) End Sub - Private Sub AgregaLote(Lote As String, FechaCaducidad As Date, Tipo As Integer) + Private Sub AgregaLote(Lote As String, Tipo As Integer) If Lote.Trim = "" Then Alert("El campo Lote es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) @@ -1783,15 +1782,15 @@ Partial Class Inventarios_RecepcionAlmacen 'VERIFICA EXISTENCIAS If TipoMovimiento > 1 Then - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Lote, FechaCaducidad:=FechaCaducidad) + Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Lote) If Existencia < CantidadLote Then - Alert($"
El numero de Lote ""{Lote}"" y FechaCaducidad = '{FechaCaducidad}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) + Alert($"
El numero de Lote ""{Lote}"" proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") End If If TipoMovimiento = 2 Then - If Not DtExistencias.SUM("Existencia", $"Lote = '{Lote}' FechaCaducidad = '{FechaCaducidad}'") = 0 Then - Alert($"
El numero de Lote ""{Lote}"" y FechaCaducidad '{FechaCaducidad}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) + If Not DtExistencias.SUM("Existencia", $"Lote = '{Lote}' ") = 0 Then + Alert($"
El numero de Lote ""{Lote}"" proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") End If End If @@ -1804,8 +1803,8 @@ Partial Class Inventarios_RecepcionAlmacen Row("CveUM") = CveUMSerie Row("PU") = PUSerie Row("Lote") = Lote - Row("FechaCaducidad") = FechaCaducidad - Row("FechaCaducidad") = If(IsDate(TxtFechaCaducidadLote.Text), TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) + 'Row("FechaCaducidad") = FechaCaducidad + 'Row("FechaCaducidad") = If(IsDate(TxtFechaCaducidadLote.Text), TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) 'Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) DtDatosLoteDetalle.Rows.Add(Row) @@ -1813,8 +1812,6 @@ Partial Class Inventarios_RecepcionAlmacen If Tipo = 1 Then TxtLote.Text = "" - TxtBatch.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString End If CargaLote(1, True) @@ -2817,68 +2814,77 @@ Partial Class Inventarios_RecepcionAlmacen End If End If + Else + ErrorMovInv = True + MensajeError = "Error al obtener movimientos" End If 'PREPOLIZA - NC - If TipoMovimiento = 3 AndAlso ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - - Dim DtCostos As DataTable = Nothing - DtCostos = ObjInventario.DtResultados - Dim TotalCosto As Decimal = DtCostos.SUM("Total").ToDecimal - - Dim TotalNC As Decimal = 0 - Dim CveClasificacionDifCostoNC = -1 - Dim tTipoCambio As Decimal = 1 - If CveMoneda <> 1 Then tTipoCambio = TipoCambio.ToDecimal - - For Each gvr As GridViewRow In GvInv.Rows - TotalNC += gvr.FCTextBox("TbCantidadF").Text.ToDecimal * gvr.DataKey("PU").ToDecimal * tTipoCambio - CveClasificacionDifCostoNC = gvr.DataKey("CveClasificacion").ToEntero - Next - Dim IdCtaContableClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionDifCostoNC}").ToEntero - Dim CveCuentaClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {CveClasificacionDifCostoNC}").ToEntero - - TotalCosto = Math.Round(TotalCosto, 2) - TotalNC = Math.Round(TotalNC, 2) - Dim DifCostoNC = Math.Round(TotalCosto - TotalNC, 2) + If TipoMovimiento = 3 Then + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - 'VARIABLES - Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim Fecha As Date = TxtFecha.Text.ToDate - Dim CveProveedor As Integer = -1 - Dim ProveedorNombre As String = "" - Dim SerieFolio As String = "" - Dim IdCtaContableNC = 0 - Dim CveConceptoContableNC = -1 - If DtCostos.Rows.Count > 0 Then - If CveCompraSurtir > 0 Then - If ObjCompras.GetCompras(CveCompraSurtir, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - CveProveedor = ObjCompras.DtResultados(0)("CveProveedor").ToString.ToEntero - ProveedorNombre = ObjCompras.DtResultados(0)("RazonSocial").ToString - SerieFolio = $"NC: {ObjCompras.DtResultados(0)("SerieFolio").ToString}" + Dim DtCostos As DataTable = Nothing + DtCostos = ObjInventario.DtResultados + Dim TotalCosto As Decimal = DtCostos.SUM("Total").ToDecimal - CveConceptoContableNC = 225 - If ObjConta.GetRetCuenta(CveConceptoContableNC, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableNC = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + Dim TotalNC As Decimal = 0 + Dim CveClasificacionDifCostoNC = -1 + Dim tTipoCambio As Decimal = 1 + If CveMoneda <> 1 Then tTipoCambio = TipoCambio.ToDecimal + + For Each gvr As GridViewRow In GvInv.Rows + TotalNC += gvr.FCTextBox("TbCantidadF").Text.ToDecimal * gvr.DataKey("PU").ToDecimal * tTipoCambio + CveClasificacionDifCostoNC = gvr.DataKey("CveClasificacion").ToEntero + Next + Dim IdCtaContableClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionDifCostoNC}").ToEntero + Dim CveCuentaClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {CveClasificacionDifCostoNC}").ToEntero + + TotalCosto = Math.Round(TotalCosto, 2) + TotalNC = Math.Round(TotalNC, 2) + Dim DifCostoNC = Math.Round(TotalCosto - TotalNC, 2) + + + 'VARIABLES + Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero + Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero + Dim Fecha As Date = TxtFecha.Text.ToDate + Dim CveProveedor As Integer = -1 + Dim ProveedorNombre As String = "" + Dim SerieFolio As String = "" + Dim IdCtaContableNC = 0 + Dim CveConceptoContableNC = -1 + + If DtCostos.Rows.Count > 0 Then + If CveCompraSurtir > 0 Then + If ObjCompras.GetCompras(CveCompraSurtir, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + CveProveedor = ObjCompras.DtResultados(0)("CveProveedor").ToString.ToEntero + ProveedorNombre = ObjCompras.DtResultados(0)("RazonSocial").ToString + SerieFolio = $"NC: {ObjCompras.DtResultados(0)("SerieFolio").ToString}" + + CveConceptoContableNC = 225 + If ObjConta.GetRetCuenta(CveConceptoContableNC, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableNC = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + Else + ErrorMovInv = True End If - - Else - ErrorMovInv = True End If - End If - If Not ErrorMovInv Then - CvePrePoliza = ObjConta.AddPrePolizas("Inventario/RecepcionAlmacen-NC", 74, TotalCosto, TotalCosto, 1, Fecha, ProveedorNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePoliza > 0 Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalNC, SerieFolio, CveConceptoContableNC, SerieFolio, Fecha, IdCtaContableNC, -1, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalNC) Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCosto * -1, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalCosto * -1, CveCuenta:=CveCuentaAlmacen) Then - If DifCostoNC <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DifCostoNC * -1, SerieFolio, 69, SerieFolio, Fecha, IdCtaContableClasificacion, -1, CveClasificacion:=CveClasificacionDifCostoNC, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DifCostoNC * -1, CveCuenta:=CveCuentaClasificacion) Then - ErrorMovInv = True + If Not ErrorMovInv Then + CvePrePoliza = ObjConta.AddPrePolizas("Inventario/RecepcionAlmacen-NC", 74, TotalCosto, TotalCosto, 1, Fecha, ProveedorNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePoliza > 0 Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalNC, SerieFolio, CveConceptoContableNC, SerieFolio, Fecha, IdCtaContableNC, -1, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalNC) Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCosto * -1, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalCosto * -1, CveCuenta:=CveCuentaAlmacen) Then + If DifCostoNC <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DifCostoNC * -1, SerieFolio, 69, SerieFolio, Fecha, IdCtaContableClasificacion, -1, CveClasificacion:=CveClasificacionDifCostoNC, CveCompra:=CveCompraSurtir, CveProveedor:=CveProveedor, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DifCostoNC * -1, CveCuenta:=CveCuentaClasificacion) Then + ErrorMovInv = True + End If End If + Else + ErrorMovInv = True End If Else ErrorMovInv = True @@ -2886,51 +2892,53 @@ Partial Class Inventarios_RecepcionAlmacen Else ErrorMovInv = True End If - Else - ErrorMovInv = True End If - End If - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Inventarios/RecepcionAlmacen-PPNC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - ErrorMovInv = True + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Inventarios/RecepcionAlmacen-PPNC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + ErrorMovInv = True + End If End If - End If - 'CONTABILIZAR - UNIFICAR Y SIMPLIFICAR CON PP DE LA COMPRA - If Not ErrorMovInv Then + 'CONTABILIZAR - UNIFICAR Y SIMPLIFICAR CON PP DE LA COMPRA + If Not ErrorMovInv Then - If CvePrePolizaCompra > 0 Then - If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then - If Not ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCompra) Then - ErrorMovInv = True - MensajeError = "Error al unificar los conceptos contables" + If CvePrePolizaCompra > 0 Then + If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then + If Not ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCompra) Then + ErrorMovInv = True + MensajeError = "Error al unificar los conceptos contables" + End If End If End If - End If - If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then - If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True - MensajeError = "Error al simplificar los conceptos contables" + If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then + If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then + ErrorMovInv = True + MensajeError = "Error al simplificar los conceptos contables" + End If End If - End If - If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - ObjContaContPAQ = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaContPAQ.IniciaTransacSQL() - If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaContPAQ) Then - MensajeContabilidad = $"
Movimiento contabilizado en el folio: {ObjConta.ContaFolio}
" - Else - ErrorMovInv = True - MensajeError = "Error al contabilizar los conceptos contables" + If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + ObjContaContPAQ = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaContPAQ.IniciaTransacSQL() + If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaContPAQ) Then + MensajeContabilidad = $"
Movimiento contabilizado en el folio: {ObjConta.ContaFolio}
" + Else + ErrorMovInv = True + MensajeError = "Error al contabilizar los conceptos contables" + End If End If + End If End If + Else + ErrorMovInv = True + MensajeError = "Error al obtener movimientos" End If End If diff --git a/Inventarios/RepApartados2.aspx b/Inventarios/RepApartados2.aspx index 4075ec211..aecae7b73 100644 --- a/Inventarios/RepApartados2.aspx +++ b/Inventarios/RepApartados2.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepApartados2.aspx.vb" Inherits="Inventarios_RepApartados" %> +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepApartados2.aspx.vb" Inherits="Inventarios_RepApartados2" %> @@ -110,7 +110,7 @@
<%----%> <%-- - --%> + %>
diff --git a/Inventarios/RepApartados2.aspx.vb b/Inventarios/RepApartados2.aspx.vb index fc3e8cf14..7c991c56b 100644 --- a/Inventarios/RepApartados2.aspx.vb +++ b/Inventarios/RepApartados2.aspx.vb @@ -5,7 +5,7 @@ Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms -Partial Class Inventarios_RepApartados +Partial Class Inventarios_RepApartados2 Inherits ClsPaginas diff --git a/Inventarios/ReporteMaterial.aspx b/Inventarios/ReporteMaterial.aspx index dec42c127..17906ae3a 100644 --- a/Inventarios/ReporteMaterial.aspx +++ b/Inventarios/ReporteMaterial.aspx @@ -91,7 +91,7 @@
- + @@ -117,7 +117,7 @@ Text='<%# Eval("Folio").ToString %>' /> - + diff --git a/Inventarios/TraspasoAlmacen.aspx b/Inventarios/TraspasoAlmacen.aspx index 1da4c116e..785ef1ff6 100644 --- a/Inventarios/TraspasoAlmacen.aspx +++ b/Inventarios/TraspasoAlmacen.aspx @@ -459,10 +459,10 @@ - + - s + @@ -661,9 +661,13 @@ + + - sss + + + diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 756ff111b..0d8762b4d 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -510,20 +510,30 @@ Partial Class Inventarios_TraspasoAlmacen Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, If(TxtnSerie.Visible, TxtnSerie.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha)) 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(TxtnLote.Visible, TxtnLote.Text, ""), FechaCaducidad:=If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha), Limpia:=FuncionalidadSinSerie) + AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(TxtnLote.Visible, TxtnLote.Text, ""), FechaCaducidad:=If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha), CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie) End If End If End Sub - Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, CveSeccionAlmacen As Integer, Serie As String, Lote As String, Fechacaducidad As Date) As Boolean + Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, CveSeccionAlmacen As Integer, Serie As String, Lote As String, FechaCaducidad As Date) As Boolean Dim Retorno = True + Dim ExistenciaEspecificada As Decimal + Dim CantidadEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(Serie <> "-1", $" AND Serie = '{Serie}'", "")}") + 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"), Serie:=Serie, Lote:=Lote, FechaCaducidad:=Fechacaducidad, PendientePorSurtir:=1) + 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) + '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 Serie <> "" OrElse Lote <> "" 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) + Else + ExistenciaEspecificada = Existencia + End If Inv.Dispose() - If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(Serie <> "-1", $" AND Serie = '{Serie}'", "")}") < 0 Then - If Existencia < 0 Then + If Existencia - Cantidad - CantidadEnGrid < 0 ORELSE ExistenciaEspecificada - Cantidad - CantidadEnGrid < 0 Then + If Existencia < 0 OrElse ExistenciaEspecificada < 0 Then Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") Else @@ -535,7 +545,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 CveSeccionAlmacen As Integer = -1, Optional SeccionAlmacen As String = "", Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True) + Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional CveSeccionAlmacen As Integer = -1, Optional SeccionAlmacen As String = "", Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True, Optional CveSeccionAlmacenDestino As Integer = -1) 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')") @@ -558,10 +568,13 @@ Partial Class Inventarios_TraspasoAlmacen registro.Item("Observaciones") = Observaciones registro.Item("Serie") = Serie registro.Item("Lote") = Lote - registro.Item("FechaCaducidad") = FechaCaducidad + If FechaCaducidad > MinFecha Then registro.Item("FechaCaducidad") = FechaCaducidad registro.Item("CveClasificacion") = CveClasificacion registro.Item("CveAF") = -1 registro.Item("EstatusExistencia") = "1" + registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen + registro.Item("SeccionAlmacen") = SeccionAlmacen + registro.Item("CveSeccionAlmacenDestino") = CveSeccionAlmacenDestino registro.Item("TotalImporte") = 0 registro.Item("PU") = 0 @@ -678,15 +691,33 @@ Partial Class Inventarios_TraspasoAlmacen 'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN Dim ErrorExistencia = False + Dim Serie, Lote As String + Dim CveSeccionAlmacen As Integer + Dim FechaCaducidad As Date + Dim TextoExistencia As StringBuilder = New StringBuilder Dim Existencia As Double - TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:
") + Dim CantidadenGrid As Decimal + TextoExistencia.Append("Los siguiente productos se ajustaron por falta de existencia:
") If Not CargadoDeMov Then For Each dr As DataRow In DtMovimientos.Rows - 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"), Serie:=If(dr("Serie").ToString = "", "-1", dr("Serie").ToString), PendientePorSurtir:=1) - Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("Serie").ToString <> "-1", $" AND Serie = '{dr("Serie").ToString}'", "")}") + CveSeccionAlmacen = If(dr("CveSeccionAlmacen").ToString = "", -1, dr("CveSeccionAlmacen").ToString.ToEntero) + Serie = If(dr("Serie").ToString = "", "-1", dr("Serie").ToString) + Lote = If(dr("Lote").ToString = "", "-1", dr("Lote").ToString) + FechaCaducidad = If(dr("FechaCaducidad").ToString = "", MinFecha, dr("FechaCaducidad").ToString.ToDate) + + Dim ExistenciaEspecificada As Decimal = 0 + CantidadenGrid = DtMovimientos.SUMD("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("Serie").ToString <> "-1", $" AND Serie = '{dr("Serie").ToString}'", "")}") + 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) + Existencia = ExistenciaEspecificada - CantidadenGrid + End If If Existencia < 0 Then ErrorExistencia = True @@ -701,7 +732,12 @@ Partial Class Inventarios_TraspasoAlmacen Next Else For Each gvr As GridViewRow In GvDatos.Rows - 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"), Serie:=If(gvr.DataKey("Serie").ToString = "", "-1", gvr.DataKey("Serie").ToString), PendientePorSurtir:=1) + CveSeccionAlmacen = If(gvr.DataKey("CveSeccionAlmacen") = "", -1, gvr.DataKey("CveSeccionAlmacen").ToEntero) + Serie = If(gvr.DataKey("Serie") = "", "-1", gvr.DataKey("Serie")) + 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) Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero If Existencia < 0 Then ErrorExistencia = True @@ -764,7 +800,7 @@ 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("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").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 @@ -819,7 +855,7 @@ 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("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, 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, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacenDestino").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Observaciones:=Dr("Observaciones").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -1119,35 +1155,33 @@ Partial Class Inventarios_TraspasoAlmacen TxtnLote.Visible = False TxtnFechaCaducidad.Visible = False - EscondeColumnasGVM(DtMovimientos) - If DdlProducto2.SelectedValue.ToEntero > 0 Then Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("", "PS") If drP IsNot Nothing Then - If CBool(drP("AplicaSeccion")) Then - ThSeccionAlmacen.Visible = True - TdSeccionAlmacen.Visible = True - DdlSeccionAlmacen.Visible = True - GvDatos.Columns(5).Visible = True - End If - If CBool(drP("AplicaSerie")) Then - ThSerie.Visible = True - TdSerie.Visible = True - TxtnSerie.Visible = True - GvDatos.Columns(6).Visible = True - End If - If CBool(drP("AplicaLote")) Then - TxtnLote.Visible = True - ThLote.Visible = True - TdLote.Visible = True - GvDatos.Columns(7).Visible = True - End If - If CBool(drP("AplicaCaducidad")) Then - TxtnFechaCaducidad.Visible = True - ThFechaCaducidad.Visible = True - TdFechaCaducidad.Visible = True - GvDatos.Columns(8).Visible = True - End If + + ThSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + TdSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + DdlSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + 'GvDatos.Columns(5).Visible = CBool(drP("AplicaSeccion")) + + + ThSerie.Visible = CBool(drP("AplicaSerie")) + TdSerie.Visible = CBool(drP("AplicaSerie")) + TxtnSerie.Visible = CBool(drP("AplicaSerie")) + 'GvDatos.Columns(6).Visible = CBool(drP("AplicaSerie")) + + + TxtnLote.Visible = CBool(drP("AplicaLote")) + ThLote.Visible = CBool(drP("AplicaLote")) + TdLote.Visible = CBool(drP("AplicaLote")) + 'GvDatos.Columns(7).Visible = CBool(drP("AplicaLote")) + + + TxtnFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + ThFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + TdFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + 'GvDatos.Columns(8).Visible = CBool(drP("AplicaCaducidad")) + End If End If @@ -1193,44 +1227,54 @@ Partial Class Inventarios_TraspasoAlmacen End Sub Private Sub EscondeColumnasGVM(DtTemp As DataTable) - TxtnSerie.Visible = False - ThSerie.Visible = False - TdSerie.Visible = False - GvDatos.Columns(5).Visible = False - TxtnLote.Visible = False - ThLote.Visible = False - TdLote.Visible = False - GvDatos.Columns(6).Visible = False + GvDatos.Columns(5).Visible = DtTemp.MAX("Serie").ToString <> "" + GvDatos.Columns(6).Visible = DtTemp.MAX("Lote").ToString <> "" + GvDatos.Columns(7).Visible = DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha + GvDatos.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0 - TxtnFechaCaducidad.Visible = False - ThFechaCaducidad.Visible = False - TdFechaCaducidad.Visible = False - GvDatos.Columns(7).Visible = False + ''TxtnSerie.Visible = False + ''ThSerie.Visible = False + ''TdSerie.Visible = False + 'GvDatos.Columns(5).Visible = False - If DtTemp.MAX("Serie").ToString <> "" Then - TxtnSerie.Visible = True - ThSerie.Visible = True - TdSerie.Visible = True - GvDatos.Columns(5).Visible = True - End If - If DtTemp.MAX("Lote").ToString <> "" Then - TxtnLote.Visible = True - ThLote.Visible = True - TdLote.Visible = True - GvDatos.Columns(6).Visible = True + 'TxtnLote.Visible = False + 'ThLote.Visible = False + 'TdLote.Visible = False + 'GvDatos.Columns(6).Visible = False + + 'TxtnFechaCaducidad.Visible = False + 'ThFechaCaducidad.Visible = False + 'TdFechaCaducidad.Visible = False + 'GvDatos.Columns(7).Visible = False + + + 'If DtTemp.MAX("Serie").ToString <> "" Then + ' TxtnSerie.Visible = True + ' ThSerie.Visible = True + ' TdSerie.Visible = True + ' GvDatos.Columns(5).Visible = True + 'End If + 'If DtTemp.MAX("Lote").ToString <> "" Then + ' TxtnLote.Visible = True + ' ThLote.Visible = True + ' TdLote.Visible = True + ' GvDatos.Columns(6).Visible = True + 'End If + 'If DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha Then + ' TxtnFechaCaducidad.Visible = True + ' ThFechaCaducidad.Visible = True + ' TdFechaCaducidad.Visible = True + ' GvDatos.Columns(7).Visible = True + + 'End If - TxtnFechaCaducidad.Visible = True - ThFechaCaducidad.Visible = True - TdFechaCaducidad.Visible = True - GvDatos.Columns(7).Visible = True - End If End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then + If e.Row.DBCampo("EstatusExistencia").ToEntero <0 Then e.Row.Cells(0).BackColor = Drawing.Color.Red End If @@ -1399,6 +1443,11 @@ Partial Class Inventarios_TraspasoAlmacen If Dtt IsNot Nothing Then GvDatosRecepcion.DataSource = Dtt GvDatosRecepcion.DataBind() + + GvDatosRecepcion.Columns(6).Visible = Dtt.MAX("Serie") <> "" + GvDatosRecepcion.Columns(7).Visible = Dtt.MAX("Lote") <> "" + GvDatosRecepcion.Columns(8).Visible = Dtt.MAX("FechaCaducidad") <> "" + GvDatosRecepcion.Columns(9).Visible = Dtt.MAX("Serie") <> "" 'Dt.Dispose() End If @@ -1447,6 +1496,12 @@ Partial Class Inventarios_TraspasoAlmacen Else e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("ValidaCantidad(this,{0});", e.Row.DBCampo("Cantidad"))) + If CBool(e.Row.DBCampo("AplicaSeccion")) AndAlso DdlAlmacenRecepcion.SelectedValue.ToEntero > 0 Then + e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True + e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenRecepcion.SelectedValue.ToEntero) + e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() + e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) + End If End If 'FUNCIONALIDAD PISTOLA DE CODIGOS @@ -1695,7 +1750,7 @@ 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, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) 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, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For