Dim g As New CrossTableBuilder("成绩转置1", DataTables("成绩登记表"))
g.HGroups.AddDef("考试期数")
g.HGroups.AddDef("年级")
g.HGroups.AddDef("班级")
g.HGroups.AddDef("学号")
g.HGroups.AddDef("姓名")
g.VGroups.AddDef("课程名称")
g.Totals.AddDef("分数", "分数")
g.HorizontalTotal = True
g.Build()
MainTable = Tables("成绩转置1")
Tables("成绩转置1").grid.Cols("合计").caption = "总分"
Dim dic As new Dictionary(of String, String)
For Each c As Col In Tables("成绩转置1").cols
dic.add(c.caption, c.name)
Next
'---------------------------------
Dim fsd As New List(of Integer)
For Each r1 As Row In Tables("自定义统计分数段").Rows
If r1.Checked = False Then
MessageBox.Show("请定义统计分数段,并把无用的数据删除,否则系统将无法统计运行","提示")
Return
Else
If r1.Checked Then
fsd.add(r1("分数段"))
End If
End If
Next
If fsd.count> 0 Then
fsd.sort
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("考试期数", Gettype(String))
dtb.AddDef("年级", Gettype(String))
dtb.AddDef("班级", Gettype(String))
dtb.AddDef("科目", Gettype(String), 32)
For Each fs As Integer In fsd
dtb.AddDef(fs & "分" & iif(fs = fsd(0), "以下","以上") , Gettype(Integer))
Next
dtb.Build()
End If
Dim flt As String
Dim dt As DataTable =DataTables("成绩转置1")
Dim t1 As Table =Tables("统计")
t1.StopRedraw
'Dim bjs As List(of String) = dt.Getvalues("年级|班级|考试期数")
'dt.GetUniqueValues
'For Each flt In bjs
'Dim f As New Filler
'f.SourceTable =DataTables("科目表")
'f.DataTable = t1.DataTable
'f.Fill()
't1.DataTable.ReplaceFor("考试期数",flt,"考试期数 Is null")
't1.DataTable.ReplaceFor("班级",flt,"班级 Is null")
't1.DataTable.ReplaceFor("年级",flt,"年级 Is null")
'Next
Dim bjs As List(of String()) = dt.Getvalues("年级|班级|考试期数")
For Each bj As String() In bjs
Dim f As New Filler
f.SourceTable =DataTables("科目表")
f.DataTable = t1.DataTable
f.Fill()
t1.DataTable.ReplaceFor("考试期数",bj(2),"考试期数 Is null")
t1.DataTable.ReplaceFor("班级",bj(1),"班级 Is null")
t1.DataTable.ReplaceFor("年级",bj(0),"年级 Is null")
Next
For Each dc As Col In t1.Cols
If dc.Index > 1 Then
For Each dr As Row In t1.Rows
flt = "班级 = '" & dr("班级") & "' and 年级 = '" & dr("年级") & "' and 考试期数 = '" & dr("考试期数") & "'And " & dic(dr("科目"))
If dc.Index = 4 Then
flt+ = " < " & dc.name.split("分")(0)
ElseIf dc.Index =Tables("统计").Cols.count -1 Then
flt+ = " >= " & dc.name.split("分")(0)
ElseIf dc.Index > 4
flt+ = " >= " & dc.name.split("分")(0) & " And " & dic(dr("科目")) & " < " & t1.Cols(dc.Index+1).Name.split("分")(0)
Else
Continue For
End If
dr(dc.name) =dt.Compute("Count(姓名)",flt)
Next
End If
Next
t1.DataTable.SysStyles("EmptyArea").BackColor = Color.White
t1.ResumeRedraw
MainTable = t1
Tables("统计_Table2").DataSource = DataTables("统计")