VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "C_TIPOCAMBIO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'PROGRAMADOR: JOE GERARDO BREÑA HUACHIM

' Clase C_TIPOCAMBIO
' Funciones Básicas de Mantenimiento
'               AgregarTipoCambio
'               EliminarTipoCambio
'               ActualizarTipoCambio
'               ListarPorTipoCambio
'               ListarTipoCambio
'               ListarTipoCambioAyuda
Option Explicit

Public Sub AgregarTipoCambio(ByVal strCURYTYPEID As String, ByVal strFROMCURYID As String, ByVal strTOCURYID As String, _
StrCURYDATE As String, DblRATE As Double, StrOperador As String, StrUSERID As String, Optional VarAux As Variant)
    Dim cmd As ADODB.Command
    Dim con As ADODB.Connection
    Dim StrSql As String

    On Error GoTo TrataError
    
    
    StrSql = " EXEC SP_InsProcCURYRATE '" & strCURYTYPEID & "','" & strFROMCURYID & "','" & strTOCURYID & "'," & _
             "'" & StrCURYDATE & "'," & DblRATE & ",'" & StrOperador & "','" & StrUSERID & "'"
    
    Set cmd = New ADODB.Command
    cmd.CommandText = StrSql
      
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    cmd.ActiveConnection = con
       
    cmd.Execute
    
    'GetObjectContext.SetComplete
        
    Exit Sub
    
TrataError:
       
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_UT_MANTENIMIENTOS.AgregarTipoCambio", LStrMensajeError
    
End Sub

Public Sub EliminarTipoCambio(ByVal strCURYTYPEID As String, ByVal strFROMCURYID As String, ByVal strTOCURYID As String, _
StrCURYDATE As String, Optional VarAux As Variant)

    Dim con As ADODB.Connection
    Dim StrSql As String
    
    On Error GoTo TrataError
    
    StrSql = " EXEC SP_DelProcCURYRATE '" & strCURYTYPEID & "','" & strFROMCURYID & "','" & strTOCURYID & "'," & _
             "'" & StrCURYDATE & "'"
    
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute StrSql
    
    'GetObjectContext.SetComplete
    
    Exit Sub

TrataError:
  Dim LStrMensajeError As String
  Dim LVarNumeroError As Variant

    
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_UT_MANTENIMIENTOS.EliminarTipoCambio", LStrMensajeError

End Sub

Public Sub ActualizarTipoCambio(ByVal strCURYTYPEID As String, ByVal strFROMCURYID As String, ByVal strTOCURYID As String, _
StrCURYDATE As String, DblRATE As Double, StrOperador As String, StrUSERID As String, Optional VarAux As Variant)
    
    Dim con As ADODB.Connection
    Dim StrSql As String
    
    On Error GoTo TrataError
    
    StrSql = " EXEC SP_UpdProcCURYRATE '" & strCURYTYPEID & "','" & strFROMCURYID & "','" & strTOCURYID & "'," & _
             "'" & StrCURYDATE & "'," & DblRATE & ",'" & StrOperador & "','" & StrUSERID & "'"
    
    Set con = New ADODB.Connection
    con.Open "FILEDSN=conexionsies"
    con.Execute StrSql
    
    'GetObjectContext.SetComplete
    
    Exit Sub

TrataError:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_UT_MANTENIMIENTOS.ActualizarTipoCambio", LStrMensajeError

End Sub

Public Function ListarTiposCambio(Optional VarAux As Variant) As ADODB.Recordset
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    StrSql = "SELECT * FROM CURYRATETYPE"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarTiposCambio = rs
    
    'GetObjectContext.SetComplete
        
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarPorTipoCambio", Err.Description

End Function

Public Function ListarCambios(Optional VarAux As Variant) As ADODB.Recordset
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    StrSql = " SELECT * FROM CURYRATE ORDER BY CURYDATE ASC"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
       
    Set ListarCambios = rs
    
    'GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarTipoCambio", Err.Description

End Function

Public Function ListarTipoCambioAyuda(Optional VarAux As Variant) As ADODB.Recordset
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    StrSql = " SELECT CURYTYPEID,descr FROM CURYRATETYPE"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
            
    Set ListarTipoCambioAyuda = rs
    
    'GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarTipoCambioAyuda", Err.Description

End Function

Public Function ListarMonedas(Optional VarAux As Variant) As ADODB.Recordset
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    StrSql = " SELECT * FROM CURRENCY"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarMonedas = rs
    
    'GetObjectContext.SetComplete
        
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarPorTipoCambio", Err.Description

End Function

Function ListarCambiosAyuda(BlnTodo As Boolean, Optional StrTipoCambio As String, Optional StrFechaIni As String, Optional StrFechaFin As String, Optional StrOperador As String, Optional VarAux As Variant)
    Dim StrSql As String
    Dim rs As ADODB.Recordset
    Dim StrCondTipoCambio As String
    Dim StrCondFechas As String
    Dim StrCondOperador As String
    
    On Error GoTo TrataError
    
    
    If BlnTodo Then
'        ,CURRENCY
        StrSql = " SELECT CURYRATE.CURYTYPEID,CURYRATETYPE.Descr AS 'TIPO DE CAMBIO',CURYRATE.CURYDATE AS 'FECHA',CURYRATE.RATE AS 'MONTO',CURYRATE.FROMCURYID AS 'MON INICIO',CURYRATE.TOCURYID AS 'MON FINAL',CURYRATE.OPERADOR AS 'OPERADOR'" & _
        " FROM CURYRATE,CURYRATETYPE " & _
        " WHERE CURYRATETYPE.CURYTYPEID = CURYRATE.CURYTYPEID " & _
        " ORDER BY CURYDATE DESC "
    Else
        If StrTipoCambio <> Empty Then
            StrCondTipoCambio = " AND CURYRATE.CURYTYPEID='" & StrTipoCambio & "' "
        End If
        If StrFechaIni <> Empty Then
            StrCondFechas = " AND CURYRATE.CURYDATE >='" & StrFechaIni & "' AND CURYRATE.CURYDATE<='" & StrFechaFin & " 23:59' "
        End If
        If StrOperador <> Empty Then
            StrCondOperador = " AND CURYRATE.OPERADOR='" & StrOperador & "' "
        End If
          ',CURRENCY
        StrSql = " SELECT CURYRATE.CURYTYPEID,CURYRATETYPE.Descr AS 'TIPO DE CAMBIO',CURYRATE.CURYDATE AS 'FECHA',CURYRATE.RATE AS 'MONTO',CURYRATE.FROMCURYID AS 'MON INICIO',CURYRATE.TOCURYID AS 'MON FINAL',CURYRATE.OPERADOR AS 'OPERADOR'" & _
        " FROM CURYRATE,CURYRATETYPE " & _
        " WHERE CURYRATETYPE.CURYTYPEID = CURYRATE.CURYTYPEID " & StrCondTipoCambio & StrCondFechas & StrCondOperador & _
        " ORDER BY CURYDATE DESC "
    End If
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open StrSql, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarCambiosAyuda = rs
    
    'GetObjectContext.SetComplete
        
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If
    
    'GetObjectContext.SetAbort
    
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.ListarPorTipoCambio", Err.Description
    
End Function



Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar1", Err.Description
End Function


Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar2", Err.Description
End Function

Public Function Auxiliar3(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar3", Err.Description
End Function

Public Function Auxiliar4(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar4", Err.Description
End Function

Public Function Auxiliar5(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar5", Err.Description
End Function


Public Function Auxiliar6(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar6", Err.Description
End Function

Public Function Auxiliar7(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar7", Err.Description
End Function

Public Function Auxiliar8(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar8", Err.Description
End Function

Public Function Auxiliar9(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar9", Err.Description
End Function

Public Function Auxiliar10(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_UT_MANTENIMIENTOS.C_REIMPRE.Auxiliar10", Err.Description
End Function



