-- 作者:jk3622223
-- 发布时间:2012/7/26 10:45:00
-- 请教多表统计中增加和统计表达式的问题?
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
不知这样编写对不对?
|
-- 作者:狐狸爸爸
-- 发布时间:2012/7/26 11:17:00
--
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("临时医嘱_金额","[数量] * [单价]") \'对数量进行统计 dt2 = bd2.BuildDataSource()
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
把下面的帮助看仔细了:
http://www.foxtable.com/help/topics/2389.htm
http://www.foxtable.com/help/topics/1626.htm
后台统计是不能直接用表达式列的。
[此贴子已经被作者于2012-7-26 11:17:53编辑过]
|