📄 sysuser.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form SysUser
Caption = "用户管理"
ClientHeight = 2640
ClientLeft = 420
ClientTop = 420
ClientWidth = 5280
LinkTopic = "Form1"
ScaleHeight = 2640
ScaleWidth = 5280
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cmbStatus
DataField = "身份"
DataSource = "Adodc1"
Height = 315
ItemData = "SysUser.frx":0000
Left = 1200
List = "SysUser.frx":000A
TabIndex = 10
Text = "cmbStatus"
Top = 1440
Width = 2415
End
Begin VB.CommandButton cmdClose
Caption = "关闭"
Height = 255
Left = 3960
TabIndex = 9
Top = 1680
Width = 975
End
Begin VB.CommandButton cmdRefresh
Caption = "刷新"
Height = 255
Left = 3960
TabIndex = 8
Top = 1320
Width = 975
End
Begin VB.CommandButton cmdSave
Caption = "保存"
Height = 255
Left = 3960
TabIndex = 7
Top = 960
Width = 975
End
Begin VB.CommandButton cmdDelete
Caption = "删除"
Height = 255
Left = 3960
TabIndex = 6
Top = 600
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 255
Left = 3960
TabIndex = 5
Top = 240
Width = 975
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 360
Top = 2040
Width = 4575
_ExtentX = 8070
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\学生信息管理系统\数据库\网络0431班学生名单.MDB;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\学生信息管理系统\数据库\网络0431班学生名单.MDB;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 系统用户"
Caption = " 用户管理"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox txtPWD
DataField = "口令"
DataSource = "Adodc1"
Height = 285
IMEMode = 3 'DISABLE
Left = 1200
TabIndex = 3
Top = 840
Width = 2415
End
Begin VB.TextBox txtUser
DataField = "用户名"
DataSource = "Adodc1"
Height = 285
Left = 1200
TabIndex = 1
Top = 240
Width = 2415
End
Begin VB.Label Label3
Caption = "身 份:"
Height = 255
Left = 360
TabIndex = 4
Top = 1440
Width = 735
End
Begin VB.Label Label2
Caption = "口 令:"
Height = 255
Left = 360
TabIndex = 2
Top = 840
Width = 615
End
Begin VB.Label Label1
Caption = "用户名:"
Height = 255
Left = 360
TabIndex = 0
Top = 240
Width = 615
End
End
Attribute VB_Name = "SysUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objCopy As New Recordset, isAdding As Boolean
Private Sub Form_Load()
Set objCopy = Adodc1.Recordset.Clone '创建Adodc1记录集副本
cmdRefresh.Value = True '执行刷新操作
End Sub
'验证用户名输入
Private Sub txtUserName_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("a") And KeyAscii <= Asc("z") _
Or KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") _
Or KeyAscii = vbKeyBack) Then
'如果输入不是英文字母或退格键,则取消输入
KeyAscii = 0
End If
End Sub
Private Sub cmdAdd_Click()
Adodc1.Recordset.AddNew '添加新记录
cmdAdd.Enabled = False '在保存新记录之前禁用
cmbStatus.ListIndex = 1
cmdDelete.Enabled = False: Adodc1.Enabled = False
txtUser.Locked = False: isAdding = True
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdDelete_Click()
With Adodc1.Recordset
If Not .EOF Then
If MsgBox("将删除" & Trim(txtUser) & ",是否继续?", _
vbCritical + vbYesNo, "系统用户管理") = vbYes Then
.Delete
.MoveNext
If .EOF And .RecordCount > 0 Then .MoveLast
End If
End If
End With
End Sub
Private Sub cmdRefresh_Click()
Adodc1.Refresh '刷新记录集
cmdAdd.Enabled = True '启用控件
cmdDelete.Enabled = True: Adodc1.Enabled = True
txtUser.Locked = True: isAdding = False
Set objCopy = Adodc1.Recordset.Clone
End Sub
Private Sub cmdSave_Click()
If Trim(txtUser) = "" Then
MsgBox "用户名不能为空!", vbCritical, "系统用户管理"
txtUser = "": txtUser.SetFocus
ElseIf Trim(txtPWD) = "" Then
MsgBox "口令为空!", vbCritical, "系统用户管理"
txtPWD = "": txtPWD.SetFocus
ElseIf Trim(cmbStatus) = "" Then
MsgBox "用户身份不能为空!", vbCritical, "系统用户管理"
cmbStatus = "": cmbStatus.SetFocus
Else
With objCopy
If .RecordCount > 0 Then
.MoveFirst
.Find "用户名='" & Trim(txtUser) & "'"
If Not .EOF And .AbsolutePosition <> Adodc1.Recordset.AbsolutePosition Then
MsgBox "用户名:" & Trim(txtUser) & "已被使用,请使用其他用户名!", _
vbCritical, "系统用户管理"
txtUser.SetFocus
txtUser.SelStart = 0: txtUser.SelLength = Len(txtUser)
Exit Sub
End If
End If
End With
Adodc1.Recordset.Update
MsgBox "数据保存成功!", vbInformation, "系统用户管理"
cmdAdd.Enabled = True
cmdDelete.Enabled = True: Adodc1.Enabled = True
txtUser.Locked = True: isAdding = False
Set objCopy = Adodc1.Recordset.Clone
End If
End Sub
Private Sub txtUser_Change()
If Trim(txtUser) = "" Or isAdding Then cmdAdd.Enabled = False _
Else cmdAdd.Enabled = True
End Sub
Private Sub txtPWD_Change()
If Trim(txtPWD) = "" Or isAdding Then cmdAdd.Enabled = False _
Else: cmdAdd.Enabled = True
End Sub
Private Sub cmbStatus_Change()
If Trim(cmbStatus) = "" Or isAdding Then cmdAdd.Enabled = False _
Else cmdAdd.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -