If DataTables("打砂车间工资表").DataCols.Contains("备注1") = False Then
DataTables("打砂车间工资表").DataCols.add("备注1", Gettype(String))
End If
Dim dt As DataTable = DataTables("打砂车间工资表")
For Each ary() As String In dt.GetValues("日期|生产形式", "日期 is not null and 生产形式 = '安比例分配'")
Dim count_rs As Integer = dt.GetValues("姓名", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "'").count
Dim drs_ds As List(Of DataRow) = dt.Select("日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "' and (备注 <> '机动' or 备注 is null)")
Dim drs_jd As List(Of DataRow) = dt.Select("日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "' and 备注 = '机动'")
Dim smoney As Double = dt.compute("sum(金额)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "'")
Dim bl As Double = 0
If count_rs < 8 Then
bl = 0.77
Else
bl = 0.74
End If
Dim stime As Double = dt.compute("sum(计件工时)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "'and ( 备注 <> '机动' or 规格 is null)")
For Each dr As DataRow In drs_ds
dr("分配后金额") = format(dr("金额") * bl,"0.00")
Next
stime = dt.compute("sum(计件工时)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "' and 备注 = '机动'")
Dim dj = smoney * (1-bl) / stime
For Each dr As DataRow In drs_jd
dr("分配后金额") = format(dj * dr("计件工时"),"0.00")
Next
Next
For Each ary() As String In dt.GetValues("日期|生产形式", "日期 is not null and 生产形式 like '*直接分配*'")
Dim drs As List(Of DataRow) = DataTables("打砂车间工资表").Select("日期=#" & ary(0)& "# and 生产形式='" & ary(1) & "'")
Dim stime As Double = dt.compute("sum(计件工时)", "日期=#" & ary(0) & "# And 生产形式='" & ary(1) & "'")
Dim ls As new List(Of String)
Dim smoney As Double = dt.compute("sum(金额)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "'")
Dim count As Integer = 0
For Each dr As DataRow In drs
Dim str As String = dr("姓名")
If str > "" Then
If ls.Contains(str) = False Then
count += 1
ls.add(str)
dr("备注1") = dr("备注1").replace("重复", Nothing)
Else
dr("备注1") = "重复" & dr("备注1").replace("重复", Nothing)
End If
Else
dr("分配后金额") = Nothing
End If
Next
For Each dr As DataRow In drs
If dr("备注1") Like "*重复*" OrElse dr.IsNull("姓名") Then
dr("分配后金额") = Nothing
Else
dr("分配后金额") = format(smoney/count, "0.00")
End If
Next
Next
For Each dr As DataRow In DataTables("打砂车间工资表").Select("生产形式 = '个人计件'")
dr("分配后金额") = format(dr("数量") * dr("单价"),"0.00")
Next
Tables("打砂车间工资表").Sort = "日期,规格,生产形式"