Dim d1 As Date = e.Form.Controls("U").Value
Dim d2 As Date = e.Form.Controls("V").Value
If d1 = Nothing Or d2 = Nothing Then
MessageBox.Show("日期都不能为空","友情提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Else
With DataTables("生产记录")
.LoadFilter = "日期>='" & d1 & "' and 日期<='" & d2 & "'"
.Load()
End With
' Dim g As New CrossTableBuilder("统计表2", DataTables("生产记录"))
' g.HGroups.AddDef("配方名称")
' g.VGroups.AddDef("原料名称")
' g.Totals.AddDef("实际值")
Dim b As New GroupTableBuilder("统计表2",DataTables("生产记录"))
b.Groups.AddDef("配方名称")
b.Groups.AddDef("原料名称")
b.Totals.AddDef("设定值")
b.Totals.AddDef("实际值")
b.Totals.AddDef("误差值")
b.Build '生成统计表
MainTable = Tables("统计表2")
Tables("窗口1_Table1").DataSource =b.BuildDataSource()
End If
Dim g As New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "配方名称" '分组列
g.TotalOn = "设定值,实际值,误差值" '进行统计
g.Caption = "合计" '设置标题
With Tables("窗口1_Table1")
.SubtotalGroups.Clear() '清除原有的分组
.SubtotalGroups.Add(g) '加入刚刚定义的分组
.Subtotal() '生成汇总模式
End With
With Tables("窗口1_Table1")
.MergeMode = MergeModeEnum.Standard
.MergeCols.Clear()
.MergeCols.Add("配方名称")
.MergeSort = "配方名称"
.AllowMerge = True
End With