统计住院主表选定用户的数据:
Dim bd1 As New SQLGroupTableBuilder("统计表1","长期医嘱")
bd1.Connection Name = "za20120720"
Dim dt1 As fxDataSource
bd1.Groups.AddDef("长期医嘱.住次ID") '根据品名分组
bd1.Groups.AddDef("姓名") '根据品名分组
bd1.Groups.AddDef("项目ID") '根据品名分组
bd1.Groups.AddDef("收费项目") '根据品名分组
bd1.Groups.AddDef("项目类别") '根据型号分组
bd1.Groups.AddDef("项目规格") '根据品名分组
bd1.Groups.AddDef("单位") '根据型号分组
bd1.Groups.AddDef("单价") '根据型号分组
bd1.Totals.AddExp("长期医嘱_报数","[数量]") '对数量进行统计
bd1.Totals.AddExp("长期医嘱_金额","[数量] * [单价]") '对数量进行统计
bd1.Filter = "姓名 = '" & Tables("住院主表").Current("姓名") & "'"
dt1 = bd1.BuildDataSource()
Dim bd2 As New SQLGroupTableBuilder("统计表2","临时医嘱")
bd2.Connection Name = "za20120720"
Dim dt2 As fxDataSource
bd2.Groups.AddDef("住次ID") '根据品名分组
bd2.Groups.AddDef("姓名") '根据品名分组
bd2.Groups.AddDef("项目ID") '根据品名分组
bd2.Groups.AddDef("收费项目") '根据品名分组
bd2.Groups.AddDef("项目类别") '根据型号分组
bd2.Groups.AddDef("项目规格") '根据品名分组
bd2.Groups.AddDef("单位") '根据型号分组
bd2.Groups.AddDef("单价") '根据型号分组
bd2.Totals.AddExp("临时医嘱_报数","[数量]") '对数量进行统计
bd2.Totals.AddExp("临时医嘱_金额","[数量] * [单价]") '对数量进行统计
bd2.Filter = "姓名 = '" & Tables("住院主表").Current("姓名") & "'"
dt2 = bd2.BuildDataSource()
Dim nms As String() = {"住次ID","姓名","项目ID","收费项目","项目类别","项目规格","单位","单价"}
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