-- 作者:jk3622223
-- 发布时间:2012/7/26 12:13: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("长期医嘱_报数","IIF([数量] >= 0,IsNull([数量] * [片数] * [次数],0),0)") \'对数量进行统计 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("临时医嘱_报数","IIF([开始日期] >= [报起始日期]And[开始日期] <= [报截止日期],IsNull([数量],0),0)") \'对数量进行统计 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
|