Dim rsTime As New ADODB.Recordset
Dim tmsetswsb, tmsetswxb, tmsetxwsb, tmsetxwxb As Date Dim tmsb1, tmxb1 As Date
sql = \ order by ID desc\ sql2 = \ Set rs = ExecuteSQL(sql, strMsg) Set rsTime = ExecuteSQL(sql2, strmsg2)
If InFlag = False And OutFlag = False Then
MsgBox \请选择上下班\警告!\ End If
'添加上班信息 If InFlag = True Then
If txtID.Text = \
MsgBox \要添加上班信息,员工编号与姓名不能为空,请输入\提示\
Exit Sub End If
'判断上下午上班时间是否迟到 tmsb1 = dtpBT.Value h = Hour(tmsb1) m = Minute(tmsb1) s = Second(tmsb1)
tmsb1 = CDate(h & \
tmsetswsb = CDate(rsTime.Fields(\上午上班时间\ tmsetswxb = CDate(rsTime.Fields(\上午下班时间\ tmsetxwsb = CDate(rsTime.Fields(\下午上班时间\
'判断上午上班时间是否迟到 If tmsb1 < tmsetswxb Then If tmsb1 > tmsetswsb Then ilate = 1 MsgBox \迟到\ Else
ilate = 0
MsgBox \正常上班\
31
End If
'判断下午上班时间是否迟到 Else
If tmsb1 > tmsetxwsb Then
ilate = 1 MsgBox \迟到\ Else
ilate = 0
MsgBox \正常上班\ End If End If aflag = \入\ rs.AddNew
rs.Fields(\工号\ rs.Fields(\姓名\ rs.Fields(\当前日期\
rs.Fields(\上班时间\
rs.Fields(\出入标志\ rs.Fields(\迟到次数\ rs.Update rs.Close
MsgBox \已完成添加上班信息\添加结果!\
Unload Me Exit Sub End If
'添加下班信息 If OutFlag = True Then
If txtID.Text = \
MsgBox \要添加下班信息,员工编号与姓名不能为空,请输入\vbOKOnly +
vbExclamation, \警告\
Exit Sub End If
'判断上下午下班时间是否早退 tmxb1 = DTPicker1.Value
32
h = Hour(tmxb1) m = Minute(tmxb1) s = Second(tmxb1)
tmxb1 = CDate(h & \
tmsetxwsb = CDate(rsTime.Fields(\下午上班时间\ tmsetswxb = CDate(rsTime.Fields(\上午下班时间\ tmsetxwxb = CDate(rsTime.Fields(\下午下班时间\ '判断上午下班时间 If tmxb1 < tmsetxwsb Then If tmxb1 < tmsetswxb Then iearly = 1 MsgBox \早退\ Else
iearly = 0
MsgBox \正常下班\ End If '判断下午下班时间 Else
If tmxb1 < tmsetxwxb Then iearly = 1 MsgBox \早退\ Else
iearly = 0
MsgBox \正常下班\ End If End If aflag = \出\ rs.AddNew
rs.Fields(\工号\ rs.Fields(\姓名\ rs.Fields(\当前日期\
rs.Fields(\下班时间\= DTPicker1.Hour & \& DTPicker1.Minute & \&
DTPicker1.Second
rs.Fields(\出入标志\ rs.Fields(\早退次数\ rs.Update
33
rs.Close
MsgBox \已完成添加下班信息\添加结果!\
Unload Me Exit Sub End If End Sub
Private Sub Form_Load()
dtpET.Value = Date '初始化为当天时间 End Sub
2、设置员工每日产量考勤
在该窗体中输入相应的信息,完成每日产量考勤具体如图4-6所示,相应部分代码如下:
图4-6 员工每日产量考勤
34
“保存”按钮代码如下:
Private Sub cmdOK_Click() Dim rs As ADODB.Recordset Dim strSql As String Dim strMsg As String '根据需要进行字段限制 If ChkBoxJJ.Value = True Then If Combo1.Text = \ MsgBox \产品类型不能为空\ TextFocus Combo1 Exit Sub End If
If ChkBoxCP.Value = True Then If Combo2.Text = \
MsgBox \产品类型二不能为空\ TextFocus Combo2 Exit Sub End If
If Txt3.Text = 0 Then MsgBox \数量不能为空\ TextFocus Txt3 Exit Sub End If End If
If ChkBoxCR.Value = True Then If Combo3.Text = \
MsgBox \产品类型三不能为空\ TextFocus Combo3 Exit Sub End If
If Txt5.Text = 0 Then MsgBox \数量不能为空\
35