Tables("统计_Table1").StopRedraw
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("进货"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("型号") '根据型号分组
bd1.Totals.AddDef("进货_数量") '对数量进行统计
bd1.Totals.AddDef("进货_金额") '对金额进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("销售"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("型号") '根据型号分组
bd2.Totals.AddDef("销售_数量") '对数量进行统计
bd2.Totals.AddDef("销售_金额") '对金额进行统计
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("退货"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("型号") '根据型号分组
bd3.Totals.AddDef("退货_数量") '对数量进行统计
bd3.Totals.AddDef("退货_金额") '对金额进行统计
dt3 = bd3.BuildDataSource()
dt1.Combine("型号",dt2,"型号") '将销售统计数据组合到进货统计数据
dt1.Combine("型号",dt3,"型号") '将退货统计数据组合到进货统计数据
Tables("统计_Table1").DataSource = dt1
With DataTables("统计_Table1").DataCols '用表达式列计算库存数据
.Add("调整_数量",Gettype(Double), "")
End With
For Each r As Row In Tables("统计_Table1").Rows
If r("型号") = "NB-XG118" Then
r("调整_数量") = r("进货_数量") * 0.8
Else
r("调整_数量") = r("进货_数量")
End If
Next
Tables("统计_Table1").ResumeRedraw