diff --git a/Contratos/Contrato.aspx.vb b/Contratos/Contrato.aspx.vb index 340a60c83..997006474 100644 --- a/Contratos/Contrato.aspx.vb +++ b/Contratos/Contrato.aspx.vb @@ -1201,7 +1201,7 @@ Partial Class Contratos_Default If DdlMoneda.SelectedIndex > 0 Then If TxtTipoCambio.Text.Trim.Length = 0 Or TxtTipoCambio.Text.Trim.ToDouble = 0.0 Then - Alert("Cuando seleccione una moneda diferencte a peso debe especificar el tipo de cambio.", TipoMensaje.MsgAdvertencia) + Alert("Cuando seleccione una moneda diferente a peso debe especificar el tipo de cambio.", TipoMensaje.MsgAdvertencia) Exit Sub End If End If diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx index e95b81ae4..55801e46e 100644 --- a/Inventarios/EntradasSalidas.aspx +++ b/Inventarios/EntradasSalidas.aspx @@ -542,99 +542,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#CantClasificación
- Producto
U.M.P.U.TotalPU ExtranCIActivo Fijo - Serie - LoteLoteBatchSección AlmacénObservaciones
- - - - - - - -
-
- - - -
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+ +
+
+
@@ -649,7 +562,7 @@
+ + + - <%--SECCION DE ALMACEN--%> - + diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 595bb902b..4d6fc54de 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -204,14 +204,6 @@ Partial Class Inventarios_EntradasSalidas 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) @@ -261,6 +253,23 @@ Partial Class Inventarios_EntradasSalidas End Set End Property + Public Property CveMovimientoDetalleEdit() As Integer + Get + Return ViewState("CveMovimientoDetalleEdit").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMovimientoDetalleEdit") = value + End Set + End Property + Public Property CveAFEdit() As Integer + Get + Return ViewState("CveAFEdit").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveAFEdit") = value + End Set + End Property + #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -279,13 +288,11 @@ Partial Class Inventarios_EntradasSalidas CargaCombos() TxtFecha.Text = Now.ToShortDateString RVFecha.MaximumValue = Now.ToShortDateString - InicializaClientes() + CantidadTotal = 0 IndexSeccionAlmacen = 0 Tipo = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() 'si viene una parámetro para cargar un movimiento lo hacemos dentro del procedimiento cargadatos Select Case UsuarioActual.Empresa.Funcionalidad(103) @@ -315,6 +322,7 @@ Partial Class Inventarios_EntradasSalidas End If End If + InicializaClientes() InicializaBitacoraTemporal() If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then @@ -325,9 +333,6 @@ Partial Class Inventarios_EntradasSalidas ActivaConsumoInterno() End If - 'SECCION ALMACEN EXISTENCIAS - GvM.Columns(14).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" AndAlso Not CveMovimiento > 0 - 'BLOQUEA PERMISOS BtnGuardar.Enabled = PermiteGuardar() BtnEliminar.Enabled = PermiteEliminar() @@ -361,14 +366,14 @@ Partial Class Inventarios_EntradasSalidas Return If(UsuarioActual.TienePermisoProceso(184) Or EsConsumoInterno, True, False) End Function Private Sub ActivaPermisoSeccionAlmacen() - GvM.Columns(12).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - TrSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - TrSeccionAlmacen2.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + If CveMovimiento <= 0 Then + GvM.Columns(11).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + End If End Sub Private Sub PermisoVerImportes() Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - tdPU.Visible = TienePermisoImportes - tdTxtPU.Visible = TienePermisoImportes + ' tdPU.Visible = TienePermisoImportes + ' tdTxtPU.Visible = TienePermisoImportes GvM.Columns(4).Visible = TienePermisoImportes ThTotal.Visible = TienePermisoImportes @@ -432,7 +437,7 @@ Partial Class Inventarios_EntradasSalidas dt.Columns.Add("CveAF") dt.Columns.Add("SerieLote", Type.GetType("System.String")) dt.Columns.Add("Lote", Type.GetType("System.String")) - dt.Columns.Add("Batch", Type.GetType("System.String")) + dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime")) dt.Columns.Add("Observaciones") dt.Columns.Add("CountMovimientoEntradaDetalle") @@ -458,11 +463,11 @@ Partial Class Inventarios_EntradasSalidas End If DdlClasificacion.DataBind() - DdlSeccion.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccion.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) DdlSeccion.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlSeccion.DataBind() - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) DdlSeccionAlmacen.DataBind() 'Llenar el dropdownlist de monedas @@ -773,7 +778,7 @@ Partial Class Inventarios_EntradasSalidas 'Carga Cliente y ClienteSucursal If Mov.CveCliente > 0 Then If DdlClientes.Items.FindByValue(Mov.CveCliente.ToString()) Is Nothing Then - Dim dr As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Mov.CveCliente)) + Dim dr As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=Mov.CveCliente).FiltroPrimero("") If dr IsNot Nothing Then DdlClientes.Items.Insert(0, New ListItem(dr("NombreComercial").ToString, dr("CveCliente").ToString)) End If @@ -810,6 +815,13 @@ Partial Class Inventarios_EntradasSalidas TxtPedidoContrato.Enabled = False TxtPedidoContrato.Text = Mov.PedidoContrato + If Mov.CveProveedor > 0 Then + DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa, Mov.CveProveedor) + DdlProveedor.DataBind() + DdlProveedor.SelectedValueExist(Mov.CveProveedor) + DdlProveedor.Enabled = False + TrProveedor.Visible = True + End If 'cargar también los movimentos detalle If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then @@ -830,13 +842,7 @@ Partial Class Inventarios_EntradasSalidas PermisoVerImportes() - If DtMov.Rows(0)("CveProveedor").ToString.ToEntero > 0 Then - DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - DdlProveedor.DataBind() - DdlProveedor.SelectedValueExist(DtMov.Rows(0)("CveProveedor").ToString) - DdlProveedor.Enabled = False - TrProveedor.Visible = True - End If + Else Alert("Movimiento No encontrado", TipoMensaje.MsgError) @@ -1014,7 +1020,6 @@ Partial Class Inventarios_EntradasSalidas DdlClasificacion.SelectedValue = "-1" txtCantidad.Text = "" TxtnLote.Text = "" - TxtnBatch.Text = "" TxtObservacionesdetalle.Text = "" End Sub @@ -1131,16 +1136,16 @@ Partial Class Inventarios_EntradasSalidas #Region " AGREGAR - GUARDAR " - Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Double + Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional Serie As String = "-1", Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha) As Double Dim Inv As New ClsInventarios - Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, -1, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch) + Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, CveSeccionAlmacen:=CveSeccionAlmacen, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Inv.Dispose() Return Existencia End Function - Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click - AgregarPS() - End Sub + 'Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + ' AgregarPS() + 'End Sub Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) AgregarPS() End Sub @@ -1151,14 +1156,13 @@ Partial Class Inventarios_EntradasSalidas Exit Sub End If - AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedText, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDouble, txtPrecio.Text.ToDouble, TxtnSerieLote.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text, TxtnLote.Text.Trim, TxtnBatch.Text.Trim, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text) + AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedText, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDouble, txtPrecio.Text.ToDouble, TxtnSerie.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text, TxtnLote.Text.Trim, MinFecha, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text) LimpiarAgregar() txtCantidad.Text = "" TxtnLote.Text = "" - TxtnBatch.Text = "" LblCodigo.Text = "" - TxtnSerieLote.Text = "" + TxtnSerie.Text = "" HdnCodigoAF.Value = "-1" HdnCveActivoFijo.Value = "-1" RegistraScript("CodigoAF = "";") @@ -1174,7 +1178,7 @@ Partial Class Inventarios_EntradasSalidas End Sub - Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Double, PU As Double, SerieLote As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, Batch As String, CveSeccionAlmacen As Integer, SeccionAlmacen As String) + Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Double, PU As Double, SerieLote As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, FechaCaducidad As Date, CveSeccionAlmacen As Integer, SeccionAlmacen As String) If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlProducto2.SelectedText = "" : Exit Sub Dim Valido As Boolean = True @@ -1191,9 +1195,9 @@ Partial Class Inventarios_EntradasSalidas 'salida If Valido AndAlso DdlConcepto.SelectedValue.Contiene({"3", "5", "7", "8", "11", "12", "13", "15", "16", "17", "20", "21", "30", "31"}) Then ' salida de almacen - Dim Existencia As Double = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(SerieLote = "", "-1", SerieLote), If(Lote = "", "-1", Lote), If(Batch = "", "-1", Batch)) - LbAgregar.ToolTip = Existencia.ToString - If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(SerieLote <> "", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then + Dim Existencia As Double = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, -1, If(SerieLote = "", "-1", SerieLote), If(Lote = "", "-1", Lote), FechaCaducidad) + ' LbAgregar.ToolTip = Existencia.ToString + If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(SerieLote <> "", $" AND Serie = '{SerieLote}'", "")}") < 0 Then If Existencia <= 0 Then Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") @@ -1242,7 +1246,7 @@ Partial Class Inventarios_EntradasSalidas registro.Item("CveAF") = CveAF registro.Item("SerieLote") = If(SerieLote <> "", SerieLote, "") registro.Item("Lote") = If(Lote <> "", Lote, "") - registro.Item("Batch") = If(Batch <> "", Batch, "") + registro.Item("FechaCaducidad") = FechaCaducidad registro.Item("Observaciones") = Observaciones DtMovimientos.Rows.Add(registro) CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) @@ -1330,14 +1334,14 @@ Partial Class Inventarios_EntradasSalidas Else If GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows.Count > 0 AndAlso GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows(0)("Origen").ToString.ToEntero < 0 Then - If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=If(Dr("Serie").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString)) >= Dr("Cantidad").ToString.ToDouble Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al Agregar los nuevos movimientos" ErrorMovInv = True : Exit For End If Else If UsuarioActual.TienePermisoProceso(114) Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("SerieLote").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al Agregar los nuevos movimientos" ErrorMovInv = True : Exit For End If @@ -1347,7 +1351,7 @@ Partial Class Inventarios_EntradasSalidas End If End If Else - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al Agregar los nuevos movimientos" ErrorMovInv = True : Exit For End If @@ -1438,13 +1442,6 @@ Partial Class Inventarios_EntradasSalidas End If Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad") - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then - ObjInventario.RollBack() - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/ES", 53, 0, 0, 1, TxtFecha.Text.ToDate, obs, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text, PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor) @@ -1461,40 +1458,40 @@ Partial Class Inventarios_EntradasSalidas Dim Cont As Integer = 0 If DdlConcepto.SelectedValue.Contiene({"3", "11", "13", "21", "30", "31"}) Then For Each Dr As DataRow In DtMovimientos.Rows - If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then + If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=If(Dr("Serie").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) >= Dr("Cantidad").ToString.ToDouble Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al guardar los movimientos" ErrorMovInv = True Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If + 'Else + 'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + ' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows + ' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then + ' ErrorMovInv = True + ' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + ' Exit For + ' End If + ' Next + 'End If End If Else If UsuarioActual.TienePermisoProceso(114) Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 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, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al guardar los movimientos" ErrorMovInv = True Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If + 'Else + 'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + ' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows + ' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then + ' ErrorMovInv = True + ' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + ' Exit For + ' End If + ' Next + 'End If End If Else Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS")) @@ -1515,20 +1512,20 @@ Partial Class Inventarios_EntradasSalidas ImporteConcepto = Dr("PU").ToString.ToDecimal End If - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then Mensaje = "Error al guardar los movimientos" ErrorMovInv = True Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If + 'Else + ' If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + ' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows + ' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then + ' ErrorMovInv = True + ' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + ' Exit For + ' End If + ' Next + ' End If End If Cont += 1 Next @@ -1767,7 +1764,7 @@ Partial Class Inventarios_EntradasSalidas Else LimpiarMovimiento() End If - DtSeccionAlmacen.Rows.Clear() + RegistraScript("playsonidito('beep-07.wav')") Else ObjInventario.RollBack() @@ -1891,7 +1888,7 @@ Partial Class Inventarios_EntradasSalidas CveMovimiento = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, TxtFecha.Text.ToDate, TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) End If - ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, SerieLote:=SerieLote) + ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, Serie:=SerieLote) ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) DtMovimientos = ObjInv.DtResultados.FiltraParametros("", "CveMovimientoDetalle DESC").AsEnumerable.Take(25).CopyToDataTable ObjInv.Dispose() @@ -2083,8 +2080,8 @@ Partial Class Inventarios_EntradasSalidas End Sub Private Sub VisualizaPU(Opcion As Boolean) - tdPU.Visible = Opcion - tdTxtPU.Visible = Opcion + 'tdPU.Visible = Opcion + 'tdTxtPU.Visible = Opcion txtPrecio.Visible = Opcion GvM.Columns(4).Visible = Opcion @@ -2142,30 +2139,34 @@ Partial Class Inventarios_EntradasSalidas ElProductoChange() End Sub Private Sub ElProductoChange() - TxtnSerieLote.Visible = False + TxtnSerie.Visible = False + divSerie.Visible = False + TxtnLote.Visible = False - TxtnBatch.Visible = False + divLote.Visible = False 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 - LblSerieLote.Visible = True - TxtnSerieLote.Visible = True - TrSerieLote.Visible = True - TrSerieLote2.Visible = True + + 'LblSerieLote.Visible = True + TxtnSerie.Visible = True + divSerie.Visible = True + + 'TrSerieLote.Visible = True + 'TrSerieLote2.Visible = True GvM.Columns(9).Visible = True End If If MetodoInventario = 6 Then TxtnLote.Visible = True - TrLote.Visible = True - TrLote2.Visible = True + divLote.Visible = True + 'TrLote.Visible = True + 'TrLote2.Visible = True GvM.Columns(10).Visible = True - TxtnBatch.Visible = True - TrBatch.Visible = True - TrBatch2.Visible = True + 'TrBatch2.Visible = True GvM.Columns(11).Visible = True End If End If @@ -2186,10 +2187,10 @@ Partial Class Inventarios_EntradasSalidas EscondeColumnasGVM(DtTemp) End Sub Private Sub EscondeColumnasGVM(DtTemp As DataTable) - LblSerieLote.Visible = False - TxtnSerieLote.Visible = False - TrSerieLote.Visible = False - TrSerieLote2.Visible = False + 'LblSerie.Visible = False + TxtnSerie.Visible = False + 'TrSerieLote.Visible = False + 'TrSerieLote2.Visible = False GvM.Columns(9).Visible = False 'PERMISO SOLO PARA EDITAR SERIELOTE @@ -2198,14 +2199,14 @@ Partial Class Inventarios_EntradasSalidas End If TxtnLote.Visible = False - TrLote.Visible = False - TrLote2.Visible = False + 'TrLote.Visible = False + 'TrLote2.Visible = False GvM.Columns(10).Visible = False - TxtnBatch.Visible = False - TrBatch.Visible = False - TrBatch2.Visible = False - GvM.Columns(11).Visible = False + 'TxtnBatch.Visible = False + 'TrBatch.Visible = False + 'TrBatch2.Visible = False + 'GvM.Columns(11).Visible = False Dim TienePermisoImportes = UsuarioActual.TienePermisoProceso(201) tdPUExtranjero.Visible = False @@ -2216,38 +2217,57 @@ Partial Class Inventarios_EntradasSalidas tdCI2.Visible = False GvM.Columns(7).Visible = False + If DtTemp.SUM("PUExtranjero") > 0 Then + tdPUExtranjero.Visible = TienePermisoImportes + tdPUExtranjero2.Visible = TienePermisoImportes + GvM.Columns(6).Visible = TienePermisoImportes + End If + + If DtTemp.SUM("CostoIndirecto") > 0 Then + tdCI.Visible = TienePermisoImportes + tdCI2.Visible = TienePermisoImportes + GvM.Columns(7).Visible = TienePermisoImportes + End If + If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then - If DtTemp.MAX("SerieLote").ToString <> "" Then - LblSerieLote.Visible = True - TxtnSerieLote.Visible = True - TrSerieLote.Visible = True - TrSerieLote2.Visible = True + 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 + 'TrLote.Visible = True + 'TrLote2.Visible = True GvM.Columns(10).Visible = True - TxtnBatch.Visible = True - TrBatch.Visible = True - TrBatch2.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.SUM("PUExtranjero") > 0 Then - tdPUExtranjero.Visible = TienePermisoImportes - tdPUExtranjero2.Visible = TienePermisoImportes - GvM.Columns(6).Visible = TienePermisoImportes + + + If DtTemp.MAX("CveSeccionAlmacen").ToString <> "" Then + 'TxtnBatch.Visible = True + 'TrBatch.Visible = True + 'TrBatch2.Visible = True + GvM.Columns(12).Visible = True End If - If DtTemp.SUM("CostoIndirecto") > 0 Then - tdCI.Visible = TienePermisoImportes - tdCI2.Visible = TienePermisoImportes - GvM.Columns(7).Visible = TienePermisoImportes - End If End If End Sub @@ -2280,18 +2300,18 @@ Partial Class Inventarios_EntradasSalidas e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onblur", String.Format("AFBlurEdit(this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID)) e.Row.FCImage("ImgAF").Attributes.Add("onclick", String.Format("AbrirVentana('/AF/PopUpBuscarAF.aspx?OPCION=OCE&RI={0}',950,600,'N');", e.Row.RowIndex)) - If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then - e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() - e.Row.FCDropDownList("DdlSeccionAlmacen").SelectedValueExist(e.Row.DBCampo("CveSeccionAlmacen")) - End If + 'If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then + ' e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) + ' e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() + ' e.Row.FCDropDownList("DdlSeccionAlmacen").SelectedValueExist(e.Row.DBCampo("CveSeccionAlmacen")) + 'End If 'PERMISO SOLO PARA EDITAR OBSERVACIONES If PermiteGuardarObservacionDetalle() Then e.Row.FCTextBox("txtPrecio").Enabled = False e.Row.FCTextBox("LblEditCodigo").Enabled = False - e.Row.FCTextBox("TxtSerieLote").Enabled = False + e.Row.FCTextBox("TxtSerie").Enabled = False e.Row.FCTextBox("TxtLote").Enabled = False e.Row.FCTextBox("TxtBatch").Enabled = False e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False @@ -2302,13 +2322,12 @@ Partial Class Inventarios_EntradasSalidas If (CveMovimiento > 0) Or (TieneRelacionado > 0 Or CveMovimientoRelacionado > 0) Then 'CveMovimiento > 0 And e.Row.DBCampo("TienePrePoliza").ToEntero > 0 e.Row.FCTextBox("txtPrecio").Enabled = False e.Row.FCTextBox("LblEditCodigo").Enabled = False - e.Row.FCTextBox("TxtSerieLote").Enabled = False + e.Row.FCTextBox("TxtSerie").Enabled = False e.Row.FCTextBox("TxtLote").Enabled = False - e.Row.FCTextBox("TxtBatch").Enabled = False e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False e.Row.FCTextBox("txtPrecio").Enabled = False End If - e.Row.FCTextBox("TxtSerieLote").Enabled = True + e.Row.FCTextBox("TxtSerie").Enabled = True End If If EsNuevoMov Then @@ -2362,22 +2381,58 @@ Partial Class Inventarios_EntradasSalidas End If End If - If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then - e.Row.FCLinkButton("imgE").Visible = False - e.Row.FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - e.Row.FCLinkButton("lnkDividir").Visible = False - e.Row.FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" - End If End If End Sub Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing GvM.EditIndex = e.NewEditIndex - + Dim Gv As GridView = DirectCast(sender, GridView) + Dim GvRow As GridViewRow = Gv.Rows(0) + If CveMovimiento > 0 Then + CveMovimientoDetalleEdit = GvRow.DataKey("CveMovimientoDetalle").ToEntero + divCantidad.Visible = False + divClasificacionProducto.Visible = False + divUnidadMedida.Visible = False + End If + txtCantidad.Text = GvRow.DataKey("Cantidad").ToEntero().ToString + DdlProducto2.SelectedValue = GvRow.DataKey("CvePS") + DdlProducto2.SelectedText = GvRow.DataKey("CodigoPS") + ElProductoChange() + DdlUnidad.SelectedValue = GvRow.DataKey("CveUM") + CveAFEdit = GvRow.DataKey("CveAF").ToEntero + txtPrecio.Text = GvRow.DataKey("PU").ToDouble.FormatoNumero + TxtnSerie.Text = GvRow.DataKey("Serie") + TxtObservacionesdetalle.Text = GvRow.DataKey("Observaciones") + DdlSeccionAlmacen.SelectedValueExist(GvRow.DataKey("CveSeccionAlmacen")) + LkAgregarDetalle.Text = "Actualizar" + UpAgregar.Update() + RegistraScript("$('#ModalAgregar').modal()") CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) End Sub + Protected Sub EditPS(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + If CveMovimiento > 0 Then + CveMovimientoDetalleEdit = GvRow.DataKey("CveMovimientoDetalle").ToEntero + divCantidad.Visible = False + divClasificacionProducto.Visible = False + divUnidadMedida.Visible = False + End If + txtCantidad.Text = GvRow.DataKey("Cantidad").ToEntero().ToString + DdlProducto2.SelectedValue = GvRow.DataKey("CvePS") + DdlProducto2.SelectedText = GvRow.DataKey("CodigoPS") + ElProductoChange() + DdlUnidad.SelectedValue = GvRow.DataKey("CveUM") + CveAFEdit = GvRow.DataKey("CveAF").ToEntero + txtPrecio.Text = GvRow.DataKey("PU").ToDouble.FormatoNumero + TxtnSerie.Text = GvRow.DataKey("SerieLote") + TxtObservacionesdetalle.Text = GvRow.DataKey("Observaciones") + DdlSeccionAlmacen.SelectedValueExist(GvRow.DataKey("CveSeccionAlmacen")) + LkAgregarDetalle.Text = "Actualizar" + UpAgregar.Update() + RegistraScript("$('#ModalAgregar').modal()") + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + End Sub + Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit GvM.EditIndex = -1 @@ -2387,7 +2442,7 @@ Partial Class Inventarios_EntradasSalidas Dim Precio As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDouble Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero - Dim serielote As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerieLote").Text.Replace(" ", String.Empty) + Dim serie As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerie").Text.Replace(" ", String.Empty) Dim Observaciones As String = GvM.Rows(e.RowIndex).FCTextBox("TxtObservaciones").Text Dim CveSeccionAlmacen As Integer = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero Dim SeccionAlmacen As String = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedItem.Text @@ -2399,7 +2454,7 @@ Partial Class Inventarios_EntradasSalidas Drs(0)("PU") = Precio Drs(0)("Total") = Drs(0)("Cantidad").ToString.ToDouble * Precio Drs(0)("Estatus") = "U" - Drs(0)("SerieLote") = serielote + Drs(0)("Serie") = serie Drs(0)("Observaciones") = Observaciones Drs(0)("CveSeccionAlmacen") = CveSeccionAlmacen Drs(0)("SeccionAlmacen") = SeccionAlmacen @@ -2591,7 +2646,7 @@ Partial Class Inventarios_EntradasSalidas LblCodigo.Text = HdnCodigoAF.Value End If - LbAgregar.Focus() + 'LbAgregar.Focus() UPDatos.Update() End Sub @@ -2900,7 +2955,7 @@ Partial Class Inventarios_EntradasSalidas Exit Sub End If - AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDouble, "", "", "", "", "", "", "", -1, "") + AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDouble, "", "", "", "", "", "", MinFecha, -1, "") TxtCodigoPS.Text = "" TxtCodigoPS.Focus() @@ -2912,7 +2967,7 @@ Partial Class Inventarios_EntradasSalidas Exit Sub End If - AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", "", -1, "") + AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", MinFecha, -1, "") TdSeriePSAdd.Visible = False TxtSeriePS.Text = "" @@ -3226,7 +3281,7 @@ Partial Class Inventarios_EntradasSalidas #Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED" Private Sub InicializaClientes() - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + If UsuarioActual.CveEmpresa.Contiene(72, 80) AndAlso CveMovimiento <= 0 Then DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) DdlClientes.DataBind() @@ -4021,124 +4076,164 @@ Partial Class Inventarios_EntradasSalidas LnkAgregarNuevoMov.Visible = False End Sub -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + '#Region "SECCION ALMACEN" + ' Private Sub CreaDtSeccionAlmacen() + ' DtSeccionAlmacen = New DataTable + ' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) + ' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) + ' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer)) + ' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String)) + ' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + ' End Sub + ' Private Sub CargaDdlAlmacen() + ' DdlSeccionAlmacenModal.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) + ' DdlSeccionAlmacenModal.Items.Insert(0, New ListItem("Seleccione", "-1")) + ' DdlSeccionAlmacenModal.DataBind() + ' End Sub + ' Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) + ' If Not DdlConcepto.SelectedValue.ToEntero > 0 Then + ' Alert("Tiene que seleccionar un concepto", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + ' Tipo = GlobalDTInvConceptos().FiltroPrimeroValor("Origen", $"CveConcepto = {DdlConcepto.SelectedValue}").ToEntero + ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + ' CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal + ' IndexSeccionAlmacen = gvRow.RowIndex + ' CargaSeccionAlmacen() + ' RegistraScript("$('#DModalSeccionAlmacen').modal()") + ' End Sub + + ' Private Sub CargaSeccionAlmacen() + ' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + ' GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") + ' GvSeccionAlmacen.DataBind() + + ' TxtCantidadSeccion.Text = "" + ' DdlSeccionAlmacenModal.SelectedIndex = 0 + ' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion + ' If CantidadRestante = 0 Then + ' RVTxtCantidad.MaximumValue = "1" + ' TxtCantidadSeccion.Enabled = False + ' Else + ' RVTxtCantidad.MaximumValue = CantidadRestante.ToString + ' TxtCantidadSeccion.Enabled = True + ' End If + + ' If CantidadTotalSeccion > 0 Then + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = False + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = False + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" + ' Else + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = True + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "" + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = True + ' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "" + ' End If + + ' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 AndAlso Tipo = -1 Then + ' DdlAlmacen.Enabled = False + ' DdlAlmacen.ToolTip = "Cuenta con sección almacen" + ' Else + ' DdlAlmacen.Enabled = True + ' DdlAlmacen.ToolTip = "" + ' End If + + ' UpModalSeccionAlmacen.Update() + ' UppGrid.Update() + ' End Sub + + ' Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + ' If Tipo = -1 Then + ' Dim ObjInv As New ClsInventarios + ' Dim CantidadDisponible As Decimal = 0 + ' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenModal.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, + ' CvePS, UsuarioActual.CveEmpresa) Then + ' If ObjInv.DtResultados.Rows.Count > 0 Then + ' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal + ' End If + ' End If + ' ObjInv.Dispose() + + ' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacenModal.SelectedValue}").SUMD("CantidadSeccionAlmacen") + + ' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then + ' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + ' End If + + ' Dim Row As DataRow = Nothing + ' DtSeccionAlmacen.AcceptChanges() + ' Row = DtSeccionAlmacen.NewRow + ' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal + ' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen + ' Row("CveSeccionAlmacen") = DdlSeccionAlmacenModal.SelectedValue.ToEntero + ' Row("SeccionAlmacen") = DdlSeccionAlmacenModal.SelectedItem.Text + ' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 + ' DtSeccionAlmacen.Rows.Add(Row) + ' DtSeccionAlmacen.AcceptChanges() + ' CargaSeccionAlmacen() + ' End Sub + + ' Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) + ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + ' Dim Index As Integer = 0 + ' For Each Dr As DataRow In DtSeccionAlmacen.Rows + ' If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then + ' Exit For + ' End If + ' Index += 1 + ' Next + ' DtSeccionAlmacen.Rows.RemoveAt(Index) + ' DtSeccionAlmacen.AcceptChanges() + ' CargaSeccionAlmacen() + ' End Sub + + '#End Region + + Protected Sub LkAgregar_Click() Handles LkAgregar.Click + limpiarModalDetalle() + UpAgregar.Update() + RegistraScript("$('#ModalAgregar').modal()") End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacenModal.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenModal.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenModal.DataBind() - End Sub - Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - If Not DdlConcepto.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un concepto", TipoMensaje.MsgAdvertencia) - Exit Sub + + Private Sub ActualizarPS() + Dim ObjInventario As New ClsInventarios + If Not ObjInventario.UpdateMovimientoDetalle(txtCantidad.Text.ToDouble, DdlUnidad.ToEntero, DdlProducto2.SelectedValue.ToEntero, txtPrecio.Text.ToDouble, CveAFEdit, + CveMovimientoDetalleEdit, DdlSeccionAlmacen.SelectedValue.ToEntero, TxtnSerie.Text, TxtObservacionesdetalle.Text, + CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Alert("Error al Actualizar los movimientos") End If - Tipo = GlobalDTInvConceptos().FiltroPrimeroValor("Origen", $"CveConcepto = {DdlConcepto.SelectedValue}").ToEntero - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") + ObjInventario.Dispose() End Sub - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") - GvSeccionAlmacen.DataBind() + Private Sub limpiarModalDetalle() - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenModal.SelectedIndex = 0 - Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion - If CantidadRestante = 0 Then - RVTxtCantidad.MaximumValue = "1" - TxtCantidadSeccion.Enabled = False + divCantidad.Visible = True + divClasificacionProducto.Visible = True + divUnidadMedida.Visible = True + txtCantidad.Text = "" + DdlProducto2.SelectedValue = "-1" + DdlProducto2.SelectedText = "" + ElProductoChange() + txtPrecio.Text = "" + TxtnSerie.Text = "" + TxtObservacionesdetalle.Text = "" + DdlSeccionAlmacen.SelectedValue = "-1" + LkAgregarDetalle.Text = "Agregar" + If DdlMonedaTC.SelectedValue.ToEntero = 2 Then + VisualizaPUExtranjero(UsuarioActual.TienePermisoProceso(201)) Else - RVTxtCantidad.MaximumValue = CantidadRestante.ToString - TxtCantidadSeccion.Enabled = True + VisualizaPUExtranjero(False) End If - If CantidadTotalSeccion > 0 Then - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" - Else - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "" - End If - - If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 AndAlso Tipo = -1 Then - DdlAlmacen.Enabled = False - DdlAlmacen.ToolTip = "Cuenta con sección almacen" - Else - DdlAlmacen.Enabled = True - DdlAlmacen.ToolTip = "" - End If - - UpModalSeccionAlmacen.Update() - UppGrid.Update() + UpAgregar.Update() End Sub - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - If Tipo = -1 Then - Dim ObjInv As New ClsInventarios - Dim CantidadDisponible As Decimal = 0 - If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenModal.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, - CvePS, UsuarioActual.CveEmpresa) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal - End If - End If - ObjInv.Dispose() - - CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacenModal.SelectedValue}").SUMD("CantidadSeccionAlmacen") - - If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then - Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Dim Row As DataRow = Nothing - DtSeccionAlmacen.AcceptChanges() - Row = DtSeccionAlmacen.NewRow - Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - Row("IndexSeccionAlmacen") = IndexSeccionAlmacen - Row("CveSeccionAlmacen") = DdlSeccionAlmacenModal.SelectedValue.ToEntero - Row("SeccionAlmacen") = DdlSeccionAlmacenModal.SelectedItem.Text - Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - DtSeccionAlmacen.Rows.Add(Row) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - - Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim Index As Integer = 0 - For Each Dr As DataRow In DtSeccionAlmacen.Rows - If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then - Exit For - End If - Index += 1 - Next - DtSeccionAlmacen.Rows.RemoveAt(Index) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - -#End Region End Class