-- 作者:刘林
-- 发布时间:2017/4/26 20:31:00
-- 分段统计
e.Form.BaseForm.windowstate = 2 Dim cmd As New SQLCommand Dim dt3 As DataTable cmd.c If user.IsRole("区业务主管") cmd.CommandText = "SELE CT DISTINCT 考试名称,单位名称,年级代码,班级 From {成绩} " Else cmd.CommandText = "SELE CT DISTINCT 考试名称,单位名称,年级代码,班级 From {成绩} where 单位名称 = \'" & user.group & "\'" End If dt3 = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt3,"考试名称|单位名称|年级代码") Dim lbl As WinForm.Label = e.Form.Controls("Label2") If e.Form.width > lbl.Width lbl.Left = (e.Form.width - lbl.Width ) / 2 End If Dim g As New GroupTableBuilder("统计表1", DataTables("成绩")) Dim dt1 As Table = Tables("后台统计_table2") g.filter ="学段 =\'初中\'" g.Groups.AddDef("考试名称") g.Groups.AddDef("单位名称") g.Groups.AddDef("年级代码") g.Groups.AddDef("班级") g.Totals.AddDef("姓名",AggregateEnum.Count,"参考人数") g.Totals.AddDef("语文_A",AggregateEnum.Average,"语文平均_A") g.Totals.AddDef("语文_B",AggregateEnum.Average,"语文平均_B") g.Totals.AddDef("数学_A",AggregateEnum.Average,"数学平均_A") g.Totals.AddDef("数学_B",AggregateEnum.Average,"数学平均_B") g.Totals.AddDef("英语_A",AggregateEnum.Average,"英语平均_A") g.Totals.AddDef("英语_B",AggregateEnum.Average,"英语平均_B") g.Totals.AddDef("政治_A",AggregateEnum.Average,"政治平均_A") g.Totals.AddDef("政治_B",AggregateEnum.Average,"政治平均_B") g.Totals.AddDef("历史_A",AggregateEnum.Average,"历史平均_A") g.Totals.AddDef("历史_B",AggregateEnum.Average,"历史平均_B") g.Totals.AddDef("物理_A",AggregateEnum.Average,"物理平均_A") g.Totals.AddDef("物理_B",AggregateEnum.Average,"物理平均_B") g.Totals.AddDef("化学_A",AggregateEnum.Average,"化学平均_A") g.Totals.AddDef("化学_B",AggregateEnum.Average,"化学平均_B") g.Totals.AddDef("语文_语总",AggregateEnum.Average,"语文") g.Totals.AddDef("数学_数总",AggregateEnum.Average,"数学") g.Totals.AddDef("英语_英总",aggregateEnum.Average,"英语") g.Totals.AddDef("政治_政总",AggregateEnum.Average,"政治") g.Totals.AddDef("历史_历总",AggregateEnum.Average,"历史") g.Totals.AddDef("物理_物总",AggregateEnum.Average,"物理") g.Totals.AddDef("化学_化总",AggregateEnum.Average,"化学") g.Totals.AddDef("生物_",AggregateEnum.Average,"生物") g.Totals.AddDef("地理_",AggregateEnum.Average,"地理") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddExp("500以上","iif(折总 >= 500,1,0)") g.FromServer = True dt1.DataSource = g.BuildDataSource() dt1.DataTable.DataCols.Add("折总班序",Gettype(Integer)) dt1.DataTable.DataCols.Add("总分班序",Gettype(Integer)) Dim Arys1 As List(Of String()) = dt1.DataTable.GetValues("考试名称|单位名称|年级代码") For Each Ary1 As String() In Arys1 Dim drs As List(Of DataRow) = dt1.DataTable.Select("[考试名称] = \'" & ary1(0) & "\'and [年级代码] =\'" & ary1(2) & "\'", "折总平均 DESC") For m As Integer = 0 To drs.Count - 1 \'遍历所有行 If m > 0 AndAlso drs(m)("折总平均") = drs(m-1)("折总平均") Then \'如果总分和上一行相同 drs(m)("折总班序") = drs(m-1)("折总班序") \'则排名等于上一行 Else drs(m)("折总班序") = m + 1 \'设置排名 End If Next Next
Dim zrys1 As List(Of String()) = dt1.DataTable.GetValues("考试名称|单位名称|年级代码") For Each zry1 As String() In zrys1 Dim drs As List(Of DataRow) = dt1.DataTable.Select("[考试名称] = \'" & zry1(0) & "\'and [年级代码] =\'" & zry1(2) & "\'", "总分平均 DESC") For m As Integer = 0 To drs.Count - 1 \'遍历所有行 If m > 0 AndAlso drs(m)("总分平均") = drs(m-1)("总分平均") Then \'如果总分和上一行相同 drs(m)("总分班序") = drs(m-1)("总分班序") \'则排名等于上一行 Else drs(m)("总分班序") = m + 1 \'设置排名 End If Next Next
dt1.SetColVisibleWidth("考试名称|80|单位名称|160|年级代码|70|班级|30|参考人数|30|语文平均_A|40|语文平均_B|40|数学平均_A|30|数学平均_B|40|英语平均_A|40|英语平均_B|40|政治平均_A|40|政治平均_B|40|历史平均_A|40|历史平均_B|40|物理平均_A|40|物理平均_B|40|化学平均_A|40|化学平均_B|40|生物|40|地理|40|总分平均|70|总分班序|70|折总平均|70|折总班序|80|500以上|50") Dim t As Table = Tables("后台统计_Table2") t.Sort = "考试名称,年级代码,折总班序" If user.IsRole("区业务主管") = False t.filter = "单位名称 = \'" & user.group & "\'" End If
老师,请问上面想加一个统计时统计按成绩表的折总分数划段统计个数并显示,这个代码没提示错,也没显示出来,统计结果,请问是什么原因,怎么办
|