📄 frmpermissions.frm
字号:
VERSION 5.00
Begin VB.Form frmPermissions
Caption = "用户的数据库权限管理"
ClientHeight = 4785
ClientLeft = 60
ClientTop = 345
ClientWidth = 4980
LinkTopic = "Form1"
ScaleHeight = 4785
ScaleWidth = 4980
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 4212
Left = 0
TabIndex = 1
Top = 0
Width = 4932
Begin VB.CommandButton cmdSave
Caption = "保存设置"
Height = 375
Left = 1800
TabIndex = 14
Top = 3720
Width = 1275
End
Begin VB.ListBox lstUsers
Height = 1140
Left = 240
TabIndex = 11
Top = 480
Width = 2055
End
Begin VB.ListBox lstTablesAndQueries
Height = 1140
Left = 2520
TabIndex = 10
Top = 480
Width = 2055
End
Begin VB.Frame fraPermissions
Caption = "权限"
Height = 1632
Left = 240
TabIndex = 2
Top = 1920
Width = 4335
Begin VB.CheckBox chkPermission
Caption = "读取设计数据"
Height = 195
Index = 0
Left = 240
TabIndex = 9
Top = 360
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "修改设计数据"
Height = 195
Index = 1
Left = 240
TabIndex = 8
Top = 660
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "管理员"
Height = 195
Index = 2
Left = 240
TabIndex = 7
Top = 960
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "插入数据"
Height = 195
Index = 5
Left = 2340
TabIndex = 6
Top = 960
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "更新数据"
Height = 195
Index = 4
Left = 2340
TabIndex = 5
Top = 660
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "读取数据"
Height = 195
Index = 3
Left = 2340
TabIndex = 4
Top = 360
Width = 1575
End
Begin VB.CheckBox chkPermission
Caption = "删除数据"
Height = 195
Index = 6
Left = 2340
TabIndex = 3
Top = 1260
Width = 1575
End
End
Begin VB.Label lblUsers
Caption = "用户名称:"
Height = 192
Left = 300
TabIndex = 13
Top = 240
Width = 912
End
Begin VB.Label lblTablesAndQueries
Caption = "表、查询及表间关系:"
Height = 192
Left = 2580
TabIndex = 12
Top = 240
Width = 1692
End
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "退出程序"
Default = -1 'True
Height = 375
Left = 1800
TabIndex = 0
Top = 4320
Width = 1275
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 = "d:\windows\system32\system.mdw"
' 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
Case PER_READ_DATA:
If (.Value = vbChecked) Then
chkPermission(PER_READ_DESIGN).Value = vbChecked
Else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -