📄 person.frm
字号:
Top = 240
Width = 1215
End
Begin VB.CommandButton Search
Caption = "搜索"
Height = 255
Left = 720
TabIndex = 10
Top = 240
Width = 615
End
Begin VB.TextBox Text1
Height = 270
Left = 2640
TabIndex = 7
Top = 240
Width = 1215
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "员工号"
Height = 180
Left = 1800
TabIndex = 12
Top = 270
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓名"
Height = 180
Left = 4200
TabIndex = 11
Top = 270
Width = 360
End
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 615
Left = 0
TabIndex = 0
Top = 0
Width = 9120
_ExtentX = 16087
_ExtentY = 1085
ButtonWidth = 1138
ButtonHeight = 926
Appearance = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 10
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "首记录"
Key = "first"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "上记录"
Key = "before"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "下记录"
Key = "next"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "尾记录"
Key = "last"
ImageIndex = 4
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "新增"
Key = "new"
ImageIndex = 5
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修改"
Key = "modify"
ImageIndex = 6
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删除"
Key = "delete"
ImageIndex = 7
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Caption = "保存"
Key = "save"
ImageIndex = 8
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Caption = "取消"
Key = "cancel"
ImageIndex = 9
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "退出"
Key = "exit"
ImageIndex = 10
EndProperty
EndProperty
Begin MSComctlLib.ImageList ImageList1
Left = 7440
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 10
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":0015
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":0127
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":0239
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":034B
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":045D
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":056F
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":0681
Key = ""
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":0793
Key = ""
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":08A5
Key = ""
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Person.frx":09B7
Key = ""
EndProperty
EndProperty
End
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "职务"
Height = 180
Left = 7920
TabIndex = 19
Top = 4680
Width = 360
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "排班"
Height = 180
Left = 6480
TabIndex = 18
Top = 4680
Width = 360
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "出生日期"
Height = 180
Left = 4920
TabIndex = 17
Top = 4680
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "性别"
Height = 180
Left = 3600
TabIndex = 16
Top = 4680
Width = 360
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "姓名"
Height = 180
Left = 2280
TabIndex = 15
Top = 4680
Width = 360
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "员工号"
Height = 180
Left = 720
TabIndex = 14
Top = 4680
Width = 540
End
End
Attribute VB_Name = "Person"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub LoadData()
Dim str As String, str1 As String, flag%, mark%
If Len(Trim(Text1.Text)) = 0 Then '无员工号
If Len(Trim(Text2.Text)) = 0 Then '无员工姓名
flag = 0
Else '匹配员工姓名
flag = 1: str1 = Text2.Text: mark = 2
End If
Else '匹配员工号
flag = 1: str = Text1.Text: mark = 1
If Len(Trim(Text2.Text)) <> 0 Then '匹配员工号和员工姓名
flag = 2: str1 = Text2.Text: mark = 2
End If
End If
'根据查询条件重新填充DataGrid
If flag = 0 Then
OpenTable Adodc1, "select * from 员工信息 "
ElseIf flag = 1 And mark = 1 Then
OpenTable Adodc1, "select * from 员工信息 " + "where " + " 员工号 " + " like '" + str + "%'"
ElseIf flag = 1 And mark = 2 Then
OpenTable Adodc1, "select * from 员工信息 " + "where " + " 姓名 " + " like '" + str1 + "%'"
ElseIf flag = 2 And mark = 2 Then
OpenTable Adodc1, "select * from 员工信息 " + "where " + " 员工号 " + " like '" + str + "%'" + " and " + " 姓名 " + " like '" + str1 + "%'"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo2.AddItem "早班"
Combo2.AddItem "中班"
Combo2.AddItem "晚班"
Combo2.AddItem "放假"
Combo3.AddItem "接待员"
Combo3.AddItem "领班"
Combo3.AddItem "经理"
LoadData
SetTextBoxState (False)
End Sub
Private Sub SetToolBarState(ByVal State As Boolean)
'设置Button的是否能够单击
Toolbar1.Buttons("first").Enabled = State
Toolbar1.Buttons("before").Enabled = State
Toolbar1.Buttons("next").Enabled = State
Toolbar1.Buttons("last").Enabled = State
Toolbar1.Buttons("new").Enabled = State
Toolbar1.Buttons("modify").Enabled = State
Toolbar1.Buttons("delete").Enabled = State
Toolbar1.Buttons("save").Enabled = Not State
Toolbar1.Buttons("cancel").Enabled = Not State
End Sub
Private Sub SetTextBoxState(ByVal State As Boolean)
Text4.Enabled = State
Combo1.Enabled = State
Text5.Enabled = State
Combo2.Enabled = State
Combo3.Enabled = State
End Sub
Private Sub Clear()
Dim strT As String, strID As String
OpenTable Adodc2, "select max(员工号) from 员工信息 "
If Not IsNull(Adodc2.Recordset.Fields(0)) Then
strT = ""
strID = Trim(str(Int(Mid(Adodc2.Recordset(0), 3, 4) + 1)))
For i = Len(strID) To 3
strT = strT & "0"
Next i
Text3 = "YD" & strT & strID
Else: Text3 = "YG0001"
End If
Text4.Text = ""
Text5.Text = ""
Combo1 = ""
Combo2 = ""
Combo3 = ""
End Sub
Private Sub Search_Click()
LoadData
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If StrComp(Button.Key, "first") = 0 Then
If Not Adodc1.Recordset.BOF And Not Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveFirst
ElseIf StrComp(Button.Key, "before") = 0 Then
If Not Adodc1.Recordset.BOF And Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
End If
ElseIf StrComp(Button.Key, "next") = 0 Then
If Not Adodc1.Recordset.BOF And Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
End If
ElseIf StrComp(Button.Key, "last") = 0 Then
If Not Adodc1.Recordset.BOF And Not Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
ElseIf StrComp(Button.Key, "new") = 0 Then
Adodc1.Recordset.AddNew
SetTextBoxState (True)
SetToolBarState (False)
Clear
ElseIf StrComp(Button.Key, "modify") = 0 Then
SetTextBoxState (True)
SetToolBarState (False)
ElseIf StrComp(Button.Key, "delete") = 0 Then
If Not Adodc1.Recordset.BOF And Not Adodc1.Recordset.EOF Then
If MsgBox("确定要删除吗?", vbYesNo, "提示") = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
End If
Else
MsgBox "当前无记录!", 64, "提示"
End If
ElseIf StrComp(Button.Key, "save") = 0 Then
If Text3 = "" Then
MsgBox "员工号不能为空", , "提示"
ElseIf Text4 = "" Then MsgBox "姓名不能为空", , "提示"
ElseIf Combo1 = "" Then MsgBox "离店时间不能为空", , "提示"
ElseIf Text5 = "" Then MsgBox "出生日期不能为空", , "提示"
ElseIf Combo2 = "" Then MsgBox "排班未选择", , "提示"
ElseIf Combo3 = "" Then MsgBox "职务不能为空", , "提示"
Else
SetTextBoxState (False)
SetToolBarState (True)
Adodc1.Recordset.Update
End If
ElseIf StrComp(Button.Key, "cancel") = 0 Then
SetTextBoxState (False)
SetToolBarState (True)
Form_Load
ElseIf StrComp(Button.Key, "exit") = 0 Then
LoadData
Unload Me
End If
End Sub
Private Sub Text5_Click()
Calendar1.Visible = True
End Sub
Private Sub Calendar1_Click()
Text5.Text = Calendar1.Value
Calendar1.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -