📄 frm_systemer.frm
字号:
Height = 375
Left = 3630
Top = 5550
Width = 2415
_ExtentX = 4260
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Cmd_Cancel
Caption = "取消"
Height = 350
Left = 4965
TabIndex = 6
Top = 3855
Width = 975
End
Begin VB.CommandButton Cmd_Add
Caption = "注册"
Height = 350
Left = 1065
TabIndex = 4
Top = 3855
Width = 975
End
Begin VB.CommandButton Cmd_Del
Caption = "删除"
Height = 350
Left = 2040
TabIndex = 5
Top = 3855
Width = 975
End
Begin VB.Frame Frame2
Caption = "用户信息"
Height = 1890
Left = 75
TabIndex = 0
Top = 45
Width = 2385
Begin VB.TextBox Text4
Height = 300
IMEMode = 3 'DISABLE
Left = 945
PasswordChar = "*"
TabIndex = 11
Top = 1440
Width = 1305
End
Begin VB.TextBox Text3
Height = 300
IMEMode = 3 'DISABLE
Left = 945
PasswordChar = "*"
TabIndex = 10
Top = 1040
Width = 1305
End
Begin VB.TextBox Text2
Height = 300
Left = 945
TabIndex = 9
Top = 640
Width = 1305
End
Begin VB.TextBox Text1
Height = 300
Left = 945
TabIndex = 8
Top = 240
Width = 1305
End
Begin VB.Label Label5
Caption = "职务"
Height = 255
Left = 90
TabIndex = 7
Top = 705
Width = 615
End
Begin VB.Label Label3
Caption = "确认密码"
Height = 225
Left = 90
TabIndex = 3
Top = 1500
Width = 855
End
Begin VB.Label Label2
Caption = "用户密码"
Height = 195
Left = 90
TabIndex = 2
Top = 1095
Width = 855
End
Begin VB.Label Label1
Caption = "用户名称"
Height = 255
Left = 90
TabIndex = 1
Top = 320
Width = 855
End
End
End
Attribute VB_Name = "frm_systemer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a
'用户注册信息的事件代码
Private Sub Cmd_Add_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "输入的用户注册信息不完全!!", , "提示信息"
Else
On Error Resume Next
Adodc1.RecordSource = "select * from tb_user where user_name='" + Text1 + "'" '判断注册的用户名是否存在
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "该用户名已经存在,请您更换其他用户名!", 48, "提示信息"
Text1.Text = "" '如果该用户名存在则重新输入
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
Else
If Text3.Text = Text4.Text Then '判断两次输入的密码是否一致
AdoRs.Open "select * from tb_user where user_name='" + Text1.Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
AdoRs.MoveLast
Dim StrId
StrId = Val(AdoRs.Fields("user_id")) + 1
Else
StrId = 1
End If
'保存注册信息
Set AdoRs = Cnn.Execute("insert into tb_user values(" & StrId & ",'" & Text1 & "','" & Text3 & "','" & Text2 & "','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0')")
MsgBox "注册成功!!", 48, "用户注册信息提示"
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from tb_user"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False '将操作员信息添加到ListView控件当中
key = Adodc1.Recordset.Fields("user_name")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
AdoRs.Close
Else
MsgBox "两次输入的密码不一致,请您确认后重新输入", 48, "用户注册信息提示"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
End If
End If
End If
End Sub
Private Sub Cmd_del_Click()
If Text1.Text = "Admin" Then
MsgBox "超级用户不能够被删除", 48, "提示信息"
Else
If Text1.Text = Name1 Then '如果是当前登录的用户名,则不允许删除
MsgBox "不能删除当前用户名!!", 48, "提示信息"
Else
a = MsgBox("您确认要删除该用户吗?", 17, "删除用户信息提示")
If a = vbOK Then
Adodc1.RecordSource = "select * from tb_user where user_name='" + Text1.Text + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.Delete '如果数据库中存在该用户信息,则将其删除
MsgBox "用户信息删除成功", 64, "删除用户信息提示"
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from tb_user"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False '将操作员信息添加到ListView控件当中
key = Adodc1.Recordset.Fields("user_name")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
Else
MsgBox "当前数据库中没有可删除的用户信息", , "信息提示"
End If
End If
End If
End If
End Sub
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_qxgl_Click()
On Error Resume Next
AdoRs.Open "select * from tb_user where user_name='" + ListView1.SelectedItem + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
c = MsgBox("确认要将所选权限的信息赋给该操作员吗?", 33, "提示信息")
If c = vbOK Then
'给操作员分配权限
Set AdoRs = Cnn.Execute("UPDATE tb_user SET [1]= '" + Str(Check1(0).Value) + "',[2]= '" + Str(Check1(1).Value) + "',[3]= '" + Str(Check1(2).Value) + "',[4]= '" + Str(Check1(3).Value) + "',[5]= '" & _
Str(Check1(4).Value) + "',[6]= '" + Str(Check1(5).Value) + "',[7]= '" + Str(Check1(6).Value) + "',[8]= '" + Str(Check1(7).Value) + "',[9]= '" + Str(Check1(8).Value) + "',[10]= '" + Str(Check1(9).Value) + "',[11]= '" & _
Str(Check1(10).Value) + "',[12]= '" + Str(Check1(11).Value) + "',[13]= '" + Str(Check1(12).Value) + "',[14]= '" + Str(Check1(13).Value) + "',[15]= '" + Str(Check1(14).Value) + "',[16]= '" + Str(Check1(15).Value) + "',[17]= '" & _
Str(Check1(16).Value) + "',[18]= '" + Str(Check1(17).Value) + "',[19]= '" + Str(Check1(18).Value) + "',[20]= '" + Str(Check1(19).Value) + "',[21]= '" + Str(Check1(20).Value) + "',[22]= '" + Str(Check1(21).Value) + "',[23]= '" _
+ Str(Check1(22).Value) + "',[24]= '" + Str(Check1(23).Value) + "',[25]= '" + Str(Check1(24).Value) + "' where user_name='" + Text1.Text + "'")
MsgBox "成功授权!!", 48, "信息提示"
Cmd_qxgl.Enabled = False
End If
End If
AdoRs.Close
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
frm_editpas.Show 1
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from tb_user"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False '将操作员信息添加到ListView控件当中
key = Adodc1.Recordset.Fields("user_name")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
Else
ListView1.Enabled = False
End If
End Sub
Private Sub ListView1_Click()
Cmd_qxgl.Enabled = True
Adodc1.RecordSource = "select * from tb_user where user_name='" + ListView1.SelectedItem + "'"
Adodc1.Refresh
On Error Resume Next
If Adodc1.Recordset.RecordCount > 0 Then
Text1.Text = Adodc1.Recordset.Fields("user_name")
Text2.Text = Adodc1.Recordset.Fields(3)
Check1(0).Value = Adodc1.Recordset.Fields("1")
Check1(1).Value = Adodc1.Recordset.Fields("2")
Check1(2).Value = Adodc1.Recordset.Fields("3")
Check1(3).Value = Adodc1.Recordset.Fields("4")
Check1(4).Value = Adodc1.Recordset.Fields("5")
Check1(5).Value = Adodc1.Recordset.Fields("6")
Check1(6).Value = Adodc1.Recordset.Fields("7")
Check1(7).Value = Adodc1.Recordset.Fields("8")
Check1(8).Value = Adodc1.Recordset.Fields("9")
Check1(9).Value = Adodc1.Recordset.Fields("10")
Check1(10).Value = Adodc1.Recordset.Fields("11")
Check1(11).Value = Adodc1.Recordset.Fields("12")
Check1(12).Value = Adodc1.Recordset.Fields("13")
Check1(13).Value = Adodc1.Recordset.Fields("14")
Check1(14).Value = Adodc1.Recordset.Fields("15")
Check1(15).Value = Adodc1.Recordset.Fields("16")
Check1(16).Value = Adodc1.Recordset.Fields("17")
Check1(17).Value = Adodc1.Recordset.Fields("18")
Check1(18).Value = Adodc1.Recordset.Fields("19")
Check1(19).Value = Adodc1.Recordset.Fields("20")
Check1(20).Value = Adodc1.Recordset.Fields("21")
Check1(21).Value = Adodc1.Recordset.Fields("22")
Check1(22).Value = Adodc1.Recordset.Fields("23")
Check1(23).Value = Adodc1.Recordset.Fields("24")
Check1(24).Value = Adodc1.Recordset.Fields("25")
Else
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text2.SetFocus
Else
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回车键,则光标落到文本框当中
Text3.SetFocus
Else
End If
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回车键,则光标落到文本框当中
Text4.SetFocus
Else
End If
End Sub
Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call Cmd_Add_Click
Else
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -