Dim Values() As String = {"总分"}
Dim s1() As String = New String() {"总分"}
Dim dt As Table = Tables("成绩库")
StatusBar.Message1= "正在生成统计数据"
Dim Time,Time1 As Date
Time = Date.now
e.Form.Controls("Label1").Text = "正在进行统计,请稍后……"
e.Form.Controls("Label4").Text = "正在计时…"
Functions.Execute("筛选记录",dt)
Functions.Execute("总分排名",s1,dt)
Functions.Execute("语数外排名",s1,dt)
For Each tjnj As String In DataTables("校名设置").GetValues("统计年级","单位 = '统计'")
For Each Value As String In Values
Dim dtb As New DataTableBuilder( value & tjnj & "级目标")
dtb.AddDef("部别",Gettype(String),8)
dtb.AddDef("年级",Gettype(Double))
dtb.AddDef("单位",Gettype(String),8)
dtb.AddDef("单位代码",Gettype(String),5)
dtb.AddDef("目标1",Gettype(Double),"","重点_A级_目标")
dtb.AddDef("目标2",Gettype(Double),"","重点_A级_完成")
dtb.AddDef("目标3",Gettype(Double),"","重点_B级_目标")
dtb.AddDef("目标4",Gettype(Double),"","重点_B级_完成")
dtb.AddDef("目标9",Gettype(Double),"","重点_C级_目标")
dtb.AddDef("目标10",Gettype(Double),"","重点_C级_完成")
dtb.AddDef("目标5",Gettype(Double),"","本科以上_目标")
dtb.AddDef("目标6",Gettype(Double),"","本科以上_完成")
dtb.AddDef("目标7",Gettype(Double),"","专科以上(语数外)_目标")
dtb.AddDef("目标8",Gettype(Double),"","专科以上(语数外)_完成")
dtb.Build()
Tables( value & tjnj & "级目标").SetHeaderRowHeight(26,26,26) '表名的标题行的行高
Tables( value & tjnj & "级目标").DefaultRowHeight = 25 '设置默认的行高
Tables( value & tjnj & "级目标").SetColVisibleWidth("单位|70|部别|50|年级|50|单位代码|44|目标1|50|目标2|50|目标3|50|目标4|50|目标9|50|目标10|50|目标5|50|目标6|50|目标7|53|目标8|53")
Tables( value & tjnj & "级目标").Cols("部别").TextAlign = TextAlignEnum.Center
Tables( value & tjnj & "级目标").Cols("年级").TextAlign = TextAlignEnum.Center
Tables( value & tjnj & "级目标").Cols("单位").TextAlign = TextAlignEnum.Center
Tables( value & tjnj & "级目标").Cols("单位代码").TextAlign = TextAlignEnum.Center
Next
For Each bubie As String In DataTables("成绩库").GetValues("部别","年级 = '" & tjnj & "'")
For Each bm As DataTable In DataTables
If bm.name <> "成绩库" AndAlso bm.Name <> "校名设置" AndAlso bm.Name <> "目标设置" AndAlso bm.Name <> "名册" AndAlso bm.Name <> "信息表" AndAlso bm.Name <> "原始名册"
Dim dr As DataRow
dr = DataTables(bm.name).addnew()
dr("单位") = "全县合计"
dr("部别") = bubie
dr("年级") = tjnj
Dim jdr As DataRow = DataTables("目标设置").Find("部别 = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "' And 类别 = '县合计'")
Dim c1 As Double = jdr("目标9")
Dim c2 As Double = jdr("目标10")
Dim c9 As Double = jdr("目标8")
Dim c3 As Double = jdr("目标12")
Dim c4 As Double = jdr("目标13")
Dim tj As String = Left(bm.name,2) & "排名"
Dim tj1 As String = Left(bm.name,2)
tj1 = Left(bm.name,2)
Dim c5 As Double = DataTables("成绩库").Find(" " & tj & " = '" & c1 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")(tj1)
Dim c6 As Double = DataTables("成绩库").Find(" " & tj & " = '" & c2 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")(tj1)
Dim c10 As Double = DataTables("成绩库").Find(" " & tj & " = '" & c9 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")(tj1)
Dim c7 As Double = DataTables("成绩库").Find(" " & tj & " = '" & c3 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")(tj1)
Dim c8 As Double = DataTables("成绩库").Find(" " & tj & " = '" & c4 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")(tj1)
dr("目标1") = c1
dr("目标3") = c2
dr("目标9") = c9
dr("目标5") = c3
dr("目标7") = c4
dr("目标2") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= '" & c5 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")
dr("目标4") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= '" & c6 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")
dr("目标10") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= '" & c10 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")
dr("目标6") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= '" & c7 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")
dr("目标8") = DataTables("成绩库").Compute("count(单位)", "语数外排名 <= '" & c4 & "' And [部别] = '" & dr("部别") & "' And 年级 = '" & dr("年级") & "'")
End If
Next
Next
StatusBar.Refresh
StatusBar.Reset
StatusBar.DefaultMessage = "统计完毕!"
e.Form.Controls("Label1").text ="统计结束,请导出数据!否则数据会丢失!"
Time1 = Date.Now
e.Form.Controls("Label4").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
DataTables("成绩库").ResumeRedraw