Mejora GlobalDT: Quitar DataViews redundantes
This commit is contained in:
@@ -219,14 +219,11 @@ Public Class ClsPaginas
|
||||
Dim AppNombre As String = $"GlobalDTTiposGastos-{CveEmpresa}"
|
||||
If Application(AppNombre) Is Nothing Then
|
||||
Dim ObjCompra As New ClsCompras()
|
||||
If ObjCompra.GetTipoGasto(-1, -1) Then Application(AppNombre) = ObjCompra.DtResultados Else Application(AppNombre) = Nothing
|
||||
If ObjCompra.GetTipoGasto(-1, CveEmpresa) Then Application(AppNombre) = ObjCompra.DtResultados Else Application(AppNombre) = Nothing
|
||||
ObjCompra.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim StrSQL As New StringBuilder
|
||||
StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstatus = {0} ", Estatus)
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
|
||||
If Estatus <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), $"CveEstatus = {Estatus}", "", DataViewRowState.CurrentRows)
|
||||
GlobalDTTiposGastos = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -615,13 +612,7 @@ Public Class ClsPaginas
|
||||
If P.GetProveedorClasificacion(CveEmpresa) Then Application(AppNombre) = P.DtResultados
|
||||
P.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa ={0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTProveedorClasificacion = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTProveedorClasificacion = DirectCast(Application(AppNombre), DataTable)
|
||||
End If
|
||||
GlobalDTProveedorClasificacion = DirectCast(Application(AppNombre), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTProveedorClasificacion-{CveEmpresa}"
|
||||
@@ -736,6 +727,7 @@ Public Class ClsPaginas
|
||||
Application("GlobalDTNomSatTipoIncapacidad") = value
|
||||
End Set
|
||||
End Property
|
||||
'Este GlobalDT no estoy seguro si se deba segmentar por empresa, se usa mucho en todos lados
|
||||
Public Shared Property GlobalDTEmpresas(Optional CveEmpresa As Integer = -1) As DataTable
|
||||
Get
|
||||
Dim AppNombre As String = "GlobalDTEmpresas"
|
||||
@@ -754,7 +746,7 @@ Public Class ClsPaginas
|
||||
End Using
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), $"CveEmpresa = {CveEmpresa}", "", DataViewRowState.CurrentRows)
|
||||
GlobalDTEmpresas = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -823,13 +815,12 @@ Public Class ClsPaginas
|
||||
If ObjClasificaciones.GetClasificaciones(CveEmpresa) Then HttpContext.Current.Application(AppNombre) = ObjClasificaciones.DtResultados
|
||||
ObjClasificaciones.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Str As New StringBuilder
|
||||
Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria)
|
||||
If UsoClasificacion <> -1 Then Str.AppendFormat(" AND UsoClasificacion IN ({0},3) ", UsoClasificacion)
|
||||
If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion)
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows)
|
||||
Dim filtros As New List(Of String)
|
||||
If CveCategoria <> -1 Then filtros.Add($"CveCategoria = {CveCategoria}")
|
||||
If UsoClasificacion <> -1 Then filtros.Add($"UsoClasificacion = {UsoClasificacion}")
|
||||
If CveClasificacion <> -1 Then filtros.Add($"CveClasificacion = {CveClasificacion}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTClasificaciones = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -850,16 +841,7 @@ Public Class ClsPaginas
|
||||
If ObjRH.GetActividades(CveEmpresa) Then Application(AppNombre) = ObjRH.DtResultados
|
||||
ObjRH.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Str As New StringBuilder
|
||||
Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTRHActividades = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTRHActividades = DirectCast(Application(AppNombre), DataTable)
|
||||
End If
|
||||
|
||||
GlobalDTRHActividades = DirectCast(Application(AppNombre), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTRHActividades-{CveEmpresa}"
|
||||
@@ -875,11 +857,8 @@ Public Class ClsPaginas
|
||||
If ObjClasificaciones.GetClasificaciones(CveEmpresa, Tipo:=4) Then Application(AppNombre) = ObjClasificaciones.DtResultados
|
||||
ObjClasificaciones.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Str As New StringBuilder
|
||||
Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria)
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows)
|
||||
If CveCategoria <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), $"CveCategoria = {CveCategoria}", "", DataViewRowState.CurrentRows)
|
||||
GlobalDTClasificaciones2 = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -1118,13 +1097,7 @@ Public Class ClsPaginas
|
||||
If ObjUnidadesMedida.GetUnidadesMedida(CveEmpresa) Then HttpContext.Current.Application(AppNombre) = ObjUnidadesMedida.DtResultados
|
||||
ObjUnidadesMedida.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows)
|
||||
GlobalDTUnidadesMedida = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTUnidadesMedida = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
|
||||
End If
|
||||
GlobalDTUnidadesMedida = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTUnidadesMedida-{CveEmpresa}"
|
||||
@@ -1140,20 +1113,11 @@ Public Class ClsPaginas
|
||||
If ObjUnidadesMedida.GetUnidadesMedidaAlias(CveEmpresa, -1) Then Application(AppNombre) = ObjUnidadesMedida.DtResultados
|
||||
ObjUnidadesMedida.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTUnidadesMedidaAlias = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTUnidadesMedidaAlias = DirectCast(Application(AppNombre), DataTable)
|
||||
End If
|
||||
GlobalDTUnidadesMedidaAlias = DirectCast(Application(AppNombre), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTUnidadesMedidaAlias-{CveEmpresa}"
|
||||
Application(AppNombre) = value
|
||||
'Dim ObjUnidadesMedida As New ClsUnidadesMedida()
|
||||
'If ObjUnidadesMedida.GetUnidadesMedidaAlias(CveEmpresa, -1) Then Application(AppNombre) = ObjUnidadesMedida.DtResultados
|
||||
'ObjUnidadesMedida.Dispose()
|
||||
End Set
|
||||
End Property
|
||||
Public Shared Property GlobalDTSATMotivosCancelacion(Optional CveSATMotivoCancelacion As Integer = -1, Optional CodigoSAT As String = "-1") As DataTable
|
||||
@@ -1332,7 +1296,7 @@ Public Class ClsPaginas
|
||||
If CveProyecto <> -1 Then filtros.Add($"CveProyecto = {CveProyecto}")
|
||||
If CveSubProyecto <> -1 Then filtros.Add($"CveSubProyecto = {CveSubProyecto}")
|
||||
If CveUsuario <> -1 Then filtros.Add($"CveUsuario = {CveUsuario}")
|
||||
If CveEstatus <> -1 Then filtros.Add($"CveUsuario = {CveEstatus}")
|
||||
If CveEstatus <> -1 Then filtros.Add($"CveEstatus = {CveEstatus}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTSubProyectosUsuarios = Dv.ToTable
|
||||
@@ -1357,7 +1321,7 @@ Public Class ClsPaginas
|
||||
Dim filtros As New List(Of String)
|
||||
If CveProyecto <> -1 Then filtros.Add($"CveProyecto = {CveProyecto}")
|
||||
If CveUsuario <> -1 Then filtros.Add($"CveUsuario = {CveUsuario}")
|
||||
If CveEstatus <> -1 Then filtros.Add($"CveUsuario = {CveEstatus}")
|
||||
If CveEstatus <> -1 Then filtros.Add($"CveEstatus = {CveEstatus}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTProyectosUsuarios = Dv.ToTable
|
||||
@@ -1586,11 +1550,8 @@ Public Class ClsPaginas
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim StrSQL As New StringBuilder
|
||||
StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstado = {0} ", Estatus)
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
|
||||
If Estatus >= 0 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), $"CveEstado = {Estatus}", "", DataViewRowState.CurrentRows)
|
||||
GlobalDTProductosServiciosAlias = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -1644,19 +1605,14 @@ Public Class ClsPaginas
|
||||
Property GlobalDTPSAdicionales(CvePS As Integer, CveEmpresa As Integer) As DataTable
|
||||
Get
|
||||
Dim AppNombre As String = $"GlobalDTPSAdicionales-{CveEmpresa}"
|
||||
If CveEmpresa <> -1 Then
|
||||
'sino existe, recarga los datos
|
||||
If Application(AppNombre) Is Nothing Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPSAdicionales(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
'sino existe, recarga los datos
|
||||
If Application(AppNombre) Is Nothing Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPSAdicionales(-1, CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
Dim Str As New StringBuilder
|
||||
If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS)
|
||||
If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa)
|
||||
If CvePS > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), $"CvePS = {CvePS}", "", DataViewRowState.CurrentRows)
|
||||
GlobalDTPSAdicionales = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -1924,18 +1880,19 @@ Public Class ClsPaginas
|
||||
Dim AppNombre As String = $"GlobalDTCliente-{CveEmpresa}"
|
||||
If HttpContext.Current.Application(AppNombre) Is Nothing Then
|
||||
Dim ObjClientes As New ClsClientes
|
||||
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, Estatus:=-1) Then HttpContext.Current.Application(AppNombre) = ObjClientes.DtResultados.Copy()
|
||||
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa:=CveEmpresa, Estatus:=-1) Then HttpContext.Current.Application(AppNombre) = ObjClientes.DtResultados.Copy()
|
||||
ObjClientes.Dispose()
|
||||
End If
|
||||
|
||||
Dim StrSQL As New StringBuilder
|
||||
StrSQL.AppendFormat("1 = 1")
|
||||
If Estatus >= 0 Then StrSQL.AppendFormat(" AND EstatusBool = {0} ", Estatus)
|
||||
If CveCliente >= 0 Then StrSQL.AppendFormat(" AND CveCliente = {0} ", CveCliente)
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
|
||||
GlobalDTCliente = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
|
||||
Dim filtros As New List(Of String)
|
||||
If Estatus >= 0 Then filtros.Add($"EstatusBool = {Estatus}")
|
||||
If CveCliente >= 0 Then filtros.Add($"CveCliente = {CveCliente}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTCliente = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTCliente = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTCliente-{CveEmpresa}"
|
||||
@@ -1951,13 +1908,7 @@ Public Class ClsPaginas
|
||||
If ObjClientes.GetClienteClasificacion(CveEmpresa) Then Application(AppNombre) = ObjClientes.DtResultados
|
||||
ObjClientes.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTClienteClasificaciones = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTClienteClasificaciones = DirectCast(Application(AppNombre), DataTable)
|
||||
End If
|
||||
GlobalDTClienteClasificaciones = DirectCast(Application(AppNombre), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
Dim AppNombre As String = $"GlobalDTClienteClasificaciones-{CveEmpresa}"
|
||||
@@ -1990,12 +1941,11 @@ Public Class ClsPaginas
|
||||
If ObjVendedores.GetVendedores(CveEmpresa) Then Application(AppNombre) = ObjVendedores.DtResultados
|
||||
ObjVendedores.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim StrSQL As New StringBuilder
|
||||
StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
||||
If VendedorTipo >= 0 Then StrSQL.AppendFormat(" AND VendedorTipo = {0} ", VendedorTipo)
|
||||
If Estatus >= 0 Then StrSQL.AppendFormat(" AND CveEstatus = {0} ", If(Estatus = 1, True, False))
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
|
||||
Dim filtros As New List(Of String)
|
||||
If VendedorTipo >= 0 Then filtros.Add($"VendedorTipo = {VendedorTipo}")
|
||||
If Estatus >= 0 Then filtros.Add($"CveEstatus = {Estatus}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTVendedores = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
@@ -3259,23 +3209,18 @@ Public Class ClsPaginas
|
||||
'sino existe, recarga los datos
|
||||
If Application(AppNombre) Is Nothing Then
|
||||
Dim ObjOC As New ClsOC
|
||||
If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, CveEmpresa) Then
|
||||
If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, CveEmpresa:=CveEmpresa) Then
|
||||
Application(AppNombre) = ObjOC.DtResultados
|
||||
Else
|
||||
Application(AppNombre) = Nothing
|
||||
End If
|
||||
ObjOC.Dispose()
|
||||
End If
|
||||
If CveEmpresa <> -1 Then
|
||||
Dim filtro As New StringBuilder
|
||||
filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa)
|
||||
If CveUsuario > 0 Then
|
||||
filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario)
|
||||
End If
|
||||
If Tipo <> "" Then
|
||||
filtro.AppendFormat(" AND Tipo='{0}'", Tipo)
|
||||
End If
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows)
|
||||
Dim filtros As New List(Of String)
|
||||
If CveUsuario > 0 Then filtros.Add($"CveUsuario = {CveUsuario}")
|
||||
If Tipo <> "" Then filtros.Add($"Tipo = {Tipo}")
|
||||
If filtros.Count > 0 Then
|
||||
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||
GlobalDTOCEstatusUsuarios = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
|
||||
Reference in New Issue
Block a user