-- unificar y se eliminó clsmetodos

This commit is contained in:
2024-04-18 20:23:17 -07:00
parent 4628c35a7a
commit 071de5481b
3 changed files with 2 additions and 146 deletions

View File

@@ -1,144 +0,0 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Imports Extensiones
Public Class ClsMetodosPagos
Implements IDisposable
#Region "Campos"
'SQL
Private SqlConexion As SqlConnection
Private SqlAdapter As SqlDataAdapter
Private SqlCommand As SqlCommand
Private Data As DataTable
'Atributos de la clase
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0
#End Region
#Region "Propiedades"
Public ReadOnly Property DtResultados() As DataTable
Get
DtResultados = Data
End Get
End Property
#End Region
Sub New()
SqlConexion = New SqlConnection
SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB
Try
SqlConexion.Open()
Catch ex As Exception
Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
End Try
SqlAdapter = New SqlDataAdapter("", SqlConexion)
ConexionAdd()
End Sub
#Region "Conexiones"
Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try
DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
.Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString)
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
End With
SqlAdapter.Fill(Data)
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
Catch ex As Exception
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
End If
End Sub
Private Sub ConexionClose()
If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text)
Try
SqlAdapter.Fill(Data)
Catch ex As Exception
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
CveConexion = 0
End If
End Sub
Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
With SqlAdapter.SelectCommand
.Parameters.Clear()
.CommandText = pStrSQL
.CommandType = TipoComando
End With
Data = New DataTable
End Sub
#End Region
'Public Function GetMetodosPago() As Boolean
' Dim Retorno As Boolean = False
' Data = New DataTable
' SqlAdapter = New SqlDataAdapter("PA_MetodosPagosGet", SqlConexion)
' SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
' Try
' SqlAdapter.Fill(Data)
' Retorno = True
' Catch ex As SqlException
' OnError("Ocurrió un error al consultar los Métodos de Pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
' End Try
' SqlAdapter.Dispose()
' Return Retorno
'End Function
#Region "IDisposable Support"
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
If Not Data Is Nothing Then Data.Dispose() : Data = Nothing
If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() : SqlAdapter = Nothing
If Not SqlCommand Is Nothing Then SqlCommand.Dispose() : SqlCommand = Nothing
If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close()
If Not SqlConexion Is Nothing Then SqlConexion.Dispose() : SqlConexion = Nothing
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
ConexionClose()
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class

View File

@@ -464,7 +464,7 @@ Partial Class Sistemas_CatSesiones
'End Sub 'End Sub
Private Sub CargaMetodosPago() Private Sub CargaMetodosPago()
Dim ObjMetodoPago As New ClsMetodosPagos() Dim ObjMetodoPago As New ClsVentas()
If ObjMetodoPago.GetMetodosPago() Then If ObjMetodoPago.GetMetodosPago() Then
Application("GlobalDTMetodosPago") = ObjMetodoPago.DtResultados Application("GlobalDTMetodosPago") = ObjMetodoPago.DtResultados
Else Else

View File

@@ -816,7 +816,7 @@ Public Class WS_PuntoVenta
#Region "MetodosPago" #Region "MetodosPago"
<WebMethod()> <WebMethod()>
Public Function GetMetodosPagos() As RespuestaWS Public Function GetMetodosPagos() As RespuestaWS
Dim objMetodoPago As New ClsMetodosPagos Dim objMetodoPago As New ClsVentas
Dim Respuesta As New RespuestaWS Dim Respuesta As New RespuestaWS
If objMetodoPago.GetMetodosPago() Then If objMetodoPago.GetMetodosPago() Then