Dim dt As DataTable Dim b As New GroupTableBuilder("tjjj",DataTables("检验")) b.Groups.AddDef("日期",DateGroupEnum.none,"日期") b.Groups.AddDef("日期",DateGroupEnum.Year,"年") b.Groups.AddDef("日期",DateGroupEnum.Month,"月") b.Groups.AddDef("日期",DateGroupEnum.day,"日") b.Groups.AddDef("班别") b.Groups.AddDef("型号") b.Totals.AddDef("投入",AggregateEnum.sum,"投入") b.Totals.AddDef("涂胶不良",AggregateEnum.sum,"涂胶不良") b.Totals.AddDef("收卷",AggregateEnum.sum,"收卷") b.Totals.AddDef("收卷",AggregateEnum.Count,"卷数") dt = b.Build(False) '参数设置为False,生成一个临时表,不在主界面显示 Dim fdr As DataRow = dt.Find("日期 <= #" & Date.Today & "#", "日期 desc") '然后根据统计表生成目录树 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 day As Integer = nd.DataRow("日") Dim Product As String = nd.DataRow("班别") Dim Product1 As String = nd.DataRow("型号") Select Case nd.Level Case 0 nd.Text = nd.text & "年(投" & dt.Compute("Sum(投入)","年 = " & Year) & "m,收" & dt.Compute("sum(收卷)","年 = " & Year) & "m," & dt.Compute("sum(卷数)","年 = " & Year) & "卷,不" & Format(dt.Compute("sum(涂胶不良)","年 = " & Year) / dt.Compute("sum(投入)","年 = " & Year),"0.00%") & ")" Case 1 nd.Text = nd.text & "月(投" & dt.Compute("Sum(投入)","年 = " & Year & " And 月 = " & Month) & "m,收" & dt.Compute("Sum(收卷)","年 = " & Year & " And 月 = " & Month) & "m," & dt.Compute("Sum(卷数)","年 = " & Year & " And 月 = " & Month) & "卷,不" & Format(dt.Compute("sum(涂胶不良)","年 = " & Year & " And 月 = " & Month) / dt.Compute("sum(投入)","年 = " & Year & " And 月 = " & Month),"0.00%") & ")" Case 2 If nd.DataRow("日期") = fdr("日期") Then trv.SelectedNode = nd nd.ExpandAll End If nd.Text = nd.text & "日(投" & dt.Compute("Sum(投入)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day) & "m,收" & dt.Compute("Sum(收卷)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day) & "m," & dt.Compute("Sum(卷数)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day) & "卷,不" & Format(dt.Compute("sum(涂胶不良)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day) / dt.Compute("sum(投入)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day),"0.00%") & ")" Case 3 Dim tr As Double = dt.Compute("Sum(投入)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day & " and 班别 = '" & Product & "'") Dim sj As Double = dt.Compute("Sum(收卷)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day & " and 班别 = '" & Product & "'") Dim js As Double = dt.Compute("Sum(卷数)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day & " and 班别 = '" & Product & "'") Dim bl As Double = dt.Compute("sum(涂胶不良)","年 = " & Year & " And 月 = " & Month & " And 日 = " & day & " and 班别 = '" & Product & "'") nd.Text = nd.text & "日(投" & tr & "m,收" & sj & "m," & js & "卷,不" & Format(bl / tr,"0.00%") & ")" Case 4 nd.Text = nd.text & "(投" & nd.DataRow("投入") & "m," & nd.DataRow("收卷") & "m,不" & Format(nd.DataRow("涂胶不良") / nd.DataRow("投入"), "0.00%") & ")" End Select Next trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(投入)") & "m)",0) trv.ResumeRedraw
|