Dim bd6 As New GroupTableBuilder("统计表6",DataTables("机物料出库表"))
Dim dt6 As fxDataSource
bd6.Groups.AddDef("品名") '根据品名分组
bd6.Groups.AddDef("规格") '根据入库编号分组
bd6.Totals.AddDef("数量","本月总出库_数量") '对数量进行统计
bd6.Totals.AddDef("金额","本月总出库_金额")
bd6.filter = "申购分类 in ('机物料','食堂') and 出库日期 < '" & lday & "'"
bd6.fromserver = True
dt6 = bd6.BuildDataSource()
Dim nms As String() = {"品名","规格"}
dt5.Combine(nms,dt1,nms)
dt5.Combine(nms,dt2,nms)
dt5.Combine(nms,dt3,nms)
dt5.Combine(nms,dt4,nms) '将收入退回统计数据组合到收入完工入库统计数据
dt5.Combine(nms,dt6,nms) '将发出销售统计数据组合到收入完工入库统计数据
Tables(e.Form.Name & "_Table7").DataSource = dt5 '将统计结果绑定到Table
Dim t As Table = Tables(e.Form.Name & "_Table7")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "上月总入库_数量,上月总入库_金额,上月总出库_数量,上月总出库_金额,本月进_数量,本月进_金额,本月出_数量,本月出_金额,本月总入库_数量,本月总入库_金额,本月总出库_数量,本月总出库_金额"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.autosizecols()
t.Cols("上月总入库_数量").Visible = False
t.Cols("上月总入库_金额").Visible = False
t.Cols("上月总出库_数量").Visible = False
t.Cols("上月总出库_金额").Visible = False
t.Cols("本月总入库_数量").Visible = False
t.Cols("本月总入库_金额").Visible = False
t.Cols("本月总出库_数量").Visible = False
t.Cols("本月总出库_金额").Visible = False
With DataTables(e.Form.Name & "_Table7").DataCols '用表达式列计算上月结存和本月结存
.Add("上月结存_数量",Gettype(Double), "IsNull([上月总入库_数量],0) - ISNULL([上月总出库_数量],0)")
.Add("上月结存_金额",Gettype(Double), "IsNull([上月总入库_金额],0) - ISNULL([上月总出库_金额],0)")
.Add("本月结存_数量",Gettype(Double), "IsNull([本月总入库_数量],0) - ISNULL([本月总出库_数量],0)")
.Add("本月结存_金额",Gettype(Double), "IsNull([本月总入库_金额],0) - ISNULL([本月总出库_金额],0)")
End With
t.Subtotal()