diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb
index aace420e7..d3694abd4 100644
--- a/App_Code/ClsInventarios.vb
+++ b/App_Code/ClsInventarios.vb
@@ -1133,7 +1133,7 @@ Public Class ClsInventarios
Return Retorno
End Function
- Public Function GetMovimientosDetalle(CveMovimiento As Integer, CveEmpresa As Integer, Optional CveCompra As Integer = -1) As Boolean
+ Public Function GetMovimientosDetalle(CveMovimiento As Integer, CveEmpresa As Integer, Optional CveCompra As Integer = -1, Optional CveMovimientoDetalle As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Inv_MovimientosDetalleGet")
@@ -1141,6 +1141,7 @@ Public Class ClsInventarios
.Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
+ .Add("@CveMovimientoDetalle", SqlDbType.Int).Value = CveMovimientoDetalle
End With
Try
SqlAdapter.Fill(Data)
diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb
index 0aec0a4c6..79134e341 100644
--- a/App_Code/ClsPaginas.vb
+++ b/App_Code/ClsPaginas.vb
@@ -1181,11 +1181,11 @@ Public Class ClsPaginas
' Application("GlobalDTProductosServicios") = value
' End Set
'End Property
- ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1) As DataTable
+ ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable
Get
Dim ObjPS As New ClsProductosServicios
- If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
+ If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
GlobalDTPS = ObjPS.DtResultados
Else
GlobalDTPS = Nothing
diff --git a/Inventarios/AjustesSeccionAlmacen.aspx b/Inventarios/AjustesSeccionAlmacen.aspx
index 9efda2629..bc20d39e9 100644
--- a/Inventarios/AjustesSeccionAlmacen.aspx
+++ b/Inventarios/AjustesSeccionAlmacen.aspx
@@ -1,70 +1,124 @@
-<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="AjustesSeccionAlmacen.aspx.vb" Inherits="Inventarios_AjustesSeccionAlmacen" %>
-
-
-
-
-
-
- Ajustes de Productos en Secciones de Almacen
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb
index 0e11ceb67..db2791104 100644
--- a/Inventarios/AjustesSeccionAlmacen.aspx.vb
+++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb
@@ -1,144 +1,340 @@
-
-Imports System.Data
-Imports Extensiones
-
-Partial Class Inventarios_AjustesSeccionAlmacen
- Inherits ClsPaginas
-
- Private Sub Inventarios_AjustesSeccionAlmacen_Load(sender As Object, e As EventArgs) Handles Me.Load
- If Not Page.IsPostBack Then
- CargaCombos()
- End If
- End Sub
-
- Private Sub CargaCombos()
- DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- DdlAlmacen.DataBind()
-
- DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
- DdlClasificaciones.DataBind()
- DdlClasificaciones.Items.Insert(0, New ListItem("Todos", "-1"))
- End Sub
-
- Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
- CargaDatos()
- End Sub
-
- Private Sub CargaDatos()
- Dim ObjInv As New ClsInventarios
-
- If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
- GvD.DataSource = ObjInv.DtResultados
- End If
-
- ObjInv.Dispose()
- GvD.DataBind()
- UppD.Update()
- End Sub
-
- Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
- If e.Row.RowType = DataControlRowType.DataRow Then
-
- e.Row.FCDropDownList("DDlS").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero)
- e.Row.FCDropDownList("DDlS").DataBind()
-
- End If
- End Sub
-
- Private Sub BtnCambiarSeccion_Click(sender As Object, e As EventArgs) Handles BtnCambiarSeccion.Click
- Dim ObjInventario As New ClsInventarios
- Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL)
- Dim Dtt As DataTable = Nothing
- Dim CveMovimientoEntrada As Integer = 0
- Dim Folio = 0
- Dim ErrorMovInv As Boolean = False
- Dim TextoError = ""
- Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero
-
-
-
- Dim Fecha As Date = DateTime.Now
- 'AGREGAMOS LA ENTRADA
- Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
- Observaciones:="", Modulo:="ASA/G1")
- Folio = ObjInventario.Folio
-
- If CveMovimientoSalida <= 0 Then
- TextoError = "No se pudo generar el movimiento de salida correctamente"
- ErrorMovInv = True
- Else
-
- Dim CveMovimientoDetalleEntrada As Integer = 0
- Dim Cont As Integer = 0
- For Each gvr As GridViewRow In GvD.Rows
-
- 'que este seleccionado y que tenga diferente seccion
- If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCDropDownList("DDlS").SelectedValue.ToEntero <> gvr.DataKey("CveSeccionAlmacen").ToEntero Then
-
- If gvr.DataKey("CveSeccionAlmacen").ToEntero > 0 Then
- ObjPS.UpdateAplicaSeccionAlmacen(gvr.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, True)
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.DataKey("Existencia").ToDecimal, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, 0, -1, CveSeccionAlmacen:=gvr.DataKey("CveSeccionAlmacen").ToEntero, Serie:=gvr.DataKey("Serie"), Lote:=gvr.DataKey("Lote"), FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) Then
- ErrorMovInv = True
- TextoError = "Ocurrió un error al guardar los movimientos de salida"
- Exit For
- End If
-
- End If
-
- Next
-
- If Not ErrorMovInv Then
-
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
-
- Dim resultado As DataTable = ObjInventario.DtResultados
- CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ASA/G1")
- Dim ind As Integer = 0
-
- For Each Row As DataRow In resultado.Rows
- Dim CvePS = Row("CvePS").ToString().ToEntero()
- Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
- Dim PU As Decimal = Row("PUOriginal").ToString().ToDecimal()
- Dim CveUM As Integer = Row("CveUM").ToString().ToEntero()
- Dim CveSeccionAlmacen As Integer = GvD.Rows(ind).FCDropDownList("DDlS").SelectedValue.ToEntero ' IfNull(Row("CveSeccionAlmacen"), "-1").ToString().ToEntero()
- Dim CostoIndirecto As Decimal = Row("CostoIndirecto").ToString().ToDecimal()
- Dim Serie As String = Row("Serie").ToString()
- Dim Lote As String = Row("Lote").ToString()
- Dim FechaCaducidad As Date = IfNull(Row("FechaCaducidad"), MinFecha).ToString.ToDate
-
- 'actualizamos el PS, para que tenga el aplica seccion
-
- ObjPS.UpdateAplicaSeccionAlmacen(Row("CvePS").ToString().ToEntero(), UsuarioActual.CveEmpresa, True)
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
- ErrorMovInv = True
- Exit For
- End If
- ind += 1
- Next
- resultado.Dispose()
-
- Else
- TextoError = "No se pudo registrar el movimiento"
- ErrorMovInv = True
- End If
-
- End If
-
- End If
-
-
- If Not ErrorMovInv Then
- ObjInventario.Commit()
- cargadatos
- Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion)
- Else
- ObjInventario.RollBack()
- Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgError)
- End If
-
- ObjInventario.Dispose()
- End Sub
-End Class
+
+Imports System.Data
+Imports Extensiones
+
+Partial Class Inventarios_AjustesSeccionAlmacen
+ Inherits ClsPaginas
+
+ Private Sub Inventarios_AjustesSeccionAlmacen_Load(sender As Object, e As EventArgs) Handles Me.Load
+ If Not Page.IsPostBack Then
+ CargaCombos()
+ End If
+ End Sub
+
+ Private Sub CargaCombos()
+ DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ DdlAlmacen.DataBind()
+
+ DdlAlmacenExcel.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ DdlAlmacenExcel.DataBind()
+
+ DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
+ DdlClasificaciones.DataBind()
+ DdlClasificaciones.Items.Insert(0, New ListItem("Todos", "-1"))
+ End Sub
+
+ Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
+ CargaDatos()
+ End Sub
+
+ Private Sub CargaDatos()
+ Dim ObjInv As New ClsInventarios
+
+ If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ GvD.DataSource = ObjInv.DtResultados
+ End If
+
+ ObjInv.Dispose()
+ GvD.DataBind()
+ UppD.Update()
+ End Sub
+
+ Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ e.Row.FCDropDownList("DDlS").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero)
+ e.Row.FCDropDownList("DDlS").DataBind()
+
+ End If
+ End Sub
+
+ Private Sub BtnCambiarSeccion_Click(sender As Object, e As EventArgs) Handles BtnCambiarSeccion.Click
+ Dim ObjInventario As New ClsInventarios
+ Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL)
+ Dim Dtt As DataTable = Nothing
+ Dim CveMovimientoEntrada As Integer = 0
+ Dim Folio = 0
+ Dim ErrorMovInv As Boolean = False
+ Dim TextoError = ""
+ Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero
+
+
+
+ Dim Fecha As Date = DateTime.Now
+ 'AGREGAMOS LA ENTRADA
+ Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
+ Observaciones:="", Modulo:="ASA/G1")
+ Folio = ObjInventario.Folio
+
+ If CveMovimientoSalida <= 0 Then
+ TextoError = "No se pudo generar el movimiento de salida correctamente"
+ ErrorMovInv = True
+ Else
+
+ Dim CveMovimientoDetalleEntrada As Integer = 0
+ Dim Cont As Integer = 0
+ For Each gvr As GridViewRow In GvD.Rows
+
+ 'que este seleccionado y que tenga diferente seccion
+ If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCDropDownList("DDlS").SelectedValue.ToEntero <> gvr.DataKey("CveSeccionAlmacen").ToEntero Then
+
+ If gvr.DataKey("CveSeccionAlmacen").ToEntero > 0 Then
+ ObjPS.UpdateAplicaSeccionAlmacen(gvr.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, True)
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.DataKey("Existencia").ToDecimal, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, 0, -1, CveSeccionAlmacen:=gvr.DataKey("CveSeccionAlmacen").ToEntero, Serie:=gvr.DataKey("Serie"), Lote:=gvr.DataKey("Lote"), FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al guardar los movimientos de salida"
+ Exit For
+ End If
+
+ End If
+
+ Next
+
+ If Not ErrorMovInv Then
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+
+ Dim resultado As DataTable = ObjInventario.DtResultados
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ASA/G1")
+ Dim ind As Integer = 0
+
+ For Each Row As DataRow In resultado.Rows
+ Dim CvePS = Row("CvePS").ToString().ToEntero()
+ Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
+ Dim PU As Decimal = Row("PUOriginal").ToString().ToDecimal()
+ Dim CveUM As Integer = Row("CveUM").ToString().ToEntero()
+ Dim CveSeccionAlmacen As Integer = GvD.Rows(ind).FCDropDownList("DDlS").SelectedValue.ToEntero ' IfNull(Row("CveSeccionAlmacen"), "-1").ToString().ToEntero()
+ Dim CostoIndirecto As Decimal = Row("CostoIndirecto").ToString().ToDecimal()
+ Dim Serie As String = Row("Serie").ToString()
+ Dim Lote As String = Row("Lote").ToString()
+ Dim FechaCaducidad As Date = IfNull(Row("FechaCaducidad"), MinFecha).ToString.ToDate
+
+ 'actualizamos el PS, para que tenga el aplica seccion
+
+ ObjPS.UpdateAplicaSeccionAlmacen(Row("CvePS").ToString().ToEntero(), UsuarioActual.CveEmpresa, True)
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
+ ErrorMovInv = True
+ Exit For
+ End If
+ ind += 1
+ Next
+ resultado.Dispose()
+
+ Else
+ TextoError = "No se pudo registrar el movimiento"
+ ErrorMovInv = True
+ End If
+
+ End If
+
+ End If
+
+ If Not ErrorMovInv Then
+ ObjInventario.Commit()
+ CargaDatos()
+ Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion)
+ Else
+ ObjInventario.RollBack()
+ Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgError)
+ End If
+
+ ObjInventario.Dispose()
+ End Sub
+
+ Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click, BtnDescargar.Click
+ Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoAjusteSecCad.xlsx"
+ Dim Archivo As New IO.FileInfo(Directorio)
+ If Archivo.Exists Then
+ Response.Clear()
+ Response.ClearHeaders()
+ Response.ClearContent()
+ Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
+ Response.AddHeader("Content-Length", Archivo.Length.ToString())
+ Response.ContentType = "text/plain"
+ Response.Flush()
+ Response.TransmitFile(Archivo.FullName)
+ Response.End()
+ End If
+ End Sub
+
+ Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
+ If TxtExcel.getfiles().Archivos.Count > 0 Then
+ Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
+ Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
+ 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}")
+
+ CargarArchivo(Directorio, file.filename, CveAlmacen, CveSubProyecto)
+ Else
+ Alert("El archivo no es de tipo excel", TipoMensaje.MsgAdvertencia)
+ End If
+
+ Else
+ Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
+ End If
+ End Sub
+
+ Private Sub CargarArchivo(Ruta As String, FileName As String, CveAlmacen As Integer, CveSubProyecto As Integer)
+ Dim DtExcel As DataTable = ReadExcelFile(Ruta + FileName, True)
+
+ Dim ErrorArchivo = False
+ If Not ErrorArchivo AndAlso DtExcel IsNot Nothing Then
+ If Not DtExcel.Columns(0).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)
+ 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)
+ 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)
+ 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)
+ 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)
+ Exit Sub
+ End If
+
+ DtExcel.TableName = "Datos"
+
+ If Not ErrorArchivo Then
+ Dim ErrorMovInv As Boolean = False
+
+ Dim RowNoEncontrados As New StringBuilder()
+ Dim NumAgregados As Integer = 0
+
+ Dim ObjInventario As New ClsInventarios()
+ Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL())
+
+ Try
+ Dim DtExistenciasSecciones As DataTable = Nothing
+ If ObjInventario.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ DtExistenciasSecciones = ObjInventario.DtResultados.Copy()
+ End If
+
+ 'SALIDA ALMACÉN
+ Dim CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", TipoCambio:=-1,
+ MovimientoFijo:=False, Modulo:="ASA/SA")
+
+ 'ENTRADA ALMACÉN
+ Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", TipoCambio:=-1,
+ MovimientoFijo:=False, Modulo:="ASA/EA")
+
+ Dim dtSecciones As DataTable = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, CveAlmacen)
+ dtSecciones.CaseSensitive = False
+
+ 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)
+
+ If DrPS IsNot Nothing Then
+ If Not ErrorMovInv Then
+ 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 Serie As String = RowExcel("Serie").ToString()
+ Dim Lote As String = RowExcel("Lote").ToString()
+ Dim FechaCaducidad As Date = IfNull(RowExcel("FechaCaducidad"), MinFecha).ToString.ToDate
+
+ 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()
+
+ '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
+ ErrorMovInv = True
+ End If
+ End If
+ End If
+ Else
+ ErrorMovInv = True
+ RowNoEncontrados.AppendFormat("{0},", Codigo)
+ End If
+
+ Next
+ dtSecciones.Dispose()
+
+ Catch ex As Exception
+ ErrorMovInv = True
+ OnError("Ocurrió un error al agregar el inventario", ex)
+ End Try
+
+ If ErrorMovInv Then
+ 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())
+ End If
+
+ Alert(SbError.ToString(), TipoMensaje.MsgError)
+ Else
+ ObjInventario.Commit()
+ Alert("Se realizó el ajuste de los productos correctamente.")
+ End If
+
+ ObjInventario.Dispose()
+ ObjPS.Dispose()
+
+ End If
+ Else
+ Alert("Ocurrió un error al cargar el excel.", TipoMensaje.MsgError)
+ End If
+ End Sub
+
+End Class
\ No newline at end of file