Dim bd1 As New SQLGroupTableBuilder("报主清单","长期医嘱")
Dim dt1 As fxDataSource
bd1.Groups.AddDef("收费项目") '根据品名分组
bd1.Groups.AddDef("项目类别") '根据型号分组
bd1.Groups.AddDef("项目规格") '根据品名分组
bd1.Groups.AddDef("单位") '根据型号分组
bd1.Groups.AddDef("单价") '根据型号分组
bd1.Totals.AddExp("报数","长期医嘱_报数") '对数量进行统计
bd1.Totals.AddExp("金额","长期医嘱_金额") '对数量进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New SQLGroupTableBuilder("统计表2","临时医嘱")
Dim dt2 As fxDataSource
bd2.Groups.AddDef("收费项目") '根据品名分组
bd2.Groups.AddDef("项目类别") '根据型号分组
bd2.Groups.AddDef("项目规格") '根据品名分组
bd2.Groups.AddDef("单位") '根据型号分组
bd2.Groups.AddDef("单价") '根据型号分组
bd2.Totals.AddExp("报数","临时医嘱_报数") '对数量进行统计
bd2.Totals.AddExp("金额","临时医嘱_金额") '对数量进行统计数
Dim nms As String() = {"收费项目","项目类别","项目规格","单位","单价"}
dt1.Combine(nms,dt2,nms)'将销售统计数据组合到进货统计数据
Tables("窗口1_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("窗口1_Table1").DataCols '用表达式列计算库存数据
.Add("数量",Gettype(Integer), "IsNull([长期医嘱_报数],0) + ISNULL([临时医嘱_报数],0)")
.Add("金额",Gettype(Double), "IsNull([长期医嘱_金额],0) + ISNULL([临时医嘱_金额],0)")
End With
不知这样编写对不对?