📄 frmleaveladd.frm
字号:
End Sub
Private Sub cmdPrevious_Click()
If rctLeavelList.RecordCount > 0 And rctLeavelList.BOF = False Then
rctLeavelList.MovePrevious
If Not rctLeavelList.BOF Then
Call InifrmLeavel
Else
MsgBox "已经到首了!", vbInformation + vbOKOnly, "移动记录"
End If
End If
End Sub
Private Sub cmdSave_Click()
Dim Emp_ID As Variant
Dim Emp_Name As Variant
Dim Depart_ID As Variant
Dim Leavel_start_time As Variant
Dim Leavel_end_time As Variant
Dim Leavel_days As Variant
Dim Leavel_ID As Variant
Dim Leavel_matter As Variant
Dim Examine_opinion As Variant
Dim Examine_person As Variant
Dim LS_ID As Variant
If Trim(txtEmpID.Text) = Empty Then
MsgBox "工作证号不能为空,请重新填写", vbInformation + vbOKOnly, "保存记录"
txtEmpID.SetFocus
Exit Sub
End If
If Trim(txtEmpName.Text) = Empty Then
MsgBox "姓名不能为空,请重新真写", vbInformation + vbOKOnly, "保存记录"
txtEmpName.SetFocus
Exit Sub
End If
If dcbDepartID.BoundText <> Empty Then
Depart_ID = dcbDepartID.BoundText
Else
Depart_ID = Empty
End If
If dcbLeavelStatus.BoundText <> Empty Then
LS_ID = Val(dcbLeavelStatus.BoundText)
Else
LS_ID = Empty
End If
If dcbLeavelType.BoundText <> Empty Then
Leavel_ID = Val(dcbLeavelType.BoundText)
Else
Leavel_ID = Empty
End If
If Trim(txtLeavel_days.Text) <> Empty Then
Leavel_days = Val(txtLeavel_days.Text)
Else
Leavel_days = Empty
End If
If InStr(mskLeavel_start_time.Text, " ") <= 0 Then
Leavel_start_time = CDate(mskLeavel_start_time.Text)
Else
Leavel_start_time = Empty
End If
If InStr(MaskLeavel_end_time.Text, " ") <= 0 Then
Leavel_end_time = CDate(MaskLeavel_end_time.Text)
Else
Leavel_end_time = Empty
End If
If Trim(txtLeavel_matter.Text) <> Empty Then
Leavel_matter = Trim(txtLeavel_matter.Text)
Else
Leavel_matter = Empty
End If
If Trim(txtExamine_opinion.Text) <> Empty Then
Examine_opinion = Trim(txtExamine_opinion.Text)
Else
Examine_opinion = Empty
End If
If Trim(txtExamine_person.Text) <> Empty Then
Examine_person = Trim(txtExamine_person.Text)
Else
Examine_person = Empty
End If
If frmLeavelAdd.Caption = "新增记录" Then
rctLeavelList.AddNew
End If
Emp_ID = Trim(txtEmpID.Text)
Emp_Name = Trim(txtEmpName.Text)
If SaveLeavelListRecords(rctLeavelList, Emp_ID, Emp_Name, Depart_ID, Leavel_start_time, Leavel_end_time, Leavel_days, Leavel_ID, Leavel_matter, Examine_opinion, Examine_person, LS_ID) = True Then
If frmLeavelAdd.Caption = "新增记录" Then
Call frmLeavelAddClear
End If
MsgBox "保存记录成功", vbInformation + vbOKOnly, "保存记录"
Else
MsgBox "保存记录失败", vbCritical + vbOKOnly, "保存记录"
End If
End Sub
Private Sub Form_Load()
Set dcbDepartID.RowSource = rctDepartList
dcbDepartID.BoundColumn = "Depart_ID"
dcbDepartID.ListField = "Depart_Name"
Set dcbLeavelStatus.RowSource = rctLeavelStatus
dcbLeavelStatus.BoundColumn = "LS_ID"
dcbLeavelStatus.ListField = "Ls_Name"
Set dcbLeavelType.RowSource = rctLeavelType
dcbLeavelType.BoundColumn = "Leavel_ID"
dcbLeavelType.ListField = "Leavel_Name"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("在退出之前确定记录是否已经保存了!您真的要退出吗?", vbQuestion + vbYesNo, "退出") = vbNo Then
Cancel = True
Exit Sub
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmLeavel.flexLeavel.Redraw = False
Call frmLeavel.IniGrid(frmLeavel.flexLeavel)
Call frmLeavel.ShowData(rctLeavelList, frmLeavel.flexLeavel)
frmLeavel.flexLeavel.Redraw = True
End Sub
Private Sub MaskLeavel_end_time_Change()
Dim intIsSpace As Integer
With MaskLeavel_end_time
intIsSpace = InStr(.Text, " ")
If intIsSpace <= 0 And InStr(mskLeavel_start_time.Text, " ") <= 0 Then
If CDate(.Text) < CDate(mskLeavel_start_time.Text) Then
MsgBox "结束时间不能小于起始时间", vbInformation + vbOKOnly, "输入错误"
Else
txtLeavel_days.Text = CDate(.Text) - CDate(mskLeavel_start_time.Text)
End If
End If
End With
End Sub
Private Sub MaskLeavel_end_time_GotFocus()
MaskLeavel_end_time.SelStart = 0
End Sub
Private Sub MaskLeavel_end_time_KeyPress(KeyAscii As Integer)
Dim intIsSpace As Integer
Dim intSelstart As Integer
With MaskLeavel_end_time
intSelstart = .SelStart
intIsSpace = InStr(.Text, " ")
' MsgBox intIsSpace & "," & intSelstart
If intIsSpace > 0 And intSelstart <> intIsPace Then
.SelStart = intIsSpace - 1
End If
If intIsSpace = 1 Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
Else
If .SelStart = 5 Then
If KeyAscii > Asc("1") Then
KeyAscii = 0
End If
End If
If .SelStart = 6 Then
If Mid(.Text, 6, 1) = "0" Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
End If
End If
If .SelStart = 8 Then
If Mid(.Text, 6, 2) = "02" Then
If KeyAscii > Asc("2") Then
KeyAscii = 0
End If
End If
If KeyAscii > Asc("3") Then
KeyAscii = 0
End If
End If
If .SelStart = 9 Then
If Mid(.Text, 9, 1) = "3" Then
'MsgBox Mid(.Text, 9, 1)
If KeyAscii > Asc("1") Then
KeyAscii = 0
End If
End If
If Mid(.Text, 9, 1) = "0" Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
End If
End If
End If
End With
End Sub
Private Sub mskLeavel_start_time_Change()
Dim enddate As Variant
If InStr(mskLeavel_start_time.Text, " ") <= 0 Then
If Trim(txtLeavel_days.Text) <> Empty Then
enddate = CDate(mskLeavel_start_time.Text) + Val(txtLeavel_days.Text)
MaskLeavel_end_time = Format(enddate, "yyyy-mm-dd")
End If
End If
End Sub
Private Sub mskLeavel_start_time_GotFocus()
mskLeavel_start_time.SelStart = 0
End Sub
Private Sub mskLeavel_start_time_KeyPress(KeyAscii As Integer)
Dim intIsSpace As Integer
Dim intSelstart As Integer
With mskLeavel_start_time
intSelstart = .SelStart
intIsSpace = InStr(.Text, " ")
' MsgBox intIsSpace & "," & intSelstart
If intIsSpace > 0 And intSelstart <> intIsPace Then
.SelStart = intIsSpace - 1
End If
If intIsSpace = 1 Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
Else
If .SelStart = 5 Then
If KeyAscii > Asc("1") Then
KeyAscii = 0
End If
End If
If .SelStart = 6 Then
If Mid(.Text, 6, 1) = "0" Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
End If
End If
If .SelStart = 8 Then
If Mid(.Text, 6, 2) = "02" Then
If KeyAscii > Asc("2") Then
KeyAscii = 0
End If
End If
If KeyAscii > Asc("3") Then
KeyAscii = 0
End If
End If
If .SelStart = 9 Then
If Mid(.Text, 9, 1) = "3" Then
'MsgBox Mid(.Text, 9, 1)
If KeyAscii > Asc("1") Then
KeyAscii = 0
End If
End If
If Mid(.Text, 9, 1) = "0" Then
If KeyAscii = Asc("0") Then
KeyAscii = 0
End If
End If
End If
End If
End With
End Sub
Private Sub txtEmpID_KeyUp(KeyCode As Integer, Shift As Integer)
Dim EmpId As String
EmpId = Trim(txtEmpID.Text)
If RecordSearch(rctEmployees, "Emp_ID", EmpId) = True Then
txtEmpName.Text = rctEmployees.Fields("Emp_name")
dcbDepartID.BoundText = rctEmployees.Fields("Depart_ID")
Else
txtEmpName.Text = Empty
dcbDepartID.BoundText = Empty
End If
End Sub
Private Sub txtEmpName_KeyUp(KeyCode As Integer, Shift As Integer)
Dim EmpName As String
EmpName = Trim(txtEmpName.Text)
If RecordSearch(rctEmployees, "Emp_Name", EmpName) = True Then
txtEmpID.Text = rctEmployees.Fields("Emp_ID")
dcbDepartID.BoundText = rctEmployees.Fields("Depart_ID")
Else
txtEmpID.Text = Empty
dcbDepartID.BoundText = Empty
End If
End Sub
Private Sub txtLeavel_days_Change()
If Trim(txtLeavel_days.Text) <> Empty Then
Call mskLeavel_start_time_Change
Else
mskLeavel_start_time.Text = " - - "
MaskLeavel_end_time.Text = " - - "
End If
End Sub
Private Sub txtLeavel_days_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And Not (KeyAscii = 13 Or KeyAscii = 8 Or KeyAscii = 9) Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -