?? userform.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form UserForm
BorderStyle = 1 'Fixed Single
Caption = "用戶瀏覽窗口"
ClientHeight = 6060
ClientLeft = 45
ClientTop = 405
ClientWidth = 8490
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6060
ScaleWidth = 8490
Begin VB.Frame Frame1
Caption = "編輯區域"
Height = 5535
Left = 120
TabIndex = 2
Top = 240
Width = 3255
Begin VB.CommandButton delBnt
Caption = "刪除"
Height = 375
Left = 840
TabIndex = 11
Top = 3600
Width = 1215
End
Begin VB.CommandButton editBnt
Caption = "修改"
Height = 375
Left = 840
TabIndex = 10
Top = 3000
Width = 1215
End
Begin VB.CommandButton addBnt
Caption = "添加"
Height = 375
Left = 840
TabIndex = 9
Top = 2400
Width = 1215
End
Begin VB.TextBox txtPwd
Height = 270
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 8
Top = 1440
Width = 1815
End
Begin VB.TextBox txtLoginName
Height = 270
Left = 1320
TabIndex = 7
Top = 960
Width = 1815
End
Begin VB.TextBox txtUserName
Height = 270
Left = 1320
TabIndex = 6
Top = 480
Width = 1815
End
Begin VB.Label Label3
Caption = "登錄密碼:"
Height = 255
Left = 120
TabIndex = 5
Top = 1440
Width = 1095
End
Begin VB.Label Label2
Caption = "登錄名:"
Height = 255
Left = 120
TabIndex = 4
Top = 960
Width = 855
End
Begin VB.Label Label1
Caption = "用戶名:"
Height = 255
Left = 120
TabIndex = 3
Top = 480
Width = 975
End
End
Begin VB.Frame userlist
Caption = "系統用戶列表"
Height = 5535
Left = 3480
TabIndex = 0
Top = 240
Width = 4815
Begin MSFlexGridLib.MSFlexGrid MSF
Height = 5175
Left = 120
TabIndex = 1
Top = 240
Width = 4455
_ExtentX = 7858
_ExtentY = 9128
_Version = 393216
SelectionMode = 1
End
End
End
Attribute VB_Name = "UserForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub classshowtitle()
Dim i As Integer
MSF.Clear
With MSF
.Cols = 4
.TextMatrix(0, 1) = "用戶名"
.TextMatrix(0, 2) = "登錄名"
.TextMatrix(0, 3) = "登錄密碼"
.ColWidth(0) = 100
.ColWidth(1) = 1300
.ColWidth(2) = 1200
.FixedRows = 1
For i = 1 To 3
.ColAlignment(i) = 0
Next i
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Public Sub classshowdata()
Dim j As Integer
Dim i As Integer
Dim mrc1 As ADODB.Recordset
strSql = "select * from user_info"
Set mrc1 = ExecuteSQL(Trim(strSql))
If mrc1.EOF = False Then
mrc1.MoveFirst
With MSF
.Rows = 1
Do While Not mrc1.EOF
.Rows = .Rows + 1
For i = 1 To mrc1.Fields.Count - 1
.TextMatrix(.Rows - 1, i) = mrc1.Fields(i)
Next i
mrc1.MoveNext
Loop
mrc1.Close
End With
End If
End Sub
Private Sub addBnt_Click()
If UserForm.txtUserName = "" Then
MsgBox "用戶名不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
Exit Sub
Else
strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
Set rs = ExecuteSQL(strSql)
If rs.EOF = False Then
MsgBox "用戶名已經存在!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
rs.Close
Exit Sub
End If
End If
If UserForm.txtLoginName = "" Then
MsgBox "登錄名不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtLoginName.SetFocus
Exit Sub
Else
strSql = "select * from user_info where user_info_loginname = '" & Trim(UserForm.txtLoginName) & "'"
Set rs = ExecuteSQL(strSql)
If rs.EOF = False Then
MsgBox "登錄名已經存在!", vbExclamation + vbOKOnly, "警告"
UserForm.txtLoginName.SetFocus
rs.Close
Exit Sub
End If
End If
If UserForm.txtPwd = "" Then
MsgBox "密碼不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtPwd.SetFocus
Exit Sub
End If
strSql = "insert into user_info (user_info_name,user_info_loginname,user_info_pwd) values('" & Trim(UserForm.txtUserName) & "','" & Trim(UserForm.txtLoginName) & "','" & Trim(UserForm.txtPwd) & "')"
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "添加用戶成功!", vbExclamation + vbOKOnly, "警告"
UserForm.classshowdata
Else
MsgBox "添加用戶失敗!", vbExclamation + vbOKOnly, "警告"
End If
End Sub
Private Sub delBnt_Click()
If UserForm.txtUserName = "" Then
MsgBox "用戶名不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
Exit Sub
Else
strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
Set rs = ExecuteSQL(strSql)
If rs.EOF = True Then
MsgBox "用戶名不存在!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
rs.Close
Exit Sub
End If
End If
If MsgBox("確認刪除用戶" & UserForm.txtUserName, vbExclamation + vbOKCancel, "警告") = vbOK Then
strSql = "delete from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "刪除用戶成功!", vbExclamation + vbOKOnly, "警告"
UserForm.classshowdata
Else
MsgBox "刪除用戶失敗!", vbExclamation + vbOKOnly, "警告"
End If
End If
End Sub
Private Sub editBnt_Click()
If UserForm.txtUserName = "" Then
MsgBox "用戶名不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
Exit Sub
Else
strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
Set rs = ExecuteSQL(strSql)
If rs.EOF = True Then
MsgBox "用戶名不存在!", vbExclamation + vbOKOnly, "警告"
UserForm.txtUserName.SetFocus
rs.Close
Exit Sub
End If
End If
If UserForm.txtLoginName = "" Then
MsgBox "登錄名不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtLoginName.SetFocus
Exit Sub
End If
If UserForm.txtPwd = "" Then
MsgBox "密碼不能為空!", vbExclamation + vbOKOnly, "警告"
UserForm.txtPwd.SetFocus
Exit Sub
End If
strSql = "update user_info set user_info_loginname = '" & Trim(UserForm.txtLoginName) & "',user_info_pwd = '" & Trim(UserForm.txtPwd) & "' where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
If ExecuteUpdateSQL(strSql) = True Then
MsgBox "修改用戶信息成功!", vbExclamation + vbOKOnly, "警告"
UserForm.classshowdata
Else
MsgBox "修改用戶信息失敗!", vbExclamation + vbOKOnly, "警告"
End If
End Sub
Private Sub MSF_Click()
UserForm.txtUserName = MSF.TextMatrix(MSF.RowSel, 1)
UserForm.txtLoginName = MSF.TextMatrix(MSF.RowSel, 2)
UserForm.txtPwd = MSF.TextMatrix(MSF.RowSel, 3)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -