Correciones en importar desde excel al hacer ajustes en seccion de almacen

This commit is contained in:
2020-07-10 11:33:37 -07:00
parent ea384a13c8
commit 0fc5d89d20

View File

@@ -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.<br/>")
SbError.Append(RowNoEncontrados.ToString())
SbError.Append("Ocurrió un error al guardar.<br/>")
If CodigosNoEncontrados.Length > 0 Then
SbError.Append("<br/>Los siguientes códigos no fueron encontrados en el sistema.<br/>")
SbError.Append(CodigosNoEncontrados.ToString())
End If
If ExistenciasNoEncontradas.Length > 0 Then
SbError.Append($"<br/>Los siguientes códigos no se encontraron existencias en el almacen: '{DdlAlmacenExcel.SelectedItem.Text}'.<br/>")
SbError.Append(ExistenciasNoEncontradas.ToString())
End If
If SeccionesNoEncontradas.Length > 0 Then
SbError.Append("<br/>Las siguientes secciones de almacen no fueron encontradas en el sistema.<br/>")
SbError.Append(SeccionesNoEncontradas.ToString())
End If
Alert(SbError.ToString(), TipoMensaje.MsgError)