VERSION 5.00
Object = "{5C8CED40-8909-11D0-9483-00A0C91110ED}#1.0#0"; "MSDATREP.OCX"
Begin VB.Form fderechosusuariosgrupos 
   Caption         =   "Derechos Usuarios/Grupos (96.020.00)"
   ClientHeight    =   4125
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9780
   LinkTopic       =   "Form1"
   ScaleHeight     =   4125
   ScaleWidth      =   9780
   StartUpPosition =   3  'Windows Default
   Begin MSDataRepeaterLib.DataRepeater DERECHOS 
      Height          =   1995
      Left            =   0
      TabIndex        =   0
      Top             =   840
      Width           =   9615
      _ExtentX        =   16960
      _ExtentY        =   3519
      _StreamID       =   -1412567295
      _Version        =   393216
      Caption         =   ""
      BeginProperty RepeatedControlName {21FC0FC0-1E5C-11D1-A327-00AA00688B10} 
         _StreamID       =   -1412567295
         _Version        =   65536
         Name            =   "DERECHOS_USUARIOS.CTRL_DERECHOS"
      EndProperty
   End
   Begin VB.CommandButton cmd_eliminar 
      Caption         =   "Eliminar"
      Height          =   615
      Left            =   4200
      Picture         =   "CF9602000.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   3360
      Width           =   1455
   End
   Begin VB.CommandButton Cmd_agregar 
      Caption         =   "Agregar"
      Height          =   615
      Left            =   360
      Picture         =   "CF9602000.frx":0102
      Style           =   1  'Graphical
      TabIndex        =   6
      TabStop         =   0   'False
      Top             =   3360
      Width           =   1455
   End
   Begin VB.TextBox txt_type 
      Enabled         =   0   'False
      Height          =   285
      Left            =   240
      TabIndex        =   5
      TabStop         =   0   'False
      Top             =   120
      Width           =   2175
   End
   Begin VB.CommandButton cmd_aceptar 
      Caption         =   "Grabar"
      Height          =   615
      Left            =   2040
      Picture         =   "CF9602000.frx":0634
      Style           =   1  'Graphical
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   3360
      Width           =   1455
   End
   Begin VB.CommandButton cmd_cancelar 
      Cancel          =   -1  'True
      Caption         =   "Cancelar"
      Height          =   615
      Left            =   7800
      Picture         =   "CF9602000.frx":0B66
      Style           =   1  'Graphical
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   3360
      Width           =   1455
   End
   Begin VB.TextBox TXT_ID 
      Enabled         =   0   'False
      Height          =   285
      Left            =   240
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   480
      Width           =   2175
   End
   Begin VB.TextBox TXT_NOMBRE 
      Enabled         =   0   'False
      Height          =   285
      Left            =   2640
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   480
      Width           =   3615
   End
End
Attribute VB_Name = "fderechosusuariosgrupos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs_derechos As ADODB.Recordset
Dim rs_SCREEN As ADODB.Recordset
Dim MOBJ_CDERECHOSACCESO As DB_SE_MANTENIMIENTOS.C_DERECHOSACCESO
Dim mobj_cseguridad As DB_SE_MANTENIMIENTOS.c_seguridad
Private Sub CMD_ACEPTAR_Click()
Dim LI_NFILAS As Integer
Dim LS_USERID As String
Dim LS_SCREENID As String
Dim LB_VIEW As Boolean
Dim LB_INSERT As Boolean
Dim LB_UPDATE As Boolean
Dim LB_DELETE As Boolean
Dim LB_PRINT As Boolean

On Error GoTo errhandler

LS_USERID = TXT_ID.Text
'borrar derechos
Set MOBJ_CDERECHOSACCESO = New DB_SE_MANTENIMIENTOS.C_DERECHOSACCESO
MOBJ_CDERECHOSACCESO.EliminarDerecho LS_USERID
LI_NFILAS = rs_derechos.RecordCount

'agregar los nuevos derechos
If LI_NFILAS > 0 Then
    rs_derechos.MoveFirst
    Do While Not rs_derechos.EOF
        LS_SCREENID = rs_derechos!SCREENID
        LB_VIEW = rs_derechos!ViewRIGHTS
        LB_INSERT = rs_derechos!iNSERTRIGHTS
        LB_UPDATE = rs_derechos!uPDATERIGHTS
        LB_DELETE = rs_derechos!dELETERIGHTS
        LB_PRINT = rs_derechos!pRINTRIGHTS
        
        MOBJ_CDERECHOSACCESO.AgregarDerechoDetalle LS_USERID, LS_SCREENID, LB_VIEW, LB_INSERT, LB_UPDATE, LB_DELETE, LB_PRINT
        rs_derechos.MoveNext
    Loop
End If

Unload Me

Exit Sub
errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"

End Sub

Private Sub Cmd_agregar_Click()
On Error GoTo errhandler
With rs_derechos
    .AddNew
    !SCREENID = " "
    !screenname = " "
End With

Exit Sub
errhandler:
   MsgBox Err.Description, vbDefaultButton1 + vbCritical, "Advertencia"
End Sub

Private Sub cmd_cancelar_Click()
Unload Me
End Sub

Private Sub cmd_eliminar_Click()
On Error GoTo errhandler

If rs_derechos.RecordCount > 0 Then
    rs_derechos.Delete
End If

Exit Sub
errhandler:
    MsgBox Err.Description, vbDefaultButton1 + vbCritical, "Advertencia"
End Sub

Private Sub DERECHOS_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 40 And Not rs_derechos.EOF Then
    rs_derechos.MoveNext
End If
If KeyCode = 38 And Not rs_derechos.BOF Then
    rs_derechos.MovePrevious
End If
End Sub

Private Sub Form_Activate()
Dim lstr_cadena As String
Dim ls_titu As String
Dim xx As Variant
Set rs_derechos = New ADODB.Recordset
Set rs_SCREEN = New ADODB.Recordset

'Set rs_derechos = New ADODB.Recordset
rs_derechos.CursorLocation = adUseClient

Set rs_derechos = mobj_cseguridad.listar_derechosgrupousuario(Trim(TXT_ID.Text), txt_type.Text)

'rs_SCREEN.Open "SELECT SCREENID,SCREENNAME FROM SE_SCREEN", cnxprueba, adOpenDynamic, adLockBatchOptimistic


ls_titu = Space(60) + "Screen" + Space(43) + "Consultar  Agregar  Modificar Eliminar Imprimir"
DERECHOS.Caption = ls_titu

Set DERECHOS.DataSource = rs_derechos
DERECHOS.RepeaterBindings.Add "r_screenid", "screenid"
DERECHOS.RepeaterBindings.Add "r_screenname", "screenname"
DERECHOS.RepeaterBindings.Add "r_view", "viewrights"
DERECHOS.RepeaterBindings.Add "r_insert", "insertrights"
DERECHOS.RepeaterBindings.Add "r_update", "updaterights"
DERECHOS.RepeaterBindings.Add "r_delete", "deleterights"
DERECHOS.RepeaterBindings.Add "r_print", "printrights"
DERECHOS.RepeaterBindings.Add "R_Descr", "screenid"
End Sub

Private Sub Form_Load()
Set mobj_cseguridad = New DB_SE_MANTENIMIENTOS.c_seguridad
End Sub
