Dim bd1 As New GroupTableBuilder("统计表1",DataTables("ruku"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("cid") '根据型号分组
bd1.Groups.AddDef("namex")
bd1.Groups.AddDef("storehouseid","rukuid")
bd1.Totals.AddDef("number","进货_数量") '对数量进行统计
bd1.Totals.AddDef("total","进货_金额") '对金额进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("chuku"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("cid") '根据型号分组
bd2.Groups.AddDef("namex")
'bd2.Groups.AddDef("storehouseid","chukuid")
bd2.Totals.AddDef("number","销售_数量") '对数量进行统计
bd2.Totals.AddDef("total","销售_金额") '对金额进行统计
dt2 = bd2.BuildDataSource()
dt1.Combine("cid",dt2,"cid") '将销售统计数据组合到进货统计数据
Tables("ruku_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("ruku_Table1").DataCols '用表达式列计算库存数据
.Add("库存_数量",Gettype(Integer), "IsNull([进货_数量],0) - ISNULL([销售_数量],0)")
.Add("库存_金额",Gettype(Double), "[库存_数量] /[进货_数量] * [进货_金额]")
End With
'bd2.Groups.AddDef("storehouseid","chukuid")---一打开前头的注释就显示“已添加了具有相同键值的项”
[此贴子已经被作者于2014-3-23 22:47:09编辑过]