-- nuevo esquema

This commit is contained in:
rrene
2020-07-01 16:06:41 -07:00
parent 4af23d2073
commit ce49be940b

View File

@@ -16,6 +16,7 @@ Public Class ClsFISConfiguracion
Private SqlConexion As SqlConnection
Private SqlAdapter As SqlDataAdapter
Private SqlCommand As SqlCommand
Private SqlTransacc As SqlTransaction
Private Data As DataTable
'Atributos de la clase
@@ -23,6 +24,7 @@ Public Class ClsFISConfiguracion
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
#End Region
#Region "Propiedades"
@@ -42,20 +44,38 @@ Public Class ClsFISConfiguracion
#End Region
Sub New()
SqlConexion = New SqlConnection
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
Try
SqlConexion.Open()
Catch ex As Exception
Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
If TransaccionCompartida Is Nothing Then
SqlConexion = New SqlConnection
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
Try
SqlConexion.Open()
Catch ex As Exception
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
End Try
Else
SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If
SqlAdapter = New SqlDataAdapter("", SqlConexion)
ConexionAdd()
End Sub
Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure)
With SqlAdapter.SelectCommand
.Parameters.Clear()
.CommandText = pStrSQL
.CommandType = TipoComando
End With
If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc
Data = New DataTable
End Sub
#Region "Conexiones"
Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try
DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters
@@ -87,21 +107,14 @@ Public Class ClsFISConfiguracion
End If
End Sub
Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
With SqlAdapter.SelectCommand
.Parameters.Clear()
.CommandText = StrSQL
.CommandType = TipoComando
End With
Data = New DataTable
End Sub
#End Region
Public Function GetConfiguracion(CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
Data = New DataTable
SqlAdapter = New SqlDataAdapter("PA_Fis_CuentaContablesGet", SqlConexion)
SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
DataAdapter("PA_Fis_CuentaContablesGet")
SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
Try
SqlAdapter.Fill(Data)
@@ -117,16 +130,15 @@ Public Class ClsFISConfiguracion
Catch ex As SqlException
OnError("Ocurrió un error al consultar las Configuraciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
SqlAdapter.Dispose()
Return Retorno
End Function
Public Function AddConfiguracion(ActIVAAcreditable As Integer, ActIVAxAcreditar As Integer, PasIVAPagar As Integer, PasIVAxPagar As Integer,
EROtrosIngresos As Integer, ERDSV As Integer, CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
Data = New DataTable
SqlAdapter = New SqlDataAdapter("PA_Fis_CuentaContablesAdd", SqlConexion)
SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
DataAdapter("PA_Fis_CuentaContablesAdd")
With SqlAdapter.SelectCommand.Parameters
.Add("@ActIVAAcreditable", SqlDbType.VarChar).Value = ActIVAAcreditable
@@ -150,7 +162,7 @@ Public Class ClsFISConfiguracion
Catch ex As Exception
OnError("Ocurrió un error al Guardar la Configuración.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
SqlAdapter.Dispose()
Return Retorno
End Function