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_GRUPO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'Enrique Franco
'Clase CGrupo
'Funciones Básicas de Mantenimiento
'Propiedades :
'             AgregarGrupo
'             EliminarGrupo
'             ActualizarGrupo
'             ListarGrupos

Public Sub AgregarGrupo(ByVal StrCodigoGrupo As String, ByVal StrNombreGrupo 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_insprocse_grouprec '" & StrCodigoGrupo & "','" & StrNombreGrupo & "'," & "1,0,0,0,0"
 
 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 - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.AgregarGrupo", LStrMensajeError
             
End Sub
Public Sub EliminarGrupo(ByVal StrCodigoGrupo 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_grouprec '" & StrCodigoGrupo & "'"

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

Public Sub ActualizarGrupo(ByVal StrCodigoGrupo As String, ByVal StrNombreGrupo 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_updprocse_grouprec '" & StrCodigoGrupo & "','" & StrNombreGrupo & "'"

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 - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.ActualizarGrupo", LStrMensajeError
     
End Sub
Public Function ListarGrupos(Optional VarAux As Variant) As ADODB.Recordset
   Dim strSql As String
   Dim rs As ADODB.Recordset
   On Error GoTo ErrorHandler
   
   
   strSql = "Select groupid,groupname  from se_grouprec"
   Set rs = New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open strSql, "FILEDSN=conexionsies", adOpenDynamic, adLockBatchOptimistic
                    
   Set ListarGrupos = 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.ListarGrupos", Err.Description
    
End Function
Public Function existeGRUPO(ByVal StrCodigoGrupo 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 GROUPID from se_grouprec WHERE GROUPID='" + StrCodigoGrupo + "'"
        
    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
        existeGRUPO = False  'grupo NO EXISTE
    Else
        existeGRUPO = True  'grupo 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 - 2).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 2).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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.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_GRUPO.Auxiliar10", Err.Description
End Function





