📄 operatormanager.frm
字号:
MsgBox "您的权限不够,请于系统管理员联系!", vbInformation
Exit Sub
Else
If Not ListView1.SelectedItem Is Nothing Then
Set MdbR = NdMd.OpenRecordset("SELECT * FROM 口令权限")
If MdbR.RecordCount <> 0 Then
MdbR.MoveLast
MdbR.MoveFirst
End If
If MdbR.RecordCount = 1 Then
MsgBox "无法删除唯一超级管理员!", vbCritical
Exit Sub
End If
If MsgBox("删除" & ListView1.SelectedItem & "用户的档案吗?", vbYesNo + vbQuestion) = vbYes Then
Set MdbR = NdMd.OpenRecordset("SELECT * FROM 口令权限 WHERE 姓名='" & Trim(ListView1.SelectedItem) & "'")
MdbR.Delete
MdbR.Close
ListView1.ListItems.Remove ListView1.SelectedItem.Index
If ListView1.ListItems.Count > 0 Then
Set ListView1.SelectedItem = ListView1.ListItems(1)
End If
ListView1.SetFocus
End If
End If
End If
End Sub
Private Sub cmdExit_Click()
SaveSetting App.EXEName, "SysStart", "Start", "Two"
Unload Me
End Sub
Private Sub comboQx_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command3.SetFocus
End If
End Sub
Private Sub Command1_Click()
Me.Height = 5250
txtName = ""
txtPasswd = ""
Text1 = ""
txtName.SetFocus
SendMess = 1
CmdTF (False)
End Sub
Private Sub Command2_Click()
On Error Resume Next
If pbUserPermission <> "系统管理员" Then
MsgBox "您的权限不够,请于系统管理员联系!", vbInformation
Exit Sub
Else
If ListView1.SelectedItem Is Nothing Then
Exit Sub
Else
Me.Height = 5250
Set MdbR = NdMd.OpenRecordset("SELECT * FROM 口令权限 WHERE 姓名='" & Trim(ListView1.SelectedItem) & "'")
With MdbR
txtName = .Fields!姓名
Text1 = .Fields!代码
txtPasswd = DeCrypt(.Fields!密码, "ND2000MXF")
Select Case .Fields!权限
Case "系统管理员"
comboQx.ListIndex = 0
Case "普通管理员"
comboQx.ListIndex = 1
Case "可查看用户"
comboQx.ListIndex = 2
End Select
End With
MdbR.Close
SendMess = 2
txtName.SetFocus
CmdTF (False)
End If
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
If GetSetting(App.EXEName, "SysStart", "Start", "") = "One" Then
Call AddBo
Else
If pbUserPermission <> "系统管理员" Then
MsgBox "您的权限不够,请于系统管理员联系!", vbInformation
Exit Sub
Else
Call AddBo
End If
End If
End Sub
Private Sub Command4_Click()
Me.Height = 3525
txtName = ""
txtPasswd = ""
Text1 = ""
CmdTF (True)
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 1 - 3500
OpenMdb
On Error Resume Next
If GetSetting(App.EXEName, "SysStart", "Start", "") = "One" Then
Me.Caption = "注意:您必须建立一个超级管理员 , 下次才能有所有权限!"
cmdDelete.Enabled = False
Command2.Enabled = False
cmdExit.Enabled = False
comboQx.AddItem "系统管理员"
comboQx.ListIndex = 0
Else
Dim Li As ListItem
comboQx.AddItem "系统管理员"
comboQx.AddItem "普通管理员"
comboQx.AddItem "可查看用户"
comboQx.ListIndex = 1
Set MdbR = NdMd.OpenRecordset("口令权限")
'Dim Li As ListItem
With MdbR
While Not MdbR.eof
Select Case .Fields!权限
Case "系统管理员"
Set Li = ListView1.ListItems.Add(, , .Fields!姓名, 1)
Case "普通管理员"
Set Li = ListView1.ListItems.Add(, , .Fields!姓名, 2)
Case "可查看用户"
Set Li = ListView1.ListItems.Add(, , .Fields!姓名, 3)
End Select
.MoveNext
Wend
End With
MdbR.Close
End If
Exit Sub
err_read:
MsgBox "不能读取用户资料,原因是:" & Err.Description, , ""
End Sub
Private Sub txtName_GotFocus()
txtName.SelStart = 0
txtName.SelLength = Len(txtName.Text)
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1.SetFocus
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPasswd.SetFocus
End If
End Sub
Private Sub txtPasswd_GotFocus()
txtPasswd.SelStart = 0
txtPasswd.SelLength = Len(txtPasswd.Text)
End Sub
Sub CmdTF(TF As Boolean)
Command1.Enabled = TF
Command2.Enabled = TF
cmdDelete.Enabled = TF
End Sub
Sub AddBo()
On Error GoTo OperErr
If SendMess = 1 Then
Dim Li As ListItem
If Len(txtName.Text) = 0 Then
MsgBox "要增加用户的用户名一定要有!", , "提示"
txtName.SetFocus
Exit Sub
End If
If Len(txtPasswd) = 0 Then
MsgBox "要增加用户的密码一定要有!", , "提示"
txtPasswd.SetFocus
Exit Sub
End If
If Len(Text1) = 0 Then
MsgBox "要增加用户的代码一定要有!", , "提示"
Text1.SetFocus
Exit Sub
End If
Set MdbR = NdMd.OpenRecordset("口令权限")
With MdbR
.AddNew
.Fields!姓名 = txtName
.Fields!代码 = Mid(Text1, 1, 3)
.Fields!密码 = Crypt(Mid(txtPasswd.Text, 1, 6), "ND2000MXF")
.Fields!权限 = comboQx.Text
.Fields!建立日期 = Format(Date, "yyyy年mm月dd日")
.Update
End With
MdbR.Close
Select Case comboQx.Text
Case "系统管理员"
Set Li = ListView1.ListItems.Add(, , txtName, 1)
Case "普通管理员"
Set Li = ListView1.ListItems.Add(, , txtName, 2)
Case "可查看用户"
Set Li = ListView1.ListItems.Add(, , txtName, 3)
End Select
Set ListView1.SelectedItem = Li
cmdExit.Enabled = True
If GetSetting(App.EXEName, "SysStart", "Start", "") = "One" Then
SaveSetting App.EXEName, "SysStart", "Start", "Two"
End If
End If
If SendMess = 2 Then
If ListView1.SelectedItem Is Nothing Then
Exit Sub
End If
Set MdbR = NdMd.OpenRecordset("SELECT * FROM 口令权限 WHERE 姓名='" & Trim(ListView1.SelectedItem) & "'")
With MdbR
.Edit
.Fields!姓名 = txtName
.Fields!代码 = Mid(Text1, 1, 3)
.Fields!密码 = Crypt(Mid(txtPasswd.Text, 1, 6), "ND2000MXF")
.Fields!权限 = comboQx.Text
.Fields!建立日期 = Format(Date, "yyyy年mm月dd日")
.Update
End With
MdbR.Close
ListView1.ListItems.Remove ListView1.SelectedItem.Index
Select Case comboQx.Text
Case "系统管理员"
Set Li = ListView1.ListItems.Add(, , txtName, 1)
Case "普通管理员"
Set Li = ListView1.ListItems.Add(, , txtName, 2)
Case "可查看用户"
Set Li = ListView1.ListItems.Add(, , txtName, 3)
End Select
End If
SendMess = 0
Me.Height = 3540
CmdTF (True)
frmMain.MenuTrueFlase (True)
' frmMain.PopDataTree
Exit Sub
OperErr:
MsgBox "请检查数据是否有误!", vbCritical
Exit Sub
End Sub
Private Sub txtPasswd_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
comboQx.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -