From 0fc5d89d203eb76b501ff42c7e2f3856c678acdb Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 10 Jul 2020 11:33:37 -0700 Subject: [PATCH] Correciones en importar desde excel al hacer ajustes en seccion de almacen --- Inventarios/AjustesSeccionAlmacen.aspx.vb | 55 ++++++++++++++++------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb index e00c268dd..478c321f9 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx.vb +++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb @@ -13,10 +13,12 @@ Partial Class Inventarios_AjustesSeccionAlmacen End Sub Private Sub CargaCombos() - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim DtAlmacenes As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + DdlAlmacen.DataSource = DtAlmacenes DdlAlmacen.DataBind() - DdlAlmacenExcel.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + DdlAlmacenExcel.DataSource = DtAlmacenes DdlAlmacenExcel.DataBind() DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) @@ -216,7 +218,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "") If Tipo = "EXCEL" Then Dim CveAlmacen As Integer = DdlAlmacenExcel.SelectedValue.ToEntero() - Dim CveSubProyecto As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}") + Dim CveSubProyecto As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}") CargarArchivo(Directorio, file.filename, CveAlmacen, CveSubProyecto) Else @@ -267,7 +269,10 @@ Partial Class Inventarios_AjustesSeccionAlmacen If Not ErrorArchivo Then Dim ErrorMovInv As Boolean = False - Dim RowNoEncontrados As New StringBuilder() + Dim CodigosNoEncontrados As New StringBuilder() + Dim SeccionesNoEncontradas As New StringBuilder() + Dim ExistenciasNoEncontradas As New StringBuilder() + Dim NumAgregados As Integer = 0 Dim ObjInventario As New ClsInventarios() @@ -275,7 +280,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen Try Dim DtExistenciasSecciones As DataTable = Nothing - If ObjInventario.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjInventario.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacenExcel.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then DtExistenciasSecciones = ObjInventario.DtResultados.Copy() End If @@ -293,9 +298,9 @@ Partial Class Inventarios_AjustesSeccionAlmacen For Each RowExcel As DataRow In DtExcel.Rows Dim Codigo As String = RowExcel("Código").ToString.Trim() - Dim PS As String = RowExcel("Producto/Servicio").ToString().Trim() + 'Dim PS As String = RowExcel("Producto/Servicio").ToString().Trim() - Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, Codigo:=Codigo).FiltroPrimero($"PS='{PS}'") + Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo='{Codigo}'") If DrPS IsNot Nothing Then If Not ErrorMovInv Then @@ -303,7 +308,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen 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 CveUM As Integer = DrPS("CveUnidadMedida").ToString().ToEntero() Dim SeccionAlmacen As String = RowExcel("SeccionAlmacen").ToString.Trim Dim CveSeccionAlmacen As Integer = -1 @@ -319,7 +324,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim RowExistencia As DataRow = DtExistenciasSecciones.FiltroPrimero($"CvePS={CvePS}") - If RowExistencia IsNot Nothing Then + If RowExistencia IsNot Nothing AndAlso CveSeccionAlmacen > 0 Then Dim CveSeccionAlmacenSalida As Integer = RowExistencia("CveSeccionAlmacen").ToString().ToEntero() Dim CantidadSalida As Decimal = RowExistencia("Existencia").ToString().ToDecimal() Dim SerieSalida As String = RowExistencia("Serie").ToString() @@ -362,13 +367,22 @@ Partial Class Inventarios_AjustesSeccionAlmacen End If Else ErrorMovInv = True - RowNoEncontrados.AppendFormat("{0},", Codigo) + End If + + If RowExistencia Is Nothing Then + ExistenciasNoEncontradas.AppendFormat("{0},", SeccionAlmacen) + ErrorMovInv = True + End If + + If CveSeccionAlmacen <= 0 Then + SeccionesNoEncontradas.AppendFormat("{0},", SeccionAlmacen) + ErrorMovInv = True End If End If Else ErrorMovInv = True - RowNoEncontrados.AppendFormat("{0},", Codigo) + CodigosNoEncontrados.AppendFormat("{0},", Codigo) End If Next @@ -383,10 +397,21 @@ Partial Class Inventarios_AjustesSeccionAlmacen ObjInventario.RollBack() Dim SbError As New StringBuilder() - SbError.Append("Ocurrió un error al guardar") - If RowNoEncontrados.Length > 0 Then - SbError.Append("Los siguientes códigos no fueron encontrados en el sistema.
") - SbError.Append(RowNoEncontrados.ToString()) + SbError.Append("Ocurrió un error al guardar.
") + + If CodigosNoEncontrados.Length > 0 Then + SbError.Append("
Los siguientes códigos no fueron encontrados en el sistema.
") + SbError.Append(CodigosNoEncontrados.ToString()) + End If + + If ExistenciasNoEncontradas.Length > 0 Then + SbError.Append($"
Los siguientes códigos no se encontraron existencias en el almacen: '{DdlAlmacenExcel.SelectedItem.Text}'.
") + SbError.Append(ExistenciasNoEncontradas.ToString()) + End If + + If SeccionesNoEncontradas.Length > 0 Then + SbError.Append("
Las siguientes secciones de almacen no fueron encontradas en el sistema.
") + SbError.Append(SeccionesNoEncontradas.ToString()) End If Alert(SbError.ToString(), TipoMensaje.MsgError)