Dim dt As DataTable = DataTables("打砂车间工资表")
For Each ary() As String In dt.GetValues("日期|生产形式", "日期 is not null and 生产形式 = '安比例分配'")
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 bl As Double = 0
If drs_ds.count + drs_jd.count < 8 Then
bl = 0.77
Else
bl = 0.74
End If
Dim smoney As Double = dt.compute("sum(金额)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "'")
Dim stime As Double = dt.compute("sum(计件工时)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "' and (备注 <> '机动' or 规格 is null)")
Dim dj As Double = smoney * bl
For Each dr As DataRow In drs_ds
dr("分配后金额") = format(dj,"0.00")
Next
stime = dt.compute("sum(计件工时)", "日期=#" & ary(0) & "# and 生产形式='" & ary(1) & "' and 备注 = '机动'")
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 生产形式 = '集体直接分配*'")
Dim drs As List(Of DataRow) = DataTables("打砂车间工资表").Select("日期=#" & ary(0)& "' and 生产形式='" & ary(1) & "'" & "# and 姓名='" & ary(2))
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 ls.Contains(str) = False Then
count += 1
ls.add(str)
dr("备注") = dr("备注").replace("重复", Nothing)
Else
dr("备注") = "重复" & dr("备注").replace("重复", Nothing)
End If
Next
For Each dr As DataRow In drs
If dr("备注") Like "*重复*" 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
[此贴子已经被作者于2016/4/12 8:13:09编辑过]