VERSION 5.00
Object = "{5C8CED40-8909-11D0-9483-00A0C91110ED}#1.0#0"; "MSDATREP.OCX"
Begin VB.Form fderechosusuariosgrupos 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Derechos Usuarios/Grupos (96.020.00)"
   ClientHeight    =   3915
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10290
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3915
   ScaleWidth      =   10290
   StartUpPosition =   2  'CenterScreen
   Begin MSDataRepeaterLib.DataRepeater DERECHOS 
      Height          =   2190
      Left            =   0
      TabIndex        =   0
      Top             =   960
      Width           =   10215
      _ExtentX        =   18018
      _ExtentY        =   3836
      _StreamID       =   -1412567295
      _Version        =   393216
      Caption         =   ""
      BeginProperty RepeatedControlName {21FC0FC0-1E5C-11D1-A327-00AA00688B10} 
         _StreamID       =   -1412567295
         _Version        =   65536
         Name            =   "DERECHOS_USUARIOS.CTRL_DERECHOS_1"
      EndProperty
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Agregar Todos"
      Height          =   855
      Left            =   8880
      Picture         =   "CF9602000.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   0
      Width           =   1215
   End
   Begin VB.CommandButton cmd_eliminar 
      Caption         =   "Eliminar"
      Height          =   615
      Left            =   4080
      Picture         =   "CF9602000.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   3240
      Width           =   1455
   End
   Begin VB.CommandButton Cmd_agregar 
      Caption         =   "Agregar"
      Height          =   615
      Left            =   240
      Picture         =   "CF9602000.frx":040C
      Style           =   1  'Graphical
      TabIndex        =   6
      TabStop         =   0   'False
      Top             =   3240
      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            =   1920
      Picture         =   "CF9602000.frx":093E
      Style           =   1  'Graphical
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   3240
      Width           =   1455
   End
   Begin VB.CommandButton cmd_cancelar 
      Cancel          =   -1  'True
      Caption         =   "Cancelar"
      Height          =   615
      Left            =   7080
      Picture         =   "CF9602000.frx":0E70
      Style           =   1  'Graphical
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   3240
      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
' Se retiraron los Fuentes de la red el 24/04/2003
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        'numero de filas
Dim li_grab As Integer          'numero de grabaciones
Dim li_nblancos As Integer          'numero de grabaciones
Dim li_nduplicados As Integer          'numero de grabaciones
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
Dim LB_NULL As Boolean
Dim LB_CLOSE As Boolean

On Error GoTo errhandler

LS_USERID = TXT_ID.Text
'borrar derechos
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
        LB_NULL = rs_derechos!nullRIGHTS
        LB_CLOSE = rs_derechos!closeRIGHTS
        
        If Len(Trim(LS_SCREENID)) > 0 Then    ' si la fila esta en blanco no la graba
            ' SI NO EXISTE YA EL DERECHO GRABAR
            If Not mobj_cseguridad.existe_derechosUsuario(LS_USERID, LS_SCREENID) Then
                MOBJ_CDERECHOSACCESO.AgregarDerechoDetalle LS_USERID, LS_SCREENID, LB_VIEW, LB_INSERT, LB_UPDATE, LB_DELETE, LB_PRINT, LB_NULL, LB_CLOSE
                li_grab = li_grab + 1
            Else
                MsgBox "Derecho Duplicado para la pantalla " + LS_SCREENID + Chr(13) + "El ultimo cambio de la pantalla fue ignorado", vbInformation, "Atencion "
                li_nduplicados = li_nduplicados + 1
            End If
        Else
            li_nblancos = li_nblancos + 1
        End If
        rs_derechos.MoveNext
    Loop
End If
MsgBox Str(LI_NFILAS) + " Registros Encontrados " + Chr(13) + _
        Str(li_nblancos) + " Filas en blanco " + Chr(13) + _
        Str(li_nduplicados) + " filas Duplicadas " + Chr(13) + _
        Str(li_grab) + " Registros Grabados", vbInformation, "Mensaje"
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 Command1_Click()
If MsgBox("Esta Seguro de agregar Derechos a todos los Screens", vbYesNo, "Atencion") = vbYes Then
    Dim LS_USERID  As String
    LS_USERID = TXT_ID.Text
    MOBJ_CDERECHOSACCESO.AGREGARTODOSLOSDERECHOS LS_USERID
    Call cargadatos
    MsgBox "Todos los Screens fueron Agregados", vbInformation, "Mensaje"
    'DERECHOS.Refresh
End If
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

rs_derechos.CursorLocation = adUseClient
Call cargadatos

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

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_null", "nullrights"
DERECHOS.RepeaterBindings.Add "r_close", "closerights"
DERECHOS.RepeaterBindings.Add "R_Descr", "screenid"

End Sub

Private Sub Form_Load()
Set mobj_cseguridad = New DB_SE_MANTENIMIENTOS.c_seguridad
Set MOBJ_CDERECHOSACCESO = New DB_SE_MANTENIMIENTOS.C_DERECHOSACCESO
Me.Top = 2000
Me.Left = (Screen.Width - Me.Width) / 2
End Sub

Private Sub cargadatos()
Set rs_derechos = mobj_cseguridad.listar_derechosgrupousuario(Trim(TXT_ID.Text), txt_type.Text)
Set DERECHOS.DataSource = rs_derechos
End Sub
