-- nuevo esquema
This commit is contained in:
@@ -16,6 +16,7 @@ Public Class ClsFISConfiguracion
|
|||||||
Private SqlConexion As SqlConnection
|
Private SqlConexion As SqlConnection
|
||||||
Private SqlAdapter As SqlDataAdapter
|
Private SqlAdapter As SqlDataAdapter
|
||||||
Private SqlCommand As SqlCommand
|
Private SqlCommand As SqlCommand
|
||||||
|
Private SqlTransacc As SqlTransaction
|
||||||
Private Data As DataTable
|
Private Data As DataTable
|
||||||
|
|
||||||
'Atributos de la clase
|
'Atributos de la clase
|
||||||
@@ -23,6 +24,7 @@ Public Class ClsFISConfiguracion
|
|||||||
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
|
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
|
||||||
'REGISTRAR CONEXIONES ABIERTAS
|
'REGISTRAR CONEXIONES ABIERTAS
|
||||||
Private CveConexion As Integer = 0
|
Private CveConexion As Integer = 0
|
||||||
|
Private EsTransaccionCompartida As Boolean = False
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "Propiedades"
|
#Region "Propiedades"
|
||||||
@@ -42,20 +44,38 @@ Public Class ClsFISConfiguracion
|
|||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Sub New()
|
Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
|
||||||
SqlConexion = New SqlConnection
|
|
||||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
If TransaccionCompartida Is Nothing Then
|
||||||
Try
|
SqlConexion = New SqlConnection
|
||||||
SqlConexion.Open()
|
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||||
Catch ex As Exception
|
Try
|
||||||
Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
SqlConexion.Open()
|
||||||
End Try
|
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()
|
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
|
End Sub
|
||||||
#Region "Conexiones"
|
#Region "Conexiones"
|
||||||
|
|
||||||
Private Sub ConexionAdd()
|
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
|
Try
|
||||||
DataAdapter("PA_Sis_RegistrarConexion")
|
DataAdapter("PA_Sis_RegistrarConexion")
|
||||||
With SqlAdapter.SelectCommand.Parameters
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
@@ -87,21 +107,14 @@ Public Class ClsFISConfiguracion
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
End Sub
|
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
|
#End Region
|
||||||
|
|
||||||
Public Function GetConfiguracion(CveEmpresa As Integer) As Boolean
|
Public Function GetConfiguracion(CveEmpresa As Integer) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
Data = New DataTable
|
|
||||||
SqlAdapter = New SqlDataAdapter("PA_Fis_CuentaContablesGet", SqlConexion)
|
DataAdapter("PA_Fis_CuentaContablesGet")
|
||||||
SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
|
|
||||||
SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||||
Try
|
Try
|
||||||
SqlAdapter.Fill(Data)
|
SqlAdapter.Fill(Data)
|
||||||
@@ -117,16 +130,15 @@ Public Class ClsFISConfiguracion
|
|||||||
Catch ex As SqlException
|
Catch ex As SqlException
|
||||||
OnError("Ocurrió un error al consultar las Configuraciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
OnError("Ocurrió un error al consultar las Configuraciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
End Try
|
End Try
|
||||||
SqlAdapter.Dispose()
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function AddConfiguracion(ActIVAAcreditable As Integer, ActIVAxAcreditar As Integer, PasIVAPagar As Integer, PasIVAxPagar As Integer,
|
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
|
EROtrosIngresos As Integer, ERDSV As Integer, CveEmpresa As Integer) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
Data = New DataTable
|
|
||||||
SqlAdapter = New SqlDataAdapter("PA_Fis_CuentaContablesAdd", SqlConexion)
|
DataAdapter("PA_Fis_CuentaContablesAdd")
|
||||||
SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
|
|
||||||
|
|
||||||
With SqlAdapter.SelectCommand.Parameters
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
.Add("@ActIVAAcreditable", SqlDbType.VarChar).Value = ActIVAAcreditable
|
.Add("@ActIVAAcreditable", SqlDbType.VarChar).Value = ActIVAAcreditable
|
||||||
@@ -150,7 +162,7 @@ Public Class ClsFISConfiguracion
|
|||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
OnError("Ocurrió un error al Guardar la Configuración.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
OnError("Ocurrió un error al Guardar la Configuración.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
End Try
|
End Try
|
||||||
SqlAdapter.Dispose()
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user