-- unificación de globalDTs

This commit is contained in:
2023-02-18 13:40:31 -07:00
parent a8eb7895e0
commit e59d485489
6 changed files with 107 additions and 1076 deletions

View File

@@ -42,461 +42,8 @@ Public Class WSApp
ObjPS.Dispose()
End Get
End Property
Property GlobalDTMonedas() As DataTable
Get
GlobalDTMonedas = DirectCast(Application("GlobalDTMonedas"), DataTable)
End Get
Set(value As DataTable)
Application("GlobalDTMonedas") = value
End Set
End Property
Property GlobalDTVtaMetodoPago() As DataTable
Get
GlobalDTVtaMetodoPago = DirectCast(Application("GlobalDTVtaMetodoPago"), DataTable)
End Get
Set(value As DataTable)
Application("GlobalDTVtaMetodoPago") = value
End Set
End Property
Property GlobalDTVtaFormaPago() As DataTable
Get
GlobalDTVtaFormaPago = DirectCast(Application("GlobalDTVtaFormaPago"), DataTable)
End Get
Set(value As DataTable)
Application("GlobalDTVtaFormaPago") = value
End Set
End Property
Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable
Get
Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa)
'sino existe, recarga los datos
If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then
Dim P As New ClsSubProyectos
If P.GetSubProyectos(CveEmpresa:=CveEmpresa) Then Application(AppNombre) = P.DtResultados
P.Dispose()
End If
If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then
Dim StrSQL As New StringBuilder
If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto)
If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto)
If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus)
If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa)
Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows)
GlobalDTSubProyectos = Dv.ToTable
Dv.Dispose()
Else
GlobalDTSubProyectos = DirectCast(Application(AppNombre), DataTable)
End If
End Get
Set(ByVal value As DataTable)
Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa)
Application(AppNombre) = value
End Set
End Property
Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable
Get
If EsPersonaFisica <> -1 Then
Dim Tipo As String = ""
If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1"
Dim Dv As New DataView(DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows)
GlobalDTSATUsosCFDI = Dv.ToTable
Dv.Dispose()
Else
GlobalDTSATUsosCFDI = DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable)
End If
End Get
Set(ByVal value As DataTable)
Application("GlobalDTSATUsosCFDI") = value
End Set
End Property
Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable
Get
Dim Str As New StringBuilder
If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario)
If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa)
If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente)
If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor)
If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
GlobalDTUsuarios = Dv.ToTable
Dv.Dispose()
Else
GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTUsuarios") = value
End Set
End Property
'Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable
' Get
' If CveEmpresa <> -1 Then
' Dim Dv As New DataView(DirectCast(Application("GlobalDTUnidadesMedida"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows)
' GlobalDTUnidadesMedida = Dv.ToTable
' Dv.Dispose()
' Else
' GlobalDTUnidadesMedida = DirectCast(Application("GlobalDTUnidadesMedida"), DataTable)
' End If
' End Get
' Set(value As DataTable)
' Application("GlobalDTUnidadesMedida") = value
' End Set
'End Property
Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTGralCategorias = Dv.ToTable
Dv.Dispose()
Else
GlobalDTGralCategorias = DirectCast(Application("GlobalDTGralCategorias"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTGralCategorias") = value
End Set
End Property
Private ReadOnly Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable
Get
If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1
Dim StrSQL As New StringBuilder
If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa)
' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto)
If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus)
Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
GlobalDTProyectos = Dv.ToTable
Dv.Dispose()
Else
GlobalDTProyectos = DirectCast(Application("GlobalDTProyectos"), DataTable)
End If
End Get
End Property
Property GlobalDTVendedores(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTVendedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTVendedores = Dv.ToTable
Dv.Dispose()
Else
GlobalDTVendedores = DirectCast(Application("GlobalDTVendedores"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTVendedores") = value
End Set
End Property
Property GlobalDTCliente(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTCliente"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTCliente = Dv.ToTable
Dv.Dispose()
Else
GlobalDTCliente = DirectCast(Application("GlobalDTCliente"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTCliente") = value
End Set
End Property
Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTOCEstatus = Dv.ToTable
Dv.Dispose()
Else
GlobalDTOCEstatus = DirectCast(Application("GlobalDTOCEstatus"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTOCEstatus") = value
End Set
End Property
Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
Get
If GlobalTipoCambio <= 0 Then
'sino tiene dato lo recargo por si ya esta insertado
If Fecha = MinFecha Then Fecha = Now
Dim ObjGral As New ClsGenerales
If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then
Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble
Else
Application("GlobalTipoCambio") = 0
End If
ObjGral.Dispose()
End If
Return Application("GlobalTipoCambio").ToString.ToDouble
End Get
Set(value As Double)
Application("GlobalTipoCambio") = value
End Set
End Property
Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable
Get
Dim AppNombre As String = String.Format("GlobalDTOCEstatusUsuarios-{0}", CveEmpresa)
'sino existe, recarga los datos
If DirectCast(HttpContext.Current.Application(AppNombre), DataTable) Is Nothing Then
Dim ObjOC As New ClsOC
If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, CveEmpresa) Then
HttpContext.Current.Application(AppNombre) = ObjOC.DtResultados
Else
HttpContext.Current.Application(AppNombre) = Nothing
End If
ObjOC.Dispose()
End If
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(HttpContext.Current.Application(AppNombre), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows)
GlobalDTOCEstatusUsuarios = Dv.ToTable
Dv.Dispose()
End Get
Set(value As DataTable)
Dim AppNombre As String = String.Format("GlobalDTOCEstatusUsuarios-{0}", CveEmpresa)
HttpContext.Current.Application(AppNombre) = value
End Set
End Property
'Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable
' Get
' 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("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows)
' GlobalDTOCEstatusUsuarios = Dv.ToTable
' Dv.Dispose()
' Else
' GlobalDTOCEstatusUsuarios = DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable)
' End If
' End Get
' Set(value As DataTable)
' Application("GlobalDTOCEstatusUsuarios") = value
' End Set
'End Property
Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTCompProveedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTCompProveedores = Dv.ToTable
Dv.Dispose()
Else
GlobalDTCompProveedores = DirectCast(Application("GlobalDTCompProveedores"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTCompProveedores") = value
End Set
End Property
Public Property GlobalDTPSSimplificado(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional PSCodigo As String = "-1", Optional Estatus As Integer = 1, Optional AplicaParaVenta As Integer = -1, Optional CvePS As Integer = -1) As DataTable
Get
Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)
If CveEmpresa <> -1 Then
'sino existe, recarga los datos
If Application(AppNombre) Is Nothing Then
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPSSimplificado(CveEmpresa) Then Application(AppNombre) = ObjPS.DtResultados.AsEnumerable()
ObjPS.Dispose()
End If
Dim Cons = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow))
Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa))
If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion))
If PSCodigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!PSCodigo) = PSCodigo))
If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus))
If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta))
If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS))
Try
GlobalDTPSSimplificado = Cons.OrderBy(Function(a) a!PSCodigo).CopyToDataTable
Catch ex As Exception
GlobalDTPSSimplificado = New DataTable
End Try
Else
GlobalDTPSSimplificado = DirectCast(Application(AppNombre), EnumerableRowCollection(Of DataRow)).CopyToDataTable
End If
End Get
Set(value As DataTable)
Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)
Application(AppNombre) = value
End Set
End Property
Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable
Get
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("GlobalDTClasificaciones"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows)
GlobalDTClasificaciones = Dv.ToTable
Dv.Dispose()
Else
GlobalDTClasificaciones = DirectCast(Application("GlobalDTClasificaciones"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTClasificaciones") = value
End Set
End Property
Property GlobalDTTurno(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTTurno"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTTurno = Dv.ToTable
Dv.Dispose()
Else
GlobalDTTurno = DirectCast(Application("GlobalDTTurno"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTTurno") = value
End Set
End Property
Property GlobalDTDepartamentos(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTDepartamentos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTDepartamentos = Dv.ToTable
Dv.Dispose()
Else
GlobalDTDepartamentos = DirectCast(Application("GlobalDTDepartamentos"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTDepartamentos") = value
End Set
End Property
Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTRHPuestos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTRHPuestos = Dv.ToTable
Dv.Dispose()
Else
GlobalDTRHPuestos = DirectCast(Application("GlobalDTRHPuestos"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTRHPuestos") = value
End Set
End Property
Property GlobalDTMetodosPago() As DataTable
Get
GlobalDTMetodosPago = DirectCast(Application("GlobalDTMetodosPago"), DataTable)
End Get
Set(value As DataTable)
Application("GlobalDTMetodosPago") = value
End Set
End Property
Property GlobalDTAsistenciasInasistencias(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTAsistenciasInasistencias = Dv.ToTable
Dv.Dispose()
Else
GlobalDTAsistenciasInasistencias = DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTAsistenciasInasistencias") = value
End Set
End Property
Property GlobalDTMotivosHorasExtras(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
Dim Dv As New DataView(DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
GlobalDTMotivosHorasExtras = Dv.ToTable
Dv.Dispose()
Else
GlobalDTMotivosHorasExtras = DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable)
End If
End Get
Set(value As DataTable)
Application("GlobalDTMotivosHorasExtras") = value
End Set
End Property
Public Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable
Get
Dim AppNombre As String = String.Format("GlobalDTUnidadesMedida-{0}", CveEmpresa)
'sino existe, recarga los datos
If DirectCast(Application(AppNombre), DataTable) Is Nothing Or (DirectCast(Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(Application(AppNombre), DataTable).Rows.Count = 0) Then
Dim ObjUnidadesMedida As New ClsUnidadesMedida()
If ObjUnidadesMedida.GetUnidadesMedida(CveEmpresa) 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), " UnidadMedida", DataViewRowState.CurrentRows)
GlobalDTUnidadesMedida = Dv.ToTable
Dv.Dispose()
Else
GlobalDTUnidadesMedida = DirectCast(Application(AppNombre), DataTable)
End If
End Get
Set(value As DataTable)
Dim AppNombre As String = String.Format("GlobalDTUnidadesMedida-{0}", CveEmpresa)
Application(AppNombre) = value
End Set
End Property
#End Region
Public Property CveEmpresa As Integer = 143