Dim mg As New Merger
DataTables("考勤表").DeleteFor("")
pth = dlg.FileName
Dim Book As New XLS.Book(pth)
mg.SourcePath = pth
mg.Format = "excel" '指定格式
mg.SourceTableName = book.sheets(0).name & "$" '指定要合并的表
mg.DataTableName = "考勤表" '指定接收数据的表
mg.Merge() '开始
vars("考勤表")= True
Tables("test_Table2").DataSource = DataTables("考勤表")
For Each r As Row In Tables("考勤表").rows
Dim i = R.index
If (r("签退时间") >= "22:00" Or (r("签退时间") >= "00:00" And r("签退时间") <= "04:00")) And Tables("考勤表").rows(i+1)("迟到时间") < "00:30" Then
Tables("考勤表").rows(i+1)("迟到时间") = Nothing
End If
If r("实到") = "1" Then
r("实到") = Nothing
Else If r("实到") = "0" Then
r("实到") = "1"
End If
Next
With DataTables("考勤表")
.DataCols.Add("迟到扣款",Gettype(Integer), "IIF(迟到时间> '00:15'and 迟到时间<= '00:30', 20 ,IIF(迟到时间> '00:30'and 迟到时间<= '00:60', 50 ,0))" )
End With
DataTables("考勤表").datacols.Add("旷工扣款", Gettype(Double))
For Each r2 As DataRow In DataTables("考勤表").DataRows
If r2("是否旷工")= "True" Then
Dim fr2 As DataRow = DataTables("人员信息表").sqlFind("姓名 = '" & r2("姓名") & "' ")
If fr2 IsNot Nothing Then
r2("旷工扣款") = fr2("实发工资")/22/2
End If
End If
Next
Dim g As New GroupTableBuilder("统计表1", DataTables("考勤表"))
g.Groups.AddDef("姓名")
g.Totals.AddDef("迟到扣款")
g.Totals.AddDef("旷工扣款")
g.Totals.AddDef("迟到时间", AggregateEnum.Count,"迟到次数")
g.Totals.AddDef("实到","请假天数")
g.Totals.AddDef("是否旷工", AggregateEnum.Count,"旷工次数")
g.Totals.AddDef("补助", AggregateEnum.Count,"补助次数")
g.Totals.AddDef("加班", AggregateEnum.Count,"加班次数")
g.Build()
With DataTables("统计表1")
.DataCols.Add("加班费",Gettype(Double))
.DataCols.Add("全勤奖",Gettype(Double),"IIF(迟到次数 = '0' and 请假天数= '0' and 旷工次数 = '0',300 ,0 )" )
.DataCols.Add("总扣款",Gettype(Double), "迟到扣款 + 旷工扣款" )
End With
Dim nl As new List(of DataRow)
For Each tr As DataRow In DataTables("统计表1").DataRows
'---------------------加班计算
Dim fdj As DataRow = DataTables("人员信息表").SQLFind("姓名 = '"& tr("姓名") & "'")
If fdj IsNot Nothing Then
If fdj("状态") = "实习" OrElse fdj("状态") = "培训" Then
tr("加班费") = tr("加班次数") * 150 + tr("补助次数") * 50
Else If fdj("状态") = "正式" OrElse fdj("状态") = "试用" Then
tr("加班费") = tr("加班次数") * 200 + tr("补助次数") * 50
End If
End If
'------------------迟到计算
If tr("迟到次数") < 3 Then
Dim drs As List(Of DataRow)
drs = DataTables("考勤表").Select("迟到时间 <>''and 姓名 = '"& tr("姓名") & "'")
If drs IsNot Nothing Then
For Each kqr As DataRow In drs
If kqr("迟到时间") >"00:60" Then
nl.Add(kqr)
End If
Next
If nl.Count = 0 Then
tr("迟到扣款") = 0
End If
End If
End If
Next
Tables("test_Table1").DataSource = DataTables("统计表1")