diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb
index 8893506f5..3d38484e1 100644
--- a/Inventarios/RecepcionAlmacen.aspx.vb
+++ b/Inventarios/RecepcionAlmacen.aspx.vb
@@ -4864,7 +4864,13 @@ Partial Class Inventarios_RecepcionAlmacen
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.path
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV")
- CargarArchivoExcel(Directorio, file.filename)
+
+ If Tipo = "CSV" AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then 'empresa de acumuladores
+ CargaArchivoCSV(Directorio, file.filename, HLFolio.Text)
+ Else
+ CargarArchivoExcel(Directorio, file.filename)
+ End If
+
Else
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
End If
@@ -4903,93 +4909,97 @@ Partial Class Inventarios_RecepcionAlmacen
Exit Sub
End If
-
- dt.TableName = "Datos"
- Dim ProductosNoCargados As New StringBuilder()
- Dim RowsCargados As Integer = 0
- Dim RowsNoCargados As Integer = 0
- Dim NoPSConSerie As Integer = 0
-
- If CveCompraSurtir > 0 Then
- 'DtRecepcion
- Try
- 'Dim DtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
- 'If(dt.Columns.Contains("PorcentajeIVA"), Round(Row("PorcentajeIVA").ToString.ToDecimal, 4), 0)
- For Each RowExcel As DataRow In dt.Rows
- If RowExcel("Código").ToString() <> "" Then
-
- Dim RowPS = DtInv.FiltroPrimero(String.Format("Codigo='{0}'", RowExcel("Código").ToString()))
-
- If RowPS IsNot Nothing AndAlso RowPS("CvePS").ToString().ToEntero() > 0 Then
-
- Dim CveProducto As Integer = RowPS("CvePS").ToString().ToEntero()
- Dim CveUnidadMedida As Integer = RowPS("CveUM").ToString().ToEntero()
- CvePSSerie = CveProducto
- CveConsecSerie = DtInv.FiltroPrimeroValor("Consec", "CvePS=" & CvePSSerie).ToEntero
-
- Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal()
- Dim Serie As String = RowExcel("Serie").ToString()
- Dim Lote As String = "" '= RowExcel("Lote").ToString()
- Dim FechaCaducidad As Date = MinFecha '= If(RowExcel("FechaCaducidad").ToString = "", MinFecha, RowExcel("FechaCaducidad").ToString.ToDate)
- Dim Observaciones As String = "" '= If(dt.Columns.Contains("Observaciones"), RowExcel("Observaciones").ToString, "").ToString
- LbCantidad.Text = Cantidad.ToString
-
- Dim Valido As Boolean = True
-
- If RowPS("AplicaSerie").ToString() = "True" And (String.IsNullOrEmpty(Serie.Trim()) OrElse Serie = "-1") Then
- Valido = False
- Alert($"El producto '{RowPS("PS")}' requiere 'Serie'", TipoMensaje.MsgAdvertencia)
- ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
- End If
-
- If RowPS("AplicaSerie").ToString() = "True" AndAlso Not String.IsNullOrEmpty(Serie.Trim()) Then
- NoPSConSerie = NoPSConSerie + 1
- End If
-
-
- If Valido Then
- CveConsecSerie = RowPS("Consec").ToString.ToEntero
- AgregaSerie(RowExcel("Serie").ToString, 1)
-
- 'AgregarPS(Cantidad, CveProducto, CveUnidadMedida, Observaciones, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(Not String.IsNullOrEmpty(Serie), Serie, ""), Lote:=Lote, FechaCaducidad:=FechaCaducidad, Limpia:=False)
- RowsCargados = RowsCargados + 1
- Else
- RowsNoCargados = RowsNoCargados + 1
- ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
- End If
-
- Else
- RowsNoCargados = RowsNoCargados + 1
- ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString())
- End If
- End If
- Next
- Catch ex As Exception
- OnError("Ocurrió un error al cargar los productos." & ProductosNoCargados.ToString(), ex)
- Finally
-
- Dim MensajeFinal As New StringBuilder()
- If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then
- MensajeFinal.Append("Los productos se cargaron correctamente.
")
- End If
- If RowsCargados > 0 Then
- MensajeFinal.Append("Se cargaron " & RowsCargados & " productos correctamente.")
- End If
- If RowsNoCargados > 0 Then
- MensajeFinal.Append("No se pudieron cargar " & RowsNoCargados & " productos.
Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString())
- End If
-
- Alert(MensajeFinal.ToString())
-
- End Try
- Else
- Alert("No hay seleccionada compra", TipoMensaje.MsgError)
- End If
-
+ ProcesaExcel(dt)
End If
End Sub
+ Private Function ProcesaExcel(dt As DataTable) As Boolean
+ dt.TableName = "Datos"
+ Dim ProductosNoCargados As New StringBuilder()
+ Dim RowsCargados As Integer = 0
+ Dim RowsNoCargados As Integer = 0
+ Dim NoPSConSerie As Integer = 0
+
+ If CveCompraSurtir > 0 Then
+
+ Try
+
+ For Each RowExcel As DataRow In dt.Rows
+ If RowExcel("Código").ToString() <> "" Then
+
+ Dim RowPS = DtInv.FiltroPrimero(String.Format("Codigo='{0}'", RowExcel("Código").ToString()))
+
+ If RowPS IsNot Nothing AndAlso RowPS("CvePS").ToString().ToEntero() > 0 Then
+
+ Dim CveProducto As Integer = RowPS("CvePS").ToString().ToEntero()
+ Dim CveUnidadMedida As Integer = RowPS("CveUM").ToString().ToEntero()
+ CvePSSerie = CveProducto
+ CveConsecSerie = DtInv.FiltroPrimeroValor("Consec", "CvePS=" & CvePSSerie).ToEntero
+
+ Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal()
+ Dim Serie As String = RowExcel("Serie").ToString()
+ Dim Lote As String = ""
+ Dim FechaCaducidad As Date = MinFecha
+ Dim Observaciones As String = ""
+ LbCantidad.Text = Cantidad.ToString
+
+ Dim Valido As Boolean = True
+
+ If RowPS("AplicaSerie").ToString() = "True" And (String.IsNullOrEmpty(Serie.Trim()) OrElse Serie = "-1") Then
+ Valido = False
+ Alert($"El producto '{RowPS("PS")}' requiere 'Serie'", TipoMensaje.MsgAdvertencia)
+ ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
+ End If
+
+ If RowPS("AplicaSerie").ToString() = "True" AndAlso Not String.IsNullOrEmpty(Serie.Trim()) Then
+ NoPSConSerie = NoPSConSerie + 1
+ End If
+
+
+ If Valido Then
+ CveConsecSerie = RowPS("Consec").ToString.ToEntero
+ AgregaSerie(RowExcel("Serie").ToString, 1)
+
+ 'AgregarPS(Cantidad, CveProducto, CveUnidadMedida, Observaciones, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(Not String.IsNullOrEmpty(Serie), Serie, ""), Lote:=Lote, FechaCaducidad:=FechaCaducidad, Limpia:=False)
+ RowsCargados = RowsCargados + 1
+ Else
+ RowsNoCargados = RowsNoCargados + 1
+ ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
+ End If
+
+ Else
+ RowsNoCargados = RowsNoCargados + 1
+ ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString())
+ End If
+ End If
+ Next
+ Catch ex As Exception
+ OnError("Ocurrió un error al cargar los productos." & ProductosNoCargados.ToString(), ex)
+ Finally
+
+ Dim MensajeFinal As New StringBuilder()
+ If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then
+ MensajeFinal.Append("Los productos se cargaron correctamente.
")
+ End If
+ If RowsCargados > 0 Then
+ MensajeFinal.Append("Se cargaron " & RowsCargados & " productos correctamente.")
+ End If
+ If RowsNoCargados > 0 Then
+ MensajeFinal.Append("No se pudieron cargar " & RowsNoCargados & " productos.
Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString())
+ End If
+
+ Alert(MensajeFinal.ToString())
+
+ End Try
+ Else
+ Alert("No hay seleccionada compra", TipoMensaje.MsgError)
+ End If
+
+ Return True
+
+ End Function
+
Protected Sub LbDescargarExcelConceptos_Click(sender As Object, e As EventArgs)
DescargarFormato()
End Sub
@@ -5024,6 +5034,59 @@ Partial Class Inventarios_RecepcionAlmacen
End Sub
+
+ Private Sub CargaArchivoCSV(Ruta As String, FileName As String, Optional FolioFactura As String = "")
+
+ 'Create a DataTable.
+ Dim dt As New DataTable()
+
+ dt.Columns.AddRange(New DataColumn(9) {New DataColumn("CodBarra", GetType(String)),
+ New DataColumn("OVenta", GetType(String)),
+ New DataColumn("Factura", GetType(String)),
+ New DataColumn("FechaFac", GetType(String)),
+ New DataColumn("Pallet", GetType(String)),
+ New DataColumn("CodigoJCI", GetType(String)),
+ New DataColumn("Producto", GetType(String)),
+ New DataColumn("Serie", GetType(String)),'CodigoUnico
+ New DataColumn("Cantidad", GetType(Integer)),
+ New DataColumn("Código", GetType(String))})
+ FolioFactura = FolioFactura.Replace("-", "")
+
+ 'Read the contents of CSV file.
+ Dim csvData As String = File.ReadAllText(Ruta & FileName)
+ Dim CodigoUnico As String = "CU no escaneado" 'texto constante para determinar que no se leyó
+
+ Dim r As Integer = 1
+ 'Execute a loop over the rows.
+ For Each row As String In csvData.Split(ControlChars.Lf)
+
+ If r > 2 Then ' si es la segundo renglon
+ If Not String.IsNullOrEmpty(row) Then
+ Dim i As Integer = 0
+ Dim rr As String() = row.Split(","c)
+
+ If CodigoUnico <> rr(7).Trim AndAlso (FolioFactura = "" OrElse FolioFactura = rr(2).Trim) Then
+ dt.Rows.Add()
+ dt.Rows(dt.Rows.Count - 1)("CodBarra") = rr(0).Trim
+ dt.Rows(dt.Rows.Count - 1)("OVenta") = rr(1).Trim
+ dt.Rows(dt.Rows.Count - 1)("Factura") = rr(2).Trim
+ dt.Rows(dt.Rows.Count - 1)("FechaFac") = rr(3).Trim
+ dt.Rows(dt.Rows.Count - 1)("Pallet") = rr(4).Trim
+ dt.Rows(dt.Rows.Count - 1)("CodigoJCI") = rr(5).Trim
+ dt.Rows(dt.Rows.Count - 1)("Producto") = rr(6).Trim
+ dt.Rows(dt.Rows.Count - 1)("Serie") = rr(7).Trim
+ dt.Rows(dt.Rows.Count - 1)("Cantidad") = 1
+ dt.Rows(dt.Rows.Count - 1)("Código") = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Codigo", String.Format("Codigo2 = '{0}'", rr(5).Trim))
+
+ End If
+ End If
+ End If
+ r += 1
+ Next
+
+ ProcesaExcel(dt)
+
+ End Sub
#End Region
Private Function GuardaDocumentoBitacora(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean