Dim dt As DataTable
Dim b As new GroupTableBuilder("统计表1",DataTables("融资合同备案表"))
b.Groups.AddDef("接收日期",DateGroupEnum.Year,"年")
b.Groups.AddDef("接收日期",DateGroupEnum.Month,"月")
b.Groups.AddDef("备案单位")
b.Groups.AddDef("借款单位")
b.Totals.AddDef("备案编号",AggregateEnum.Count,"合同数")
dt = b.Build(False)
'根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"年|月|备案单位|借款单位")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.allnodes
Dim year As Integer = nd.DataRow("年")
Dim month As Integer = nd.DataRow("月")
Dim badw As String = nd.DataRow("备案单位")
Dim jkdw As String = nd.DataRow("借款单位")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt.Compute("sum(合同数)","年 = " & year) & "份合同)"
Case 1
nd.text = nd.Text & "月(" & dt.Compute("sum(合同数)","年 = " & year & " and 月 = " & month) & "份合同)"
Case 2
nd.text = nd.text & "(" & dt.Compute("sum(合同数)","年 = " & year & " And 月 = " & month & " and 备案单位 = " & badw) & "份合同)"
Case 3
nd.text = nd.text & "(" & nd.DataRow("合同数") & "份合同)"
'nd.Text = nd.Text & "(" & dt.Compute("sum(合同数)","备案单位 = " & badw & " and 借款单位 = " & jkdw & " and 年 = " & year & " and 月 = " & month) & "份合同)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("sum(合同数)") & "份合同)",0)
trv.ResumeRedraw
红色一行报错