-- 作者:jk3622223
-- 发布时间:2012/7/26 16:56:00
-- [求助]帮我改一下统计代码
Dim bd1 As New SQLGroupTableBuilder("统计表1","长期医嘱") bd1.AddTable("长期医嘱","住次ID","住院主表","住次ID") Dim dt1 As fxDataSource bd1.Groups.AddDef("姓名") \'根据品名分组 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","临时医嘱") bd2.AddTable("临时医嘱","住次ID","住院主表","住次ID") Dim dt2 As fxDataSource bd2.Groups.AddDef("姓名") \'根据品名分组 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
|
-- 作者:jk362223
-- 发布时间:2012/7/27 10:10:00
--
Dim bd1 As New SQLGroupTableBuilder("统计表1","长期医嘱") bd1.C Dim dt1 As fxDataSource
bd1.AddTable("长期医嘱","住次ID","住院主表","住次ID") bd1.AddTable("长期医嘱","项目ID","长期医嘱模板","项目ID") 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("长期医嘱_报数","IIF([数量] >= 0,[数量],0)") \'对数量进行统计 bd1.Totals.AddExp("长期医嘱_金额","IIF([数量] > 0,[数量] * [单价],0)") \'对数量进行统计 dt1 = bd1.BuildDataSource()
Dim bd2 As New SQLGroupTableBuilder("统计表2","临时医嘱") bd2.C Dim dt2 As fxDataSource
bd2.AddTable("临时医嘱","住次ID","住院主表","住次ID") bd2.AddTable("临时医嘱","项目ID","临时医嘱模板","项目ID") 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("临时医嘱_报数","IIF([开始日期] >= [报起始日期]And[开始日期] <= [报截止日期],[数量],0)") \'对数量进行统计 bd2.Totals.AddExp("临时医嘱_金额","IIF([开始日期] >= [报起始日期]And[开始日期] <= [报截止日期],[数量] * [单价],0)") \'对数量进行统计 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
这是我新写的代码,,总不是有二个题示,
|
-- 作者:狐狸爸爸
-- 发布时间:2012/7/27 14:35:00
--
统计住院主表选定用户的数据:
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
|