📄 form5.frm
字号:
Width = 1935
End
Begin VB.Label Label3
Caption = "角 色"
BeginProperty Font
Name = "华文细黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 8
Top = 2280
Width = 1215
End
Begin VB.Label Label2
Caption = "口 令"
BeginProperty Font
Name = "华文细黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 7
Top = 1560
Width = 1095
End
Begin VB.Label Label1
Caption = "用户名"
BeginProperty Font
Name = "华文细黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 6
Top = 720
Width = 1095
End
End
Begin VB.CommandButton Command4
Caption = "删 除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 4
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "修 改"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 3
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "添 加"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 2
Top = 4440
Width = 1215
End
Begin VB.Frame Frame1
Caption = "用户信息"
BeginProperty Font
Name = "华文细黑"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3735
Left = 240
TabIndex = 1
Top = 480
Width = 5415
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 3135
Left = 240
TabIndex = 23
Top = 360
Width = 4935
_ExtentX = 8705
_ExtentY = 5530
_Version = 393216
End
End
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim iWidth(3) As Integer
Dim Heads(3) As String, uid As String
Dim index1() As Integer, index2() As Integer, power As Integer
Private Sub Command2_Click()
SSTab1.Tab = 1
End Sub
Private Sub Command3_Click()
MSFlexGrid1.Col = 0
Text3 = MSFlexGrid1.Text
uid = MSFlexGrid1.Text
MSFlexGrid1.Col = 1
Text4 = MSFlexGrid1.Text
MSFlexGrid1.Col = 2
Combo2.Text = MSFlexGrid1.Text
MSFlexGrid1.Col = 3
power = MSFlexGrid1.Text
SSTab1.Tab = 2
End Sub
Private Sub Command4_Click()
On Error GoTo a:
MSFlexGrid1.Col = 0
cmd.CommandText = "delete from user where UID='" & _
MSFlexGrid1.Text & "'"
cmd.Execute
Set rs = New ADODB.Recordset
rs.Open "select * from user", cn, adOpenKeyset, adLockReadOnly
If rs.EOF = False Then
Call DisplayKeysetGrid(MSFlexGrid1, Heads(), iWidth())
End If
rs.Close
Set rs = Nothing
Exit Sub
a:
tishi = "请与管理员联系!"
DisplayError (tishi)
End Sub
Private Sub Command5_Click()
On Error GoTo a
cmd.CommandText = "insert into user values('" & Text1 & _
"','" & Text2 & "','" & Combo1.Text & "','" & _
index1(Combo1.ListIndex) & "')"
cmd.Execute
MsgBox "您已添加新用户成功!", vbInformation, "添加用户"
Set rs = New ADODB.Recordset
rs.Open "select * from user", cn, adOpenKeyset, adLockReadOnly
If rs.EOF = False Then
Call DisplayKeysetGrid(MSFlexGrid1, Heads(), iWidth())
End If
rs.Close
Set rs = Nothing
Exit Sub
a:
tishi = "请检查输入值是否正确!"
DisplayError (tishi)
End Sub
Private Sub Command6_Click()
Text1 = ""
Text2 = ""
End Sub
Private Sub Command8_Click()
Text3 = ""
Text4 = ""
End Sub
Private Sub Command7_Click()
On Error GoTo a:
If Combo2.ListIndex > -1 Then power = index2(Combo2.ListIndex)
cmd.CommandText = "update user set UID='" & Text3 & _
"',PWD='" & Text4 & "',role='" & Combo2.Text & _
"',power=" & power & " where UID='" & uid & "'"
cmd.Execute
MsgBox "您已修改成功!", vbInformation, "用户修改"
Set rs = New ADODB.Recordset
rs.Open "select * from user", cn, adOpenKeyset, adLockReadOnly
If rs.EOF = False Then
Call DisplayKeysetGrid(MSFlexGrid1, Heads(), iWidth())
End If
rs.Close
Set rs = Nothing
Exit Sub
a:
tishi = "请检查输入值是否正确!"
DisplayError (tishi)
End Sub
Private Sub Command9_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
rs.Open "select distinct power,role from user", , adOpenStatic, adLockReadOnly
rs.MoveLast
ReDim index1(rs.RecordCount - 1)
ReDim index2(rs.RecordCount - 1)
i = 0
rs.MoveFirst
While Not rs.EOF
Combo1.AddItem rs.Fields(1)
Combo2.AddItem rs.Fields(1)
index1(i) = rs.Fields(0)
index2(i) = rs.Fields(0)
i = i + 1
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
Heads(0) = "用户名"
Heads(1) = "口令"
Heads(2) = "角色"
Heads(3) = "权限"
iWidth(0) = 1500
iWidth(1) = 1000
iWidth(2) = 1000
iWidth(3) = 1000
Set rs = New ADODB.Recordset
rs.Open "select * from user", cn, adOpenKeyset, adLockReadOnly
If rs.EOF = False Then
Call DisplayKeysetGrid(MSFlexGrid1, Heads(), iWidth())
End If
rs.Close
Set rs = Nothing
SSTab1.Tab = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -