📄 frmadmin.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmAdmin
Caption = "管理员设置"
ClientHeight = 4395
ClientLeft = 60
ClientTop = 345
ClientWidth = 6900
Icon = "frmAdmin.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4395
ScaleWidth = 6900
StartUpPosition = 1 '所有者中心
Begin MSComctlLib.ListView ListView1
Height = 1215
Left = 4440
TabIndex = 0
Top = 1560
Width = 2055
_ExtentX = 3625
_ExtentY = 2143
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 3
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "用户名"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "密码"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "权限"
Object.Width = 2540
EndProperty
End
Begin VB.Frame Frame1
Caption = "用户设置:"
Height = 3375
Left = 120
TabIndex = 6
Top = 120
Visible = 0 'False
Width = 6135
Begin VB.TextBox Text4
Height = 375
IMEMode = 3 'DISABLE
Left = 1920
MaxLength = 14
PasswordChar = "*"
TabIndex = 16
Top = 2640
Width = 2175
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 1920
MaxLength = 14
PasswordChar = "*"
TabIndex = 15
Top = 2040
Width = 2175
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "frmAdmin.frx":0442
Left = 1920
List = "frmAdmin.frx":0452
Style = 2 'Dropdown List
TabIndex = 14
Top = 960
Width = 2175
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1920
MaxLength = 14
PasswordChar = "*"
TabIndex = 13
Top = 1560
Width = 2175
End
Begin VB.TextBox Text1
Height = 375
Left = 1920
TabIndex = 12
Top = 360
Width = 2175
End
Begin VB.Label Label5
Caption = "确认密码:"
Height = 375
Left = 600
TabIndex = 11
Top = 2760
Width = 2175
End
Begin VB.Label Label4
Caption = "新密码:"
Height = 375
Left = 600
TabIndex = 10
Top = 2160
Width = 1815
End
Begin VB.Label Label3
Caption = "原密码:"
Height = 375
Left = 600
TabIndex = 9
Top = 1680
Width = 1335
End
Begin VB.Label Label2
Caption = "权限:"
Height = 375
Left = 600
TabIndex = 8
Top = 1080
Width = 1095
End
Begin VB.Label Label1
Caption = "用户名:"
Height = 255
Left = 600
TabIndex = 7
Top = 480
Width = 1455
End
End
Begin VB.PictureBox Picture1
BorderStyle = 0 'None
Height = 615
Left = 120
ScaleHeight = 615
ScaleWidth = 6615
TabIndex = 1
Top = 3600
Width = 6615
Begin VB.CommandButton Command5
Caption = "关闭窗口"
Height = 375
Left = 5400
TabIndex = 17
Top = 120
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "保存设置"
Enabled = 0 'False
Height = 375
Left = 4080
TabIndex = 5
Top = 120
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "删除用户"
Height = 375
Left = 2760
TabIndex = 4
Top = 120
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "修改用户"
Height = 375
Left = 1440
TabIndex = 3
Top = 120
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "添加用户"
Height = 375
Left = 120
TabIndex = 2
Top = 120
Width = 1095
End
End
End
Attribute VB_Name = "frmAdmin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim aa As Long
Private Sub Combo1_Click()
Command4.Enabled = True
End Sub
Private Sub Command1_Click()
'添加用户
On Error Resume Next
If Command1.Caption = "添加用户" Then
ListView1.Visible = False
Frame1.Visible = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = Combo1.List(0)
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
Command1.Caption = "放弃添加"
Else
ListView1.Visible = True
Frame1.Visible = False
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command1.Caption = "添加用户"
End If
End Sub
Private Sub Command2_Click()
'编辑用户
On Error Resume Next
With frmMain.Data8.Recordset
Text1.Text = .Fields("用户名称")
Select Case .Fields("权限")
Case "A"
Combo1.Text = Combo1.List(0)
Text2.PasswordChar = ""
Text3.PasswordChar = ""
Text4.PasswordChar = ""
Text2.Text = .Fields("用户密码")
Text3.Text = .Fields("用户密码")
Text4.Text = .Fields("用户密码")
Case "B"
Combo1.Text = Combo1.List(1)
Text2.PasswordChar = ""
Text3.PasswordChar = ""
Text4.PasswordChar = ""
Text2.Text = .Fields("用户密码")
Text3.Text = .Fields("用户密码")
Text4.Text = .Fields("用户密码")
Case "C"
Combo1.Text = Combo1.List(2)
Text2.PasswordChar = ""
Text3.PasswordChar = ""
Text4.PasswordChar = ""
Text2.Text = .Fields("用户密码")
Text3.Text = .Fields("用户密码")
Text4.Text = .Fields("用户密码")
Case "D"
Text2.PasswordChar = "*"
Text3.PasswordChar = "*"
Text4.PasswordChar = "*"
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = Combo1.List(3)
End Select
End With
If Command2.Caption = "修改用户" Then
ListView1.Visible = False
Frame1.Visible = True
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command2.Caption = "放弃修改"
Else
ListView1.Visible = True
Frame1.Visible = False
Command1.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command2.Caption = "修改用户"
End If
End Sub
Private Sub Command3_Click()
'删除用户
On Error Resume Next
With frmMain.Data8.Recordset
If MsgBox("确实要删除用户:" & .Fields("用户名称") & " 吗?", vbYesNo + vbQuestion) = vbYes Then
If Err <> 0 Then Exit Sub
If .Fields("权限") = "D" Then
mm = InputBox("请输入密码:")
If mm = .Fields("用户密码") And .Fields("用户名称") <> UserName Then
.Delete
ListView1.ListItems.Clear
Form_Load
Else
MsgBox "不能删除用户!", vbCritical
End If
Else
.Delete
ListView1.ListItems.Clear
Form_Load
End If
End If
End With
End Sub
Private Sub Command4_Click()
'保存设置
On Error Resume Next
If Trim(Text1.Text) = "" Then
MsgBox "用户名错误!", vbCritical
Text1.SetFocus
Exit Sub
End If
With frmMain.Data8.Recordset
If Text3.Text <> Text4.Text Then
MsgBox "前后密码设置不一至,请重新输入!", vbCritical
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Exit Sub
End If
aa = .AbsolutePosition
.MoveFirst
For i = 1 To .RecordCount
If .Fields("用户名称") = Text1.Text Then
If .AbsolutePosition <> aa Then
MsgBox "用户名已经存在了,请你再换一个!", vbExclamation
.MoveFirst
.Move aa
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
End If
End If
.MoveNext
Next i
.MoveFirst
.Move aa
If Command1.Caption = "放弃添加" Then
.AddNew
Else
If Text2.Text <> .Fields("用户密码") Then
MsgBox "密码错误,请重新输入!", vbCritical
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text2.SetFocus
Exit Sub
End If
.Edit
End If
.Fields("用户名称") = Text1.Text
.Fields("用户密码") = Text3.Text
.Fields("权限") = Left(Combo1.Text, 1)
.Update
End With
If Err <> 0 Then MsgBox Error: Exit Sub
ListView1.Visible = True
Frame1.Visible = False
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command1.Caption = "添加用户"
Command2.Caption = "修改用户"
ListView1.ListItems.Clear
Form_Load
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error Resume Next
With frmMain.Data8.Recordset
aa = .AbsolutePosition
.MoveFirst
For i = 1 To .RecordCount
ListView1.ListItems.Add i, , .Fields("用户名称")
' ListView1.ListItems(i).SubItems(1) = .Fields("用户密码")
ListView1.ListItems(i).SubItems(1) = "********"
Select Case .Fields("权限")
Case "A"
ListView1.ListItems(i).SubItems(2) = "A—记费员"
Case "B"
ListView1.ListItems(i).SubItems(2) = "B—操作员"
Case "C"
ListView1.ListItems(i).SubItems(2) = "C—管理员"
Case "D"
ListView1.ListItems(i).SubItems(2) = "D—超级管理员"
End Select
.MoveNext
Next i
.MoveFirst
.Move aa
End With
End Sub
Private Sub Form_Resize()
On Error Resume Next
ListView1.Move 30, 10, Me.Width - 150, Me.Height - 1200
Picture1.Top = ListView1.Top + ListView1.Height + 100
Picture1.Left = (Me.Width - Picture1.Width) / 2
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
'
On Error Resume Next
With frmMain.Data8.Recordset
.MoveFirst
.Move Item.Index - 1
End With
End Sub
Private Sub Text1_Change()
Command4.Enabled = True
End Sub
Private Sub Text2_Change()
Command4.Enabled = True
End Sub
Private Sub Text3_Change()
Command4.Enabled = True
End Sub
Private Sub Text4_Change()
Command4.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -