diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 7ee59cc49..f29eb1e50 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4101,29 +4101,51 @@ Public Class ClsPaginas HttpContext.Current.Application(AppNombre) = value End Set End Property - Property GlobalDTAcumGarantiasMesesTipoUso(CveEmpresa As Integer, CveMarca As Integer, CveTipoUso As Integer, Mes As Integer) As DataTable + + Property GlobalDTAcumGarantiasTipoUso(CveEmpresa As Integer, CveMarca As Integer, CveTipoUso As Integer) As DataTable Get - Dim AppNombre As String = $"GlobalDTAcumGarantiasMesesTipoUso-{CveEmpresa}" + Dim AppNombre As String = $"GlobalDTAcumGarantiasTipoUso-{CveEmpresa}" If Application(AppNombre) Is Nothing Then Dim ObjAcumuladores As New ClsAcumuladores() If ObjAcumuladores.GarantiasMesesGet(-1, CveEmpresa) Then Application(AppNombre) = ObjAcumuladores.DtResultados.FiltraParametros("", DistinctColumns:={"CveMarca", "CveTipoUso", "TipoUso"}) ObjAcumuladores.Dispose() End If - If CveMarca <> -1 Then - Dim Str As StringBuilder = New StringBuilder() - If CveMarca <> -1 Then Str.AppendFormat("CveMarca = {0}", CveMarca) - If CveTipoUso <> -1 Then Str.AppendFormat("CveTipoUso = {0}", CveTipoUso) - If Mes <> -1 Then Str.AppendFormat("Mes = {0}", CveTipoUso) - Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTAcumGarantiasMesesTipoUso = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAcumGarantiasMesesTipoUso = DirectCast(Application(AppNombre), DataTable) - End If + Dim filtros As New List(Of String) + If CveMarca <> -1 Then filtros.Add($"CveMarca = {CveMarca}") + If CveTipoUso <> -1 Then filtros.Add($"CveTipoUso = {CveTipoUso}") + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows) + GlobalDTAcumGarantiasTipoUso = Dv.ToTable + Dv.Dispose() + End Get Set(value As DataTable) - Dim AppNombre As String = $"GlobalDTAcumGarantiasMesesTipoUso-{CveEmpresa}" + Dim AppNombre As String = $"GlobalDTAcumGarantiasTipoUso-{CveEmpresa}" + Application(AppNombre) = value + End Set + End Property + Property GlobalDTAcumGarantiasTipoUsoMeses(CveEmpresa As Integer, CveMarca As Integer, CveTipoUso As Integer, Mes As Integer) As DataTable + Get + Dim AppNombre As String = $"GlobalDTAcumGarantiasTipoUsoMeses-{CveEmpresa}" + If Application(AppNombre) Is Nothing Then + Dim ObjAcumuladores As New ClsAcumuladores() + If ObjAcumuladores.GarantiasMesesGet(-1, CveEmpresa) Then Application(AppNombre) = ObjAcumuladores.DtResultados + ObjAcumuladores.Dispose() + End If + + Dim filtros As New List(Of String) + If CveMarca <> -1 Then filtros.Add($"CveMarca = {CveMarca}") + If CveTipoUso <> -1 Then filtros.Add($"CveTipoUso = {CveTipoUso}") + If Mes <> -1 Then filtros.Add($"Mes = {Mes}") + + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows) + GlobalDTAcumGarantiasTipoUsoMeses = Dv.ToTable + Dv.Dispose() + + End Get + Set(value As DataTable) + Dim AppNombre As String = $"GlobalDTAcumGarantiasTipoUsoMeses-{CveEmpresa}" Application(AppNombre) = value End Set End Property diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 3416520dc..1e3a0966b 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -3089,7 +3089,7 @@ Partial Class Inventarios_RecepcionUsados End If DdlTipoUso.Items.Clear() - DdlTipoUso.DataSource = GlobalDTAcumGarantiasMesesTipoUso(UsuarioActual.CveEmpresa, CveMarca, -1, -1) + DdlTipoUso.DataSource = GlobalDTAcumGarantiasTipoUso(UsuarioActual.CveEmpresa, CveMarca, -1) DdlTipoUso.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlTipoUso.DataBind() @@ -3246,7 +3246,7 @@ Partial Class Inventarios_RecepcionUsados CveMarca = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimeroValor("CveMarca", "").ToEntero - Dim dtt As DataTable = GlobalDTAcumGarantiasMesesTipoUso(UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) + Dim dtt As DataTable = GlobalDTAcumGarantiasTipoUsoMeses(UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) If dtt IsNot Nothing Then If dtt.Rows.Count > 0 Then diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index fc6e5ad78..539e0a193 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -7378,7 +7378,7 @@ Partial Class PV End If DdlTipoUso.Items.Clear() - DdlTipoUso.DataSource = GlobalDTAcumGarantiasMesesTipoUso(UsuarioActual.CveEmpresa, CveMarca) + DdlTipoUso.DataSource = GlobalDTAcumGarantiasTipoUso(UsuarioActual.CveEmpresa, CveMarca, -1) DdlTipoUso.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlTipoUso.DataBind() @@ -7434,12 +7434,13 @@ Partial Class PV CveMarca = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimeroValor("CveMarca", "").ToEntero Dim ImportePagarCliente As Decimal = 0 - Dim ObjAcum As New ClsAcumuladores - If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then - If ObjAcum.DtResultados.Rows.Count > 0 Then + Dim dtt As DataTable = GlobalDTAcumGarantiasTipoUsoMeses(UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) + + If dtt IsNot Nothing Then + If dtt.Rows.Count > 0 Then ''obtener siempre y cuando la fecha de inicio sea mayor Dim strDate As Date = ($"20{TxtEtiqueta.Text.Substring(2, 2)}/{TxtEtiqueta.Text.Substring(0, 2)}/01").ToDate - Dim drg As DataRow = ObjAcum.DtResultados.FiltroPrimero($" #{strDate.ToString("yyyy/MM/dd")}# >= FechaInicioVigencia ", "FechaInicioVigencia DESC") + Dim drg As DataRow = dtt.FiltroPrimero($" #{strDate.ToString("yyyy/MM/dd")}# >= FechaInicioVigencia ", "FechaInicioVigencia DESC") If drg IsNot Nothing Then TxtPorcentajeAjuste.Text = (drg("Valor").ToString.ToDouble / 100).ToString @@ -7498,7 +7499,7 @@ Partial Class PV Else Alert("No se tiene especificado tabla de garantía") End If - ObjAcum.Dispose() + Else If DdlPSAjuste.SelectedValue.ToEntero <= 0 Then Alert("Especificar el producto a recibir")