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("总分排名",s1,dt)
For Each Value As String In Values
Dim tjlb As String = e.Form.Controls("类别").text '统计类别
Dim nj As String = e.Form.Controls("年级").text '统计年级
Dim bm As String = Value & "重点人数对照表"
Dim dtb As New DataTableBuilder(bm)
dtb.AddDef("单位",Gettype(String),8)
dtb.AddDef("单位代码",Gettype(String),8)
dtb.AddDef("统计类别",Gettype(String),8)
For Each tjbb As String In DataTables("成绩库").GetValues("部别","[年级] = '" & nj & "'And [类别] = '"& tjlb &"'")
For i As Integer = 0 To 2
dtb.AddDef( tjbb & i ,Gettype(Double),"",tjbb &"_"& (nj-i) & "级")
Next
Next
For i As Integer = 0 To 2
dtb.AddDef("合计"& i ,Gettype(Double),"","合 计_"& (nj-i) & "级")
Next
dtb.Build()
For i As Integer = 0 To 2
For Each tjbb As String In DataTables("成绩库").GetValues("部别","[年级] = '" & nj & "'And [类别] = '"& tjlb &"'")
Dim dr As DataRow
dr = DataTables(bm).find("单位='全区合计'")
If dr Is Nothing Then
dr = DataTables(bm).addnew()
dr("单位") = "全区合计"
dr("单位代码") = 0
dr("统计类别") = tjlb
End If
Dim wdr As DataRow = DataTables("分数线").Find("类别 = '" & tjlb & "'And 部别 = '" & tjbb & "'")
Dim tj As String = Left(bm,2) & "排名"
Dim tj1 As String = Left(bm,2)
dr( tjbb & i ) = DataTables("成绩库").Compute("count(单位)", "" & tj1 & " >= '" & wdr("目标" & (i+1) ) & "' And [部别] = '" & tjbb & "' And [类别] = '" & tjlb & "'And [年级] = '"& (nj-i) &"'")
dr("合计"& i ) += dr( tjbb & i )
For Each tjdw As String In DataTables("成绩库").GetValues("单位","[年级] = '" & nj & "'And [类别] = '"& tjlb &"'")
For Each dwdm As String In DataTables("成绩库").GetValues("单位代码","[单位] = '" & tjdw & "'")
dr = DataTables(bm).find("单位='" & tjdw & "'")
If dr Is Nothing Then
dr = DataTables(bm).addnew()
dr("单位") = tjdw
dr("单位代码") = dwdm
End If
dr("统计类别") = tjlb
dr( tjbb & i ) = DataTables("成绩库").Compute("count(单位)", "" & tj1 & " >= '" & wdr("目标" & (i+1) ) & "' And [单位] = '" & dr("单位") & "' And [部别] = '" & tjbb & "' And [类别] = '" & tjlb & "'And [年级] = '"& (nj-i) &"'")
dr("合计"& i ) += dr( tjbb & i )
Next
Next
If bm <> "成绩库" AndAlso bm <> "校名设置" AndAlso bm <> "目标设置" AndAlso bm <> "分数线" AndAlso bm <> "市级1分段" AndAlso bm <> "区县基数" AndAlso bm <> "基数" AndAlso bm <> "调用基数"
dr = DataTables(bm).find("单位= '市级分数线'")
If dr Is Nothing Then
dr = DataTables(bm).addnew()
dr("单位") = "市级分数线"
dr("单位代码") = 100
dr("统计类别") = tjlb
End If
dr( tjbb & i ) = wdr("目标" & (i+1) )
End If
Next
Next
Tables(Value & "重点人数对照表").Sort = "单位代码"
For Each bm1 As DataTable In DataTables
If bm1.name <> "成绩库" AndAlso bm1.Name <> "校名设置" AndAlso bm1.Name <> "目标设置" AndAlso bm1.Name <> "分数线"AndAlso bm1.Name <> "市级1分段"AndAlso bm1.Name <> "区县基数"AndAlso bm1.Name <> "基数"AndAlso bm1.Name <> "调用人数"
For Each fdr As DataRow In bm1.Select("[单位] = '全区合计' Or [单位] = '市级分数线'")
Dim pos As Integer = Tables(bm1.Name).FindRow(fdr)
Dim ns As C1.Win.C1FlexGrid.CellStyle = Tables(bm1.Name).grid.Styles.Add("自定义的样式")
ns.ForeColor = Color.Red
ns.Font = New Font("宋体",9, FontStyle.Bold)
For i As Integer = 0 To Tables(bm1.Name).Cols.Count - 1
Tables(bm1.Name).Grid.SetCellStyle(pos+2, i+1, ns) '注:标题行如果是1栏的"pos+1 ",2栏的"pos+2 ", 3栏的"pos+3 ".
Next
Next
End If
Next
For Each dr As DataRow In DataTables( Value & "重点人数对照表").DataRows
For Each dc As DataCol In DataTables( Value & "重点人数对照表").datacols
If dc.IsNumeric Then
If dr(dc.name) = 0 Then
dr(dc.name) = Nothing
End If
End If
Next
Next
Dim str As String = ""
For Each tjbb As String In DataTables("成绩库").GetValues("部别","[年级] = '" & nj & "'And [类别] = '"& tjlb &"'")
Tables( Value & "重点人数对照表").SetHeaderRowHeight(35,35,35) '表名的两个标题行的行高
Tables( Value & "重点人数对照表").DefaultRowHeight = 27 '设置默认的行高
For i As Integer = 0 To 2
str = str & "|" & tjbb & i & "|55|合计" & i & "|55"
Next
Tables( Value & "重点人数对照表").Cols("单位").TextAlign = TextAlignEnum.Center
Tables( Value & "重点人数对照表").Cols("单位代码").TextAlign = TextAlignEnum.Center
Tables( Value & "重点人数对照表").Cols("统计类别").TextAlign = TextAlignEnum.Center
Next
Tables( Value & "重点人数对照表").SetColVisibleWidth("单位|65|单位代码|50|统计类别|50|" & str.trim("|"))
Next
e.Form.Controls("Label1").text ="统计结束,请导出数据!否则数据会丢失!"
StatusBar.Reset
StatusBar.DefaultMessage = "统计完毕!"
Time1 = Date.Now
e.Form.Controls("Label4").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
Tables("成绩库").ResumeRedraw