📄 frmpermissions.frm
字号:
VERSION 5.00
Begin VB.Form frmPermissions
Caption = "Permitter"
ClientHeight = 4005
ClientLeft = 60
ClientTop = 345
ClientWidth = 5910
LinkTopic = "Form1"
ScaleHeight = 4005
ScaleWidth = 5910
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdSave
Caption = "&Save"
Height = 375
Left = 4560
TabIndex = 14
Top = 2040
Width = 1275
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Default = -1 'True
Height = 375
Left = 4560
TabIndex = 13
Top = 360
Width = 1275
End
Begin VB.Frame fraPermissions
Caption = "Permissions"
Height = 1995
Left = 60
TabIndex = 4
Top = 1920
Width = 4335
Begin VB.CheckBox chkPermission
Caption = "&Delete Data"
Height = 195
Index = 6
Left = 2340
TabIndex = 12
Top = 1620
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "R&ead Data"
Height = 195
Index = 3
Left = 2340
TabIndex = 9
Top = 720
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "&Update Data"
Height = 195
Index = 4
Left = 2340
TabIndex = 10
Top = 1020
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "&Insert Data"
Height = 195
Index = 5
Left = 2340
TabIndex = 11
Top = 1320
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "&Administer"
Height = 195
Index = 2
Left = 240
TabIndex = 8
Top = 1320
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "&Modify Design"
Height = 195
Index = 1
Left = 240
TabIndex = 7
Top = 1020
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "&Read Design"
Height = 195
Index = 0
Left = 240
TabIndex = 6
Top = 720
Width = 1575
End
Begin VB.Label lblPermissionCode
Alignment = 1 'Right Justify
Caption = "Permission Code:"
Height = 195
Left = 240
TabIndex = 15
Top = 300
Width = 1755
End
Begin VB.Label lblPermissions
Caption = "0"
Height = 195
Left = 2400
TabIndex = 5
Top = 300
Width = 1395
End
End
Begin VB.ListBox lstTablesAndQueries
Height = 1425
Left = 2340
TabIndex = 3
Top = 360
Width = 2055
End
Begin VB.ListBox lstUsers
Height = 1425
Left = 60
TabIndex = 1
Top = 360
Width = 2055
End
Begin VB.Label lblTablesAndQueries
Caption = "&Tables and Queries"
Height = 195
Left = 2400
TabIndex = 2
Top = 120
Width = 1455
End
Begin VB.Label lblUsers
Caption = "&Users"
Height = 195
Left = 120
TabIndex = 0
Top = 120
Width = 555
End
End
Attribute VB_Name = "frmPermissions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' form level object variable used to store database object
Private db As Database
' form level constant declarations which correspond to check boxes on the
' frmPermitter form
Const PER_READ_DESIGN = 0
Const PER_MODIFY_DESIGN = 1
Const PER_ADMINISTER = 2
Const PER_READ_DATA = 3
Const PER_UPDATE_DATA = 4
Const PER_INSERT_DATA = 5
Const PER_DELETE_DATA = 6
' form level constant declarations which indicate various permissions
Const DB_NOPERMISSIONS = 0
Const DB_READDESIGN = 4
Const DB_READDATA = 20
Const DB_INSERTDATA = 52
Const DB_UPDATEDATA = 84
Const DB_UPDATEINSERTDATA = 116
Const DB_DELETEDATA = 148
Const DB_INSERTDELETEDATA = 180
Const DB_UPDATEDELETEDATA = 212
Const DB_UPDATEINSERTDELETEDATA = 244
Const DB_MODIFYDESIGN = 65756
Const DB_MODIFYDESIGN_INSERTDATA = 65788
Const DB_READSEC = 131072
Const DB_ADMINISTER = 852478
Private Sub Form_Load()
' if there is an error then goto the code section labeled by ERR_Form_Load
On Error GoTo ERR_Form_Load:
Dim sUserName As String
Dim sPassword As String
Dim sDBName As String
' assign default user name and password
sUserName = "Admin"
sPassword = ""
With DBEngine
' set system database path and name
.SystemDB = GetWorkgroupDatabase
' set default user name and password
.DefaultUser = sUserName
.DefaultPassword = sPassword
' get path and name of database from ReadINI module
sDBName = DBPath
' open database
Set db = .Workspaces(0).OpenDatabase(sDBName)
End With
' populate the two list boxes with the available users, tables, and
' queries from database
FillUserList
FillTableAndQueriesList
' if there are no valid users, inform the user and exit the application
If (lstUsers.ListCount < 1) Then
MsgBox "There are no users!", vbExclamation, "USERS"
cmdClose_Click
Else
' initialize the list boxes to point to the first item in each list box
lstUsers.ListIndex = 0
lstTablesAndQueries.ListIndex = 0
End If
Exit Sub
ERR_Form_Load:
' display error for the user
With Err
MsgBox "ERROR #" & .Number & ": " & .Description, vbExclamation, _
"ERROR"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
' close the database
Set db = Nothing
End Sub
Private Sub lstUsers_Click()
' if the TablesAndQueries list box is set to one of the items, call the
' ReadPermissions procedure and if there was an error, unselect all
' check boxes
If (lstTablesAndQueries.ListIndex >= 0) Then
If (Not ReadPermissions()) Then
lstUsers.ListIndex = -1
UnCheckAll
End If
End If
End Sub
Private Sub lstTablesAndQueries_Click()
' if the Users list box is set to one of the items, call the
' ReadPermissions procedure and if there was an error, unselect all
' check boxes
If (lstUsers.ListIndex >= 0) Then
If (Not ReadPermissions()) Then
lstTablesAndQueries.ListIndex = -1
UnCheckAll
End If
End If
End Sub
Private Sub chkPermission_Click(Index As Integer)
Dim nCount As Integer
With chkPermission(Index)
' set the appropriate check boxe values dependant upon the others
Select Case Index
Case PER_READ_DESIGN:
If (.Value = vbUnchecked) Then
For nCount = 0 To 6
chkPermission(nCount).Value = vbUnchecked
Next nCount
End If
Case PER_MODIFY_DESIGN:
If (.Value = vbChecked) Then
chkPermission(PER_READ_DESIGN).Value = vbChecked
chkPermission(PER_READ_DATA).Value = vbChecked
chkPermission(PER_UPDATE_DATA).Value = vbChecked
chkPermission(PER_INSERT_DATA).Value = vbChecked
Else
chkPermission(PER_ADMINISTER).Value = vbUnchecked
End If
Case PER_ADMINISTER:
If (.Value = vbChecked) Then
For nCount = 0 To 6
chkPermission(nCount).Value = vbChecked
Next nCount
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -