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_USUARIO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'Clase CUsuario
'Funciones Básicas de Mantenimiento

Option Explicit

Public Sub AgregarUsuario(ByVal StrCodigoUsuario As String, ByVal StrNombreUsuario As String, _
                          ByVal StrEmail As String, ByVal strlocation As String, ByVal StrPassWord As String, _
                          ByVal StrPhone As String, datvence As Date, ByVal bolactivo As Boolean, Optional VarAux As Variant)
       
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " sp_InsProcSE_USERREC '" & StrCodigoUsuario & "','" & StrNombreUsuario & "','" _
                             & StrEmail & "','" & strlocation & "',""" & StrPassWord & """,'" _
                             & StrPhone & "','" & CStr(datvence) & "'," & IIf(bolactivo, "1", "0") & ",1,0,0,0,0,'" & _
                             VarAux(1, 1) & "','" & VarAux(1, 2) & "'," & VarAux(1, 3) & "," & VarAux(1, 4)
                             
Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"
                             
Set cmd.ActiveConnection = con
cmd.Execute

 'GetObjectContext.SetComplete
 
Exit Sub
    
ErrorHandler:
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 - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.AgregarUsuario", LStrMensajeError
     
End Sub

Public Sub EliminarUsuario(ByVal StrCodigoUsuario As String, Optional VarAux As Variant)
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
On Error GoTo ErrorHandler
Set cmd = New ADODB.Command
cmd.CommandText = " sp_DELProcSE_USERREC '" & StrCodigoUsuario & "'"

Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"

Set cmd.ActiveConnection = con
cmd.Execute

'GetObjectContext.SetComplete

Exit Sub
    
ErrorHandler:
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 - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.EliminarUsuario", LStrMensajeError
     
End Sub
Public Sub ActualizarUsuario(ByVal StrCodigoUsuario As String, ByVal StrNombreUsuario As String, _
                             ByVal StrEmail As String, ByVal strlocation As String, ByVal StrPassWord As String, _
                             ByVal StrPhone As String, datvence As Date, ByVal bolactivo As Boolean, Optional VarAux As Variant)
                               
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim strSql As String

On Error GoTo ErrorHandler
Set cmd = New ADODB.Command

strSql = " sp_UPDProcSE_USERREC '" & StrCodigoUsuario & "','" & StrNombreUsuario & "','" _
                             & StrEmail & "','" & strlocation & "',""" & StrPassWord & """,'" _
                             & StrPhone & "','" & CStr(datvence) & "'," & IIf(bolactivo, "1", "0") & ",0,1,0,0,0,'" & _
                             VarAux(1, 1) & "','" & VarAux(1, 2) & "'," & VarAux(1, 3) & "," & VarAux(1, 4)
cmd.CommandText = strSql

Set con = New ADODB.Connection
con.Open "FILEDSN=conexionsies"

Set cmd.ActiveConnection = con
cmd.Execute
    
'GetObjectContext.SetComplete
Exit Sub
    
ErrorHandler:
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 - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.ActualizarUsuario", LStrMensajeError
     
End Sub
Public Function ListarUsuarios(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSql As String
   Dim rs As ADODB.Recordset
   On Error GoTo ErrorHandler
    strSql = "select * from se_userrec"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSql, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
    Set ListarUsuarios = rs
    
    'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
      
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.ListarUsuarios", Err.Description
    
End Function

Public Function ListarUsuariosAyuda(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSql As String
   Dim rs As ADODB.Recordset
   On Error GoTo ErrorHandler
    strSql = "select USERID,USERNAME from se_userrec"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSql, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
    Set ListarUsuariosAyuda = rs
    
    'GetObjectContext.SetComplete
   
   Exit Function
ErrorHandler:
   If Not rs Is Nothing Then
      Set rs = Nothing
   End If
      
   'GetObjectContext.SetAbort
   
   Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.ListarUsuariosAyuda", Err.Description
    
End Function

Public Function existeUsuario(ByVal StrCodigoUsuario As String, Optional VarAux As Variant) As Boolean
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String

On Error GoTo ErrorHandler
'Funcion de Encriptación del password
    
    
    strSql = "select userid from se_userrec where userid='" + StrCodigoUsuario + "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    
    If rs.RecordCount = 0 Or rs.EOF Then
        existeUsuario = False  'USUARIO NO EXISTE
    Else
        existeUsuario = True  'USUARIO EXISTE
    
    End If
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.ValidarUsuario", LStrMensajeError
     
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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.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_SE_MANTENIMIENTOS.C_USUARIO.Auxiliar10", Err.Description
End Function







