DataTables("生产主表").LoadFilter = "完工时间 is null" '加载未完工机台
DataTables("生产主表").LoadOrder = "生产区域,预排区域"
DataTables("生产主表").Load()
Dim all As WinForm.RadioButton = e.Form.Controls("rdoall")
all.Checked = True
Dim dt As DataTable
Dim b As New SQLGroupTableBuilder("统计表1","生产主表") '首先生成统计表
b.C '数据源
b.Filter = "完工 = 0"
b.Groups.AddDef("预计上线时间",DateGroupEnum.Year,"年")
b.Groups.AddDef("预计上线时间",DateGroupEnum.Month,"月")
b.Totals.AddDef("制令号",AggregateEnum.Count,"制令号") '根据制令号列来统计记录数,也就是机台数
b.Build()
dt = DataTables("统计表1") '生成统计表
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "年|月","","年 Desc") '然后根据统计表生成目录树
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim Year As Integer = nd.DataRow("年")
Dim Month As Integer = 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) & "台)"
End Select
Next
trv.Nodes.Insert("加载所有行","加载所有行(" & dt.Compute("Sum(制令号)") & "台)",0)
trv.ResumeRedraw
Tables("生产主表").Sort = "生产区域,预排区域"