以下是引用yyzlxc在2012-11-20 13:09:00的发言:
还有一个新问题,能否在此基础上再增加一行合计数,请lin_hailun老师指教,谢谢!!
如下代码
Select Case MainTable.Name
Case "统计"
MainTable.DataTable.DataRows.Clear
Dim dt As DataTable = DataTables("名册")
Dim chejians As List(Of String) = dt.GetUniqueValues("", "车间")
For Each chejian As String In chejians
Dim r As Row = MainTable.AddNew
r("车间") = chejian
r("在册人数") = dt.Compute("count(_Identify)", "进厂日期 <= #8/31/2012# And 离厂日期 > #8/1/2012# And 车间 = '" & chejian & "'")
For i As Integer = 2 To 6
r("技术等级_" & i) = dt.Compute("count(_Identify)", "技术等级 = " & i & " And 车间 = '" & chejian & "'And 进厂日期 <= #8/31/2012# And 离厂日期 > #8/1/2012# ")
Next
Next
Dim nr As Row = MainTable.AddNew
nr("车间") = "合计"
nr("在册人数") = MainTable.Compute("Sum(在册人数)")
For i As Integer = 2 To 6
nr("技术等级_" & i) = MainTable.Compute("Sum(" & "技术等级_" & i & ")")
Next
End Select