diff --git a/Inventarios/AjustesSeccionAlmacen.aspx b/Inventarios/AjustesSeccionAlmacen.aspx index 795fb5427..c54c8728c 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx +++ b/Inventarios/AjustesSeccionAlmacen.aspx @@ -60,7 +60,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb index db2791104..ec0aeb1f9 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx.vb +++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb @@ -184,28 +184,32 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim ErrorArchivo = False If Not ErrorArchivo AndAlso DtExcel IsNot Nothing Then - If Not DtExcel.Columns(0).ColumnName = "Código" Then + If Not DtExcel.Columns(0).ColumnName = "Cantidad" Then + Alert("El nombre de la primera columna debe ser 'Código'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not DtExcel.Columns(1).ColumnName = "Código" Then Alert("El nombre de la segunda columna debe ser 'Código'.Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not DtExcel.Columns(1).ColumnName = "Producto/Servicio" Then - Alert("El nombre de la cuarta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError) + If Not DtExcel.Columns(2).ColumnName = "Producto/Servicio" Then + Alert("El nombre de la tercera columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not DtExcel.Columns(2).ColumnName = "SeccionAlmacen" Then - Alert("El nombre de la quinta columna debe ser 'SeccionAlmacen'. Favor de corregirlo", TipoMensaje.MsgError) + If Not DtExcel.Columns(3).ColumnName = "SeccionAlmacen" Then + Alert("El nombre de la cuarta columna debe ser 'SeccionAlmacen'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not DtExcel.Columns(3).ColumnName = "Serie" Then - Alert("El nombre de la sexta columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError) + If Not DtExcel.Columns(4).ColumnName = "Serie" Then + Alert("El nombre de la quinta columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not DtExcel.Columns(4).ColumnName = "Lote" Then - Alert("El nombre de la séptima columna debe ser 'Lote'. Favor de corregirlo", TipoMensaje.MsgError) + If Not DtExcel.Columns(5).ColumnName = "Lote" Then + Alert("El nombre de la sexta columna debe ser 'Lote'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not DtExcel.Columns(5).ColumnName = "FechaCaducidad" Then - Alert("El nombre de la octava columna debe ser 'FechaCaducidad'. Favor de corregirlo", TipoMensaje.MsgError) + If Not DtExcel.Columns(6).ColumnName = "FechaCaducidad" Then + Alert("El nombre de la séptima columna debe ser 'FechaCaducidad'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If @@ -239,17 +243,21 @@ Partial Class Inventarios_AjustesSeccionAlmacen For Each RowExcel As DataRow In DtExcel.Rows - Dim Codigo As String = RowExcel("Código").ToString.Trim - Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, Codigo:=Codigo).Rows(0) + Dim Codigo As String = RowExcel("Código").ToString.Trim() + Dim PS As String = RowExcel("Producto/Servicio").ToString().Trim() + + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, Codigo:=Codigo).FiltroPrimero($"PS='{PS}'") If DrPS IsNot Nothing Then If Not ErrorMovInv Then + + Dim CantidadEntrada As Decimal = RowExcel("Cantidad").ToString().ToDecimal() + Dim CvePS As Integer = DrPS("CvePS").ToString().ToEntero() Dim CveUM As Integer = DrPS("CveUM").ToString().ToEntero() - Dim ProductoServicio As String = RowExcel("Producto/Servicio").ToString.Trim Dim SeccionAlmacen As String = RowExcel("SeccionAlmacen").ToString.Trim - Dim CveSeccionAlmacen As Integer = dtSecciones.FiltroPrimeroValor("CveSeccion", $"AlmacenSeccion='{SeccionAlmacen}'") + Dim CveSeccionAlmacen As Integer = dtSecciones.FiltroPrimeroValor("CveSeccion", $"SeccionAlmacen='{SeccionAlmacen}'") Dim Serie As String = RowExcel("Serie").ToString() Dim Lote As String = RowExcel("Lote").ToString() @@ -257,47 +265,52 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim RowExistencia As DataRow = DtExistenciasSecciones.FiltroPrimero($"CvePS={CvePS}") - Dim CveSeccionAlmacenSalida As Integer = RowExistencia("CveSeccionAlmacen").ToString().ToEntero() - Dim CantidadSalida As Decimal = RowExistencia("Existencia").ToString().ToDecimal() - Dim SerieSalida As String = RowExistencia("Serie").ToString() - Dim LoteSalida As String = RowExistencia("Lote").ToString() - Dim FechaCaducidadSalida As Date = IfNull(RowExistencia("FechaCaducidad"), MinFecha).ToString.ToDate - Dim PUSalida As Decimal = RowExistencia("PU").ToString() + If RowExistencia IsNot Nothing Then + Dim CveSeccionAlmacenSalida As Integer = RowExistencia("CveSeccionAlmacen").ToString().ToEntero() + Dim CantidadSalida As Decimal = RowExistencia("Existencia").ToString().ToDecimal() + Dim SerieSalida As String = RowExistencia("Serie").ToString() + Dim LoteSalida As String = RowExistencia("Lote").ToString() + Dim FechaCaducidadSalida As Date = IfNull(RowExistencia("FechaCaducidad"), MinFecha).ToString.ToDate + Dim PUSalida As Decimal = RowExistencia("PU").ToString() - 'GENERA LA SALIDA DE LOS PRODUCTOS QUE VIENEN EN EL EXCEL - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadSalida, CveUM, CvePS, PUSalida, CveSeccionAlmacen:=CveSeccionAlmacenSalida, Serie:=SerieSalida, Lote:=LoteSalida, FechaCaducidad:=FechaCaducidadSalida, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - ErrorMovInv = True - Exit For - End If - - Dim CveMovimientoDetalleSalida As Integer = ObjInventario.CveMovimientoDetalle - - ErrorMovInv = CveMovimientoDetalleSalida <= 0 - - 'GENERA LA ENTRADA DE LOS PRODUCTOS QUE SE DIERON ENTRADA - If Not ErrorMovInv Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa, CveMovimientoDetalle:=CveMovimientoDetalleSalida) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - Dim RowEntrada As DataRow = ObjInventario.DtResultados.Rows(0) - - Dim CvePSEntrada = RowEntrada("CvePS").ToString().ToEntero() - Dim CantidadEntrada As Decimal = RowEntrada("Cantidad").ToString().ToDecimal() - Dim PUEntrada As Decimal = RowEntrada("PUOriginal").ToString().ToDecimal() - Dim CveUMEntrada As Integer = RowEntrada("CveUM").ToString().ToEntero() - - Dim CostoIndirecto As Decimal = RowEntrada("CostoIndirecto").ToString().ToDecimal() - - 'ACTUALIZAMOS EL PS, PARA QUE TENGA EL APLICA SECCION - ErrorMovInv = Not ObjPS.UpdateAplicaSeccionAlmacen(CvePS, UsuarioActual.CveEmpresa, True) - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, CantidadEntrada, CveUMEntrada, CvePSEntrada, PUEntrada, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - ErrorMovInv = True - Exit For - End If - - Else + 'GENERA LA SALIDA DE LOS PRODUCTOS QUE VIENEN EN EL EXCEL + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadSalida, CveUM, CvePS, PUSalida, CveSeccionAlmacen:=CveSeccionAlmacenSalida, Serie:=SerieSalida, Lote:=LoteSalida, FechaCaducidad:=FechaCaducidadSalida, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then ErrorMovInv = True + Exit For End If + + Dim CveMovimientoDetalleSalida As Integer = ObjInventario.CveMovimientoDetalle + + ErrorMovInv = CveMovimientoDetalleSalida <= 0 + + 'GENERA LA ENTRADA DE LOS PRODUCTOS QUE SE DIERON ENTRADA + If Not ErrorMovInv Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa, CveMovimientoDetalle:=CveMovimientoDetalleSalida) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim RowEntrada As DataRow = ObjInventario.DtResultados.Rows(0) + + Dim CvePSEntrada = RowEntrada("CvePS").ToString().ToEntero() + Dim PUEntrada As Decimal = RowEntrada("PUOriginal").ToString().ToDecimal() + Dim CveUMEntrada As Integer = RowEntrada("CveUM").ToString().ToEntero() + + Dim CostoIndirecto As Decimal = RowEntrada("CostoIndirecto").ToString().ToDecimal() + + 'ACTUALIZAMOS EL PS, PARA QUE TENGA EL APLICA SECCION + ErrorMovInv = Not ObjPS.UpdateAplicaSeccionAlmacen(CvePS, UsuarioActual.CveEmpresa, True) + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, CantidadEntrada, CveUMEntrada, CvePSEntrada, PUEntrada, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + ErrorMovInv = True + Exit For + End If + + Else + ErrorMovInv = True + End If + End If + Else + ErrorMovInv = True + RowNoEncontrados.AppendFormat("{0},", Codigo) End If + End If Else ErrorMovInv = True