'pause = True
Dim t As Table = Tables("冲压车间工资表")
Dim tr As Row
For i As Integer = 1 To t.rows.count-1
tr = t.rows(i)
If tr.isnull("产品名称") AndAlso tr.IsNull("日期") = False AndAlso tr.("生产形式") <> "个人" Then
tr.("产品名称") =t.rows(i-1)("产品名称")
End If
If tr.IsNull("姓名") Then
tr.("姓名") =t.rows(i-1)("姓名")
End If
Next
If DataTables("冲压车间工资表").DataCols.Contains("备注1") = False Then
DataTables("冲压车间工资表").DataCols.add("备注1", Gettype(String))
End If
For Each ary() As String In DataTables("冲压车间工资表").GetValues("日期|产品名称|生产形式", "日期 is not null and 生产形式 <> '个人'")
'Dim drs As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期=#" & ary(0) & "# and 产品名称='" & ary(1) & "' and 生产形式='" & ary(2) & "'")
Dim drs As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期=#" & ary(0) & "# and 产品名称='" & ary(1).Replace("'","''") & "' and 生产形式='" & ary(2).Replace("'","''") & "'")
Dim sum As Double = 0
Dim count As Integer = 0
Dim ls As new List(Of String)
For Each dr As DataRow In drs
'Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & dr("产品名称") & "' and 工序 = '" & dr("生产工序") & "'")
Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & dr("产品名称").Replace("'","''") & "' and 工序 = '" & dr("生产工序").Replace("'","''") & "'")
If fdr IsNot Nothing
dr("单价") = fdr("单价")
sum += dr("数量") * dr("单价")
End If
Next
For Each dr As DataRow In drs
Dim str As String = dr("姓名")
If ls.Contains(str) = False Then
count += 1
ls.add(str)
dr("备注1") = Nothing 'dr("备注1").replace("重复", Nothing)
dr("分配后金额") = format(sum/count, "0.00")
Else
dr("备注1") = "重复" ' & dr("备注1").replace("重复", Nothing)
dr("分配后金额") = Nothing
End If
Next
Next
For Each dr As DataRow In DataTables("冲压车间工资表").Select("生产形式 = '个人'")
dr("分配后金额") = dr("数量") * dr("单价")
Next
For Each ary As String() In DataTables("冲压车间工资表").GetValues("日期|姓名", "日期 is not null")
Dim sum As Double = DataTables("冲压车间工资表").compute("sum(上班工时)", "日期=#" & ary(0) & "# and 姓名='" & ary(1) & "'")
Dim drs1 As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期=#" & ary(0) & "# and 姓名='" & ary(1) & "'")
Dim ls As new List(Of String)
For i As Integer = 0 To drs1.count-1
Dim dr = drs1(i)
If i = 0 Then
dr("备注1") = dr("备注1").replace("重复", Nothing)
If sum > = 8 Then
dr("上班天数") = 1
ElseIf sum > = 6 Then
dr("上班天数") =format(sum/8, "0.00")
ElseIf sum > = 4 And sum < 6 Then
dr("上班天数") = 0.5
ElseIf sum > = 2 And sum < 4 Then
dr("上班天数") =format(sum/8, "0.00")
Else
dr("上班天数") = 0
End If
Else
dr("备注1") = "重复" & dr("备注1").replace("重复", Nothing)
End If
Next
Next
Tables("冲压车间工资表").filter = ""
Tables("冲压车间工资表").Sort = "日期,产品名称,生产形式"
Tables("冲压车间工资表").Filter = "日期 is null"