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_MONEDA"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Clase C_MONEDA
' Funciones Básicas de Mantenimiento
'               AgregarMoneda
'               EliminarMoneda
'               ActualizarMoneda
'               ListarPorMonedaID
'               ListarMonedas
Option Explicit

Public Sub AgregarMoneda(ByVal strCURYID As String, ByVal strDESCR As String, ByVal strDESCRMONEY 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_InsProcCURRENCY '" & strCURYID & "','" & strDESCR & "','" & _
                                            strDESCRMONEY & "'"
               
    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_MA_MANTENIMIENTOS.AgregarMoneda", LStrMensajeError

End Sub

Public Sub EliminarMoneda(ByVal strCURYID As String, Optional VarAux As Variant)
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_DelProcCURRENCY '" & strCURYID & "'"
    
    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_MA_MANTENIMIENTOS.EliminarMoneda", LStrMensajeError
 
End Sub

Public Sub ActualizarMoneda(ByVal strCURYID As String, ByVal strDESCR As String, ByVal strDESCRMONEY As String, Optional VarAux As Variant)
    
    Dim con As ADODB.Connection
    Dim strSQL As String
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_UpdProcCURRENCY '" & strCURYID & "','" & strDESCR & "','" & _
                                            strDESCRMONEY & "'"
    
    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_MA_MANTENIMIENTOS.ActualizarMoneda", LStrMensajeError

End Sub

Public Function ListarPorMonedaID(ByVal strCURYID As String, Optional VarAux As Variant) As ADODB.Recordset
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    
    On Error GoTo TrataError
    
    strSQL = " EXEC SP_SelProcCURRENCY '" & strCURYID & "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, "FILEDSN=conexionsies", adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        
    Set ListarPorMonedaID = rs
    
    ''GetObjectContext.SetComplete
    
    Exit Function
    
TrataError:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.ListarPorMonedaID", 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 CURYID,DESCR,DESCRMONEY 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_MA_MANTENIMIENTOS.ListarMonedas", Err.Description

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

End Function

Public Function ObtenerMonedaExtranjera(ByVal strMONEDABASE As String, Optional VarAux As Variant) As String
   Dim strSQL As String
   Dim rs As ADODB.Recordset
   Dim cmd As ADODB.Recordset
    
   On Error GoTo errhandler
   
   strSQL = " Select top 1 curyid from currency where curyid <> '" & strMONEDABASE & "'"
              
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSQL, "FILEDSN=conexionsies", adOpenStatic
                
   If rs.EOF Then
      ObtenerMonedaExtranjera = Empty
   Else
      ObtenerMonedaExtranjera = rs!CURYID
   End If
      
   ''GetObjectContext.SetComplete
   Exit Function
errhandler:
    If Not rs Is Nothing Then
        Set rs = Nothing
    End If

   'GetObjectContext.SetAbort
   Err.Raise Err.Number, "DB_MA_MANTENIMIENTOS.ObtenerMonedaExtranjera", 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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.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_MA_MANTENIMIENTOS.C_MONEDA.Auxiliar10", Err.Description
End Function



