DataTables("成绩库").StopRedraw
Dim Values() As String = {"考室"}
For Each Value As String In Values
Dim dtb As New DataTableBuilder(value & "统计")
dtb.AddDef("单位",Gettype(String),8)
dtb.AddDef("参考人数",Gettype(Double))
dtb.AddDef("考室数",Gettype(Double))
dtb.AddDef("试卷袋起号",Gettype(Double))
dtb.AddDef("试卷袋止号",Gettype(Double))
dtb.AddDef("试卷袋编号",Gettype(String))
dtb.Build()
Tables("成绩库").Visible = True
Dim f As New Filler
f.SourceTable = DataTables("成绩库") '指定数据来源
f.SourceCols = "单位" '指定数据来源列
f.DataTable = DataTables( value & "统计" )'指定数据接收表
f.DataCols = "单位" '指定数据接收列
f.Fill() '填充数据
Next
For Each bm As DataTable In DataTables
For Each dr As DataRow In DataTables(bm.name).DataRows
If bm.name = "考室统计"
dr("参考人数") = DataTables("成绩库").Compute("count(单位)", "[单位] = '" & dr("单位") & "'")
dr("考室数") = DataTables("成绩库").Compute("Max(考室)", "[单位] = '" & dr("单位") & "'")
End If
Next
Next
For i As Integer = 0 To Tables("考室统计").count - 1
Dim r As Row = Tables("考室统计").Rows(i)
If i = 0
r("试卷袋起号") = 1
Else
r("试卷袋起号") = Tables("考室统计")(i-1,"考室数") + Tables("考室统计")(i-1,"试卷袋起号")
End If
r("试卷袋止号") = r("考室数") + r("试卷袋起号") -1
r("试卷袋编号") = r("试卷袋起号") & "-" & r("试卷袋止号")
Next
MainTable = Tables("考室统计")
DataTables("成绩库").ResumeRedraw
DataTables("成绩库").ResumeRedraw