diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index ce903284a..66f3ce64e 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -19102,7 +19102,7 @@ Partial Class Ventas Conexion.Open() Dim cmd = Conexion.CreateCommand() cmd.CommandType = CommandType.Text - cmd.CommandText = "Select * FROM [Hoja1$]" + cmd.CommandText = "Select * FROM [Hoja1$] WHERE Cantidad >=1" Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) DataAdapter.Fill(dt) Case Else @@ -19155,6 +19155,8 @@ Partial Class Ventas dt.TableName = "Datos" + Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + DtSubProyecto.CaseSensitive = False If Not ErrorArchivo Then NumRow = 1 Dim RowNoEncontrados As String = "" @@ -19179,8 +19181,6 @@ Partial Class Ventas NumRow = NumRow + 1 If Proyecto <> "" Then - Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - DtSubProyecto.CaseSensitive = False DrProyecto = DtSubProyecto.FiltroPrimero($"(SubProyecto) = '{Proyecto}'") If DrProyecto IsNot Nothing Then CveSubProyecto = DrProyecto("CveSubProyecto").ToString.ToEntero @@ -19193,38 +19193,80 @@ Partial Class Ventas End If If Codigo <> "" Then - Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c) - If StrArray.Length > 0 Then - If CBool(StrArray(0)) = True Then - CvePS = StrArray(1).ToEntero + + Using ObjPS As New ClsProductosServicios + If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, Codigo:=Codigo) Then + If ObjPS.CvePS > 0 Then + CvePS = ObjPS.CvePS + CveUM = ObjPS.CveUnidadMedida + + Else + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados) + End If Else - RowNoEncontrados &= StrArray(1) & "<\BR>" + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados) End If - End If + End Using + + 'Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c) + 'If StrArray.Length > 0 Then + ' If CBool(StrArray(0)) = True Then + ' CvePS = StrArray(1).ToEntero + ' Else + ' RowNoEncontrados &= StrArray(1) & "<\BR>" + ' End If + 'End If ElseIf CodigoBarras <> "" Then - Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c) - If StrArray.Length > 0 Then - If CBool(StrArray(0)) = True Then - CvePS = StrArray(1).ToEntero + + Using ObjPS As New ClsProductosServicios + If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, CodigoBarras:=CodigoBarras) Then + If ObjPS.CvePS > 0 Then + CvePS = ObjPS.CvePS + CveUM = ObjPS.CveUnidadMedida + + Else + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados) + End If Else - RowNoEncontrados &= StrArray(1) & "<\BR>" + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados) End If - End If + End Using + 'Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c) + 'If StrArray.Length > 0 Then + ' If CBool(StrArray(0)) = True Then + ' CvePS = StrArray(1).ToEntero + ' Else + ' RowNoEncontrados &= StrArray(1) & "<\BR>" + ' End If + 'End If ElseIf ProductoServicio <> "" Then - Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c) - If StrArray.Length > 0 Then - If CBool(StrArray(0)) = True Then - CvePS = StrArray(1).ToEntero + + Using ObjPS As New ClsProductosServicios + If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa, CodigoBarras:=CodigoBarras) Then + If ObjPS.CvePS > 0 Then + CvePS = ObjPS.CvePS + CveUM = ObjPS.CveUnidadMedida + Else + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados) + End If Else - RowNoEncontrados &= StrArray(1) & "<\BR>" + RowNoEncontrados = String.Format("{3}    - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados) End If - End If + End Using + 'Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c) + 'If StrArray.Length > 0 Then + ' If CBool(StrArray(0)) = True Then + ' CvePS = StrArray(1).ToEntero + ' Else + ' RowNoEncontrados &= StrArray(1) & "<\BR>" + ' End If + 'End If Else RowNoEncontrados &= "<\BR>    - En la fila " & NumRow & " no se especificó código, código de barras ó descripción." End If If CvePS > 0 Then - CveUM = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero + 'CveUM = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero AgregarProductoServicio(Cantidad, CveUM, UM, -1, "", CvePS, HdnPS.Value, Observaciones, PrecioUnitario, HdnDescuento.Value.ToDecimal, @@ -19276,17 +19318,21 @@ Partial Class Ventas Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) End If End Sub - Private Function GetPS(Opt As String, Valor As String) As String - Dim StrReturn As String = String.Empty - Dim CvePS As Integer = 0 - CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero - If CvePS > 0 Then - StrReturn = "True|" & CvePS.ToString - Else - StrReturn = "False|    - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt - End If - Return StrReturn - End Function + + + 'Private dtps As DataTable = Nothing + 'Private Function GetPS(Opt As String, Valor As String) As String + ' Dim StrReturn As String = String.Empty + ' Dim CvePS As Integer = 0 + ' If dtps Is Nothing Then dtps = GlobalDTPS(UsuarioActual.CveEmpresa) + ' CvePS = dtps.FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString().ToEntero() + ' If CvePS > 0 Then + ' StrReturn = "True|" & CvePS.ToString + ' Else + ' StrReturn = "False|    - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt + ' End If + ' Return StrReturn + 'End Function #End Region #Region "P E D I D O S"