Dim Filter As String
With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
Filter = "姓名 = '" & .Value & "'"
End If
End With
Dim filter2 As String = "1=1 "
With e.Form.Controls("DateTimePicker5")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
filter2 = filter2 & " and 日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker6")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
filter2 = filter2 & " and 日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("计件明细").Filter = Filter
Tables("计时明细").Filter = Filter
Tables("其它工资").Filter = Filter
End If
DataTables("计件工资").DataRows.Clear()
For Each xm As String In DataTables("计件明细").GetValues("姓名",Filter)
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("计件工资") = Tables("计件明细").compute("sum(计件工资)", "姓名 = '" & xm & "' and " & filter2 )
Next
For Each xm As String In DataTables("计时明细").GetValues("姓名",Filter)
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("其它工资") = Tables("计时明细").compute("sum(计时工资)", "姓名 = '" & xm & "' and " & filter2)
Next
For Each xm As String In DataTables("其它工资").GetValues("姓名",Filter)
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("奖励") = Tables("其它工资").compute("sum(奖励)", "姓名 = '" & xm & "' and " & filter2)
fdr("罚款") = Tables("其它工资").compute("sum(罚款)", "姓名 = '" & xm & "' and " & filter2)
fdr("房租") = Tables("其它工资").compute("sum(房租)", "姓名 = '" & xm & "' and " & filter2)
fdr("扣水电") = Tables("其它工资").compute("sum(扣水电)", "姓名 = '" & xm & "' and " & filter2)
fdr("保险") = Tables("其它工资").compute("sum(保险)", "姓名 = '" & xm & "' and " & filter2)
fdr("扣其它") = Tables("其它工资").compute("sum(扣其它)", "姓名 = '" & xm & "' and " & filter2)
Next