应该怎么改?我把附助列改到临时列了,替换产品名称不知怎么写:
For Each ary() As String In DataTables("冲压车间工资表").GetValues("日期|产品名称|生产形式", "日期 is not null and 生产形式 <> '个人'")
Dim t As Table = Tables("冲压车间工资表")
For i As Integer = 1 To t.rows.count-1
If t.rows(i).isnull("产品名称") Then
t.rows(i)("产品名称") =t.rows(i-1)("产品名称")
End If
Next
'DataTables("冲压车间工资表").ReplaceFor("产品名称", "特殊产品", "产品名称 Is Null")
Dim drs As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期=#" & ary(0) & "# and 产品名称='" & ary(1) & "' and 生产形式='" & ary(2) & "'")
Dim sum As Double = 0
Dim count As Integer = 0
Dim ls As new List(Of String)
If DataTables("冲压车间工资表").DataCols.Contains("备注1") = False Then
DataTables("冲压车间工资表").DataCols.add("备注1", Gettype(String))
End If
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") = dr("备注1").replace("重复", Nothing)
Else
dr("备注1") = "重复" & dr("备注1").replace("重复", Nothing)
End If
Next
For Each dr As DataRow In drs
Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & dr("产品名称") & "' and 工序 = '" & dr("生产工序") & "'")
If fdr IsNot Nothing
dr("单价") = fdr("单价")
sum += dr("数量") * dr("单价")
End If
Next
For Each dr As DataRow In drs
If dr("备注1") Like "*重复*" Then
dr("分配金额") = Nothing
Else
dr("分配金额") = format(sum/count, "0.00")
End If
Next
Next
For Each dr As DataRow In DataTables("冲压车间工资表").Select("生产形式 = '个人'")
dr("分配金额") = dr("数量") * dr("单价")
Next
Tables("冲压车间工资表").filter = ""
Tables("冲压车间工资表").Sort = "日期,产品名称,生产形式"
Tables("冲压车间工资表").Filter = "日期 is null"