按比例分配的代码
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 / stime
For Each dr As DataRow In drs_ds
dr("分配后金额") = dj * dr("计件工时")
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("分配后金额") = dj * dr("计件工时")
Next
Next