From 7c2f3592d72dc46d5912aab88cebf6cd6985a25c Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 1 Jul 2022 09:16:27 -0700 Subject: [PATCH] E140. CveVentaDetalle en recepcion de usados desde el PV.aspx --- App_Code/ClsVentas.vb | 3 +- App_Code/Modelos.vb | 14 ++++--- Inventarios/RecepcionUsados.aspx | 2 +- Inventarios/RecepcionUsados.aspx.vb | 58 +++++++++++++++++------------ Ventas/PV.aspx | 2 +- Ventas/PV.aspx.vb | 11 ++++-- 6 files changed, 55 insertions(+), 35 deletions(-) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index dd9049057..91fbf3097 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -5121,7 +5121,7 @@ Public Class ClsVentas #Region " U S A D O S " - Public Function AddVentaUsado(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, Optional CveBCI As Integer = -1, Optional CveModeloAuto As Integer = -1) As Boolean + Public Function AddVentaUsado(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, Optional CveBCI As Integer = -1, Optional CveModeloAuto As Integer = -1, Optional CveVentaDetalle As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasUsadosAdd", CommandType.StoredProcedure) @@ -5133,6 +5133,7 @@ Public Class ClsVentas .Add("@PU", SqlDbType.Money).Value = PU .Add("@CveBCI", SqlDbType.Int).Value = CveBCI .Add("@CveModeloAuto", SqlDbType.Int).Value = CveModeloAuto + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle End With Try diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index e60e23e27..c067e3d94 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1578,10 +1578,14 @@ Namespace Modelos End If If DtRecepcionUsados IsNot Nothing Then - If DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then - Dim rowInv As DataRow = DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) - rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If + Try + If DtRecepcionUsados.Select($"ConsecUsado={Row("Consec").ToString.ToEntero}").Length > 0 Then + Dim rowUsados As DataRow = DtRecepcionUsados.Select($"ConsecUsado={Row("Consec").ToString.ToEntero}")(0) + rowUsados("CveVentaDetalle") = ObjVentas.CveVentaDetalle + End If + Catch ex As Exception + GuardaLog("Ocurrió un error al relacionar los usados. " & ex.ToString()) + End Try End If If DtPolizasVirtuales IsNot Nothing Then @@ -2138,7 +2142,7 @@ Namespace Modelos If factura.TipoDocto.Contiene("Rem") Then If factura.DtRecepcionUsados IsNot Nothing Then For Each drow As DataRow In factura.DtRecepcionUsados.Rows - If Not ObjVentas.AddVentaUsado(factura.CveVenta, drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("CveBCIUsado").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero) Then + If Not ObjVentas.AddVentaUsado(factura.CveVenta, drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("CveBCIUsado").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero, CveVentaDetalle:=drow("CveVentaDetalle").ToString.ToEntero) Then Resultado = False Exit For End If diff --git a/Inventarios/RecepcionUsados.aspx b/Inventarios/RecepcionUsados.aspx index cc164582b..fd65ecbb7 100644 --- a/Inventarios/RecepcionUsados.aspx +++ b/Inventarios/RecepcionUsados.aspx @@ -130,7 +130,7 @@
- +
diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index f2f347096..807fcfcd0 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -15,14 +15,14 @@ Partial Class Inventarios_RecepcionUsados Private _dtDatos As DataTable - Public Property DtClientes() As DataTable - Get - Return CType(ViewState("DtClientes"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtClientes") = value - End Set - End Property + 'Public Property DtClientes() As DataTable + ' Get + ' Return CType(ViewState("DtClientes"), DataTable) + ' End Get + ' Set(value As DataTable) + ' ViewState("DtClientes") = value + ' End Set + 'End Property Public Property DtMovimientos() As DataTable Get @@ -454,6 +454,7 @@ Partial Class Inventarios_RecepcionUsados Dim Fecha As DateTime = IfNull(Request("Fecha"), Now.ToString("dd/MM/yyyy")).ToString().ToDateTime() If Not String.IsNullOrEmpty(RFC) Then + Dim DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa) If DtClientes Is Nothing Then Alert("No se encontraron clientes para filtrar", TipoMensaje.MsgError) Exit Sub @@ -476,8 +477,10 @@ Partial Class Inventarios_RecepcionUsados End If Dim CveCliente As Integer = RowCliente("CveCliente").ToString().ToEntero() + Dim Cliente = RowCliente("NombreComercial").ToString() - DdlClientes.SelectedValueExist(CveCliente) + DdlClientes.SelectedValue = CveCliente.ToString() + DdlClientes.SelectedText = Cliente DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty) DdlAlmacen.SelectedValueExist(CveAlmacen) @@ -775,6 +778,10 @@ Partial Class Inventarios_RecepcionUsados EsDistribuidor = False InicializaClientes(True) DdlClientes.Enabled = True + If Not String.IsNullOrEmpty(DdlClientes.ddlWS.Attributes.Item("disabled")) Then + DdlClientes.ddlWS.Attributes.Remove("disabled") + End If + ChkClientesTodos.Enabled = True SiguienteFolio() @@ -2008,14 +2015,11 @@ Partial Class Inventarios_RecepcionUsados #Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED" Private Sub InicializaClientes(Todos As Boolean) - DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(If(Todos, "", "EsDistribuidor = 1")) - - DdlClientes.DataSource = DtClientes - DdlClientes.DataBind() - - DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClientes.ddlWS.Attributes.Add("data-esdistribuidor", If(Todos, "-1", "1")) DdlClientes.SelectedValue = "-1" + DdlClientes.SelectedText = "Seleccione" + UpGenerales.Update() End Sub 'Protected Sub ActivaClientes() ' If UsuarioActual.CveEmpresa.Contiene(72, 80) Then @@ -2027,7 +2031,7 @@ Partial Class Inventarios_RecepcionUsados 'End Sub - Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) + Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.selectedindexchange CambiaCliente() End Sub Private Sub CambiaCliente(Optional CargaSucursales As Boolean = True, Optional CargaFacturas As Boolean = True) @@ -2314,11 +2318,16 @@ Partial Class Inventarios_RecepcionUsados 'RELACIONA LA VENTA DETALLA DE LA REMISION If DtUsados IsNot Nothing Then - DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer))) + If Not DtUsados.Columns.Contains("CveVentaDetalle") Then + DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer))) + End If + For Each RowUsado As DataRow In DtUsados.Rows - Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero() - If CveVentaDetalle > 0 Then - RowUsado("CveVentaDetalle") = CveVentaDetalle + If RowUsado("CveVentaDetalle").ToString().ToEntero() <= 0 Then + Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero() + If CveVentaDetalle > 0 Then + RowUsado("CveVentaDetalle") = CveVentaDetalle + End If End If Next End If @@ -2330,13 +2339,15 @@ Partial Class Inventarios_RecepcionUsados If CveCliente > 0 Then DivCliente.Visible = True - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente)) - DdlClientes.DataBind() + Dim Cliente = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=CveCliente).FiltroPrimeroValor("NombreComercial") + + DdlClientes.SelectedValue = CveCliente.ToString() + DdlClientes.SelectedText = Cliente - DdlClientes.SelectedValueExist(CveCliente) CambiaCliente(False, False) DdlClientes.Enabled = False + DdlClientes.ddlWS.Attributes.Add("disabled", "disabled") ChkClientesTodos.Enabled = False End If @@ -3414,7 +3425,6 @@ Partial Class Inventarios_RecepcionUsados #End Region Protected Sub SeleccionarTipoDeClientes(sender As Object, e As EventArgs) - DdlClientes.Items.Clear() InicializaClientes(ChkClientesTodos.Checked) End Sub diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx index 996b26007..5cfaa7423 100644 --- a/Ventas/PV.aspx +++ b/Ventas/PV.aspx @@ -2482,7 +2482,7 @@
- +
diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 7158d5eb1..c45973ddb 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -5014,7 +5014,7 @@ Partial Class PV If Modalidad = "A" Then Row("Consec") = TmpDT.MAX("Consec").ToEntero() + 1 If Not EsCargo Then - ConsecutivoVenta = TmpDT.MAX("Consec").ToEntero() + 1 + ConsecutivoVenta = Row("Consec").ToString.ToEntero End If ElseIf Modalidad = "U" Then If Not EsCargo Then @@ -7661,6 +7661,7 @@ Partial Class PV TmpDTRecepcionUsados = New DataTable TmpDTRecepcionUsados.Columns.Add("CvePS", GetType(Integer)) TmpDTRecepcionUsados.Columns.Add("CvePSRelacionado", GetType(Integer)) + TmpDTRecepcionUsados.Columns.Add("ConsecUsado", GetType(Integer)) TmpDTRecepcionUsados.Columns.Add("ConsecRelacionado", GetType(Integer)) TmpDTRecepcionUsados.Columns.Add("Cantidad", GetType(Decimal)) TmpDTRecepcionUsados.Columns.Add("AnioVehiculo", GetType(String)) @@ -7743,6 +7744,9 @@ Partial Class PV Row("PU") = DrTamanio("Cargo").ToString().ToDecimal Row("CveBCIUsado") = DdlBCIUsado.SelectedValue.ToEntero Row("CveModeloAuto") = DdlModeloAuto.SelectedValue.ToEntero + If ListaPSCargo IsNot Nothing AndAlso ListaPSCargo.Count = 1 Then + Row("ConsecUsado") = ListaPSCargo.FirstOrDefault().ConsecutivoUsado + End If Row("ConsecRelacionado") = ConsecPSPadre Row("FechaUsado") = TxtFechaVigencia.Text.ToDateTime() Row("AnioVehiculo") = TxtAnioVehiculo.Text @@ -7878,6 +7882,7 @@ Partial Class PV End Sub Public Class MConceptoUsado Public Property Consecutivo As Integer + Public Property ConsecutivoUsado As Integer Public Property CvePS As Integer End Class Private Function CalculaUsados(Consec As Integer, Optional LimpiarUsados As Boolean = True) As List(Of MConceptoUsado) @@ -7985,12 +7990,12 @@ Partial Class PV For Each drowPsTamaños As DataRow In DTPSTemp.Rows If drowPsTamaños("PU").ToString.ToDecimal > 0 Then - Dim Concec = AgregarProductoServicio(drowPsTamaños("Cantidad").ToString.ToEntero, drowPsTamaños("CveUnidadMedida").ToString.ToEntero, drowPsTamaños("UnidadMedida").ToString, + Dim ConsecutivoUsado As Integer = AgregarProductoServicio(drowPsTamaños("Cantidad").ToString.ToEntero, drowPsTamaños("CveUnidadMedida").ToString.ToEntero, drowPsTamaños("UnidadMedida").ToString, drowPsTamaños("CveClasificacion").ToString.ToEntero, drowPsTamaños("Clasificacion").ToString, drowPsTamaños("CvePS").ToString.ToEntero, drowPsTamaños("PS").ToString, "", drowPsTamaños("PU").ToString.ToDecimal, 0, -1, "", drowPsTamaños("CveSubProyecto").ToString.ToEntero, drowPsTamaños("SubProyecto").ToString, EsCargo:=True, ConsecPSPadre:=drowPsTamaños("ConsecPSPadre").ToString.ToEntero, EliminarDB:=CBool(drowPsTamaños("EliminarDB").ToString())) If Consec > 0 Then - ListaPScargo.Add(New MConceptoUsado() With {.Consecutivo = Consec, .CvePS = drowPsTamaños("CvePS").ToString.ToEntero}) + ListaPScargo.Add(New MConceptoUsado() With {.Consecutivo = Consec, .ConsecutivoUsado = ConsecutivoUsado, .CvePS = drowPsTamaños("CvePS").ToString.ToEntero}) End If End If Next