📄 frmpersonnelmanager.frm
字号:
VERSION 5.00
Object = "{FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0"; "DBLIST32.OCX"
Begin VB.Form frmPersonnelManager
Caption = "人员管理"
ClientHeight = 3000
ClientLeft = 60
ClientTop = 450
ClientWidth = 7575
Icon = "frmPersonnelManager.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3000
ScaleWidth = 7575
StartUpPosition = 2 '屏幕中心
Begin VB.Data Data
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Index = 1
Left = 3480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 1920
Visible = 0 'False
Width = 2415
End
Begin VB.Data Data
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Index = 0
Left = 240
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 2400
Width = 5775
End
Begin VB.CommandButton cmdReturn
Cancel = -1 'True
Caption = "返回(&R)"
Height = 375
Left = 6240
TabIndex = 13
Top = 2280
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "删除(&D)"
Height = 375
Left = 6240
TabIndex = 12
Top = 1600
Width = 1095
End
Begin VB.CommandButton cmdEdit
Caption = "修改(&E)"
Height = 375
Left = 6240
TabIndex = 11
Top = 920
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "新增(&A)"
Height = 375
Left = 6240
TabIndex = 10
Top = 240
Width = 1095
End
Begin VB.Frame Frame1
Caption = "管理员设置"
Height = 1935
Left = 240
TabIndex = 0
Top = 240
Width = 5775
Begin VB.TextBox txtName
DataSource = "Data(0)"
Height = 270
Left = 3720
TabIndex = 4
Top = 360
Width = 1455
End
Begin MSDBCtls.DBCombo DBcomClass
Bindings = "frmPersonnelManager.frx":0442
DataSource = "Data(0)"
Height = 330
Left = 960
TabIndex = 6
Top = 1200
Width = 1455
_ExtentX = 2566
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin VB.TextBox txtPassword
DataSource = "Data(0)"
Height = 270
IMEMode = 3 'DISABLE
Left = 3720
PasswordChar = "*"
TabIndex = 9
Top = 1230
Width = 1455
End
Begin VB.TextBox txtNo
DataSource = "Data(0)"
Enabled = 0 'False
Height = 270
Left = 960
TabIndex = 2
Top = 360
Width = 1455
End
Begin VB.CommandButton cmdAdditional
Caption = ".."
Height = 375
Left = 2400
TabIndex = 7
Top = 1155
Width = 375
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "类别:"
Height = 180
Left = 360
TabIndex = 5
Top = 1275
Width = 450
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "密码:"
Height = 180
Left = 3120
TabIndex = 8
Top = 1275
Width = 450
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓名:"
Height = 180
Left = 3120
TabIndex = 3
Top = 405
Width = 450
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "编号:"
Height = 180
Left = 360
TabIndex = 1
Top = 405
Width = 450
End
End
End
Attribute VB_Name = "frmPersonnelManager"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdAdd_Click()
On Error GoTo AddErr
cmdEdit.Enabled = Not cmdEdit.Enabled
cmdDelete.Enabled = Not cmdDelete.Enabled
If Left(cmdAdd.Caption, 2) = "新增" Then
cmdAdd.Caption = "确认(&O)"
cmdReturn.Caption = "放弃(&C)"
'Data(0).Recordset.MoveLast
Data(0).Recordset.AddNew
txtName.SetFocus
Else
cmdAdd.Caption = "新增(&A)"
cmdReturn.Caption = "返回(&R)"
Data(0).Recordset.Update
Data(0).Recordset.MoveLast
End If
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdAdditional_Click()
frmAdditional.Show vbModal '用户类别设置
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
With Data(0).Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub
Private Sub cmdEdit_Click()
On Error GoTo EditErr
cmdAdd.Enabled = Not cmdAdd.Enabled
cmdDelete.Enabled = Not cmdDelete.Enabled
If Left(cmdEdit.Caption, 2) = "修改" Then
cmdEdit.Caption = "确认(&O)"
cmdReturn.Caption = "放弃(&C)"
Data(0).Recordset.Edit
txtName.SetFocus
Else
cmdEdit.Caption = "修改(&E)"
cmdReturn.Caption = "返回(&R)"
Data(0).Recordset.Update
End If
Exit Sub
EditErr:
MsgBox Err.Description
End Sub
Private Sub cmdReturn_Click()
If Left(cmdReturn.Caption, 2) = "放弃" Then
cmdReturn.Caption = "返回(&R)"
cmdAdd.Caption = "新增(&A)"
cmdEdit.Caption = "修改(&E)"
cmdAdd.Enabled = True
cmdEdit.Enabled = True
cmdDelete.Enabled = True
Data(0).UpdateControls
'如果记录不为空,则移到最后
If Not (Data(0).Recordset.BOF And Data(0).Recordset.EOF) Then Data(0).Recordset.MoveLast
Else
Unload Me
End If
End Sub
Private Sub Data_Reposition(Index As Integer)
Select Case Index
Case 0
Data(Index).Caption = "记录:人员" & Data(0).Recordset.AbsolutePosition + 1
End Select
End Sub
Private Sub Form_Load()
'打开人员库
Dim strAppName As String, strSQL As String
strAppName = App.Path & "\人员库.mdb"
strSQL = "select * from 人员表"
Data(0).DatabaseName = strAppName
Data(0).RecordSource = strSQL
strSQL = "select * from 权限表"
Data(1).DatabaseName = strAppName
Data(1).RecordSource = strSQL
'数据绑定控件初始化
txtNo.DataField = "编号"
txtName.DataField = "姓名"
txtPassword.DataField = "密码"
DBcomClass.DataField = "人员代号"
DBcomClass.ListField = "人员名"
DBcomClass.BoundColumn = "人员代号"
Data(0).Refresh
Data(1).Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -