以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 多个联接列 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=42652) |
||||
-- 作者:石四 -- 发布时间:2013/11/18 12:49:00 -- 多个联接列 Dim nms As String() = {"品名","型号"} \'指定连接列 dt1.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据
在事例文件表增加了日期列,希望能按月和型号分组统计. bd1.Groups.AddDef
改成如下: Dim nms As String() = {"日期","月份","型号"} \'指定连接列
行不通
|
||||
-- 作者:Bin -- 发布时间:2013/11/18 14:45:00 -- 你又不是每个表都有日期.数据不统一怎么分组? |
||||
-- 作者:有点甜 -- 发布时间:2013/11/18 21:49:00 -- 简单改了一下 Dim nms As String() = {"月", "型号"} \'指定连接列 Dim bd1 As New GroupTableBuilder("统计表1",DataTables("进货单")) Dim dt1 As fxDataSource bd1.Groups.AddDef("日期", "月") bd1.Groups.AddDef("型号") \'根据型号分组 bd1.Totals.AddDef("数量","进货_数量") \'对数量进行统计 bd1.Totals.AddDef("金额","进货_金额") \'对金额进行统计 dt1 = bd1.BuildDataSource() Dim bd2 As New GroupTableBuilder("统计表2",DataTables("销售单")) Dim dt2 As fxDataSource bd2.Groups.AddDef("日期", "月") bd2.Groups.AddDef("型号") \'根据型号分组 bd2.Totals.AddDef("数量","销售_数量") \'对数量进行统计 bd2.Totals.AddDef("金额","销售_金额") \'对金额进行统计 dt2 = bd2.BuildDataSource() Dim bd3 As New GroupTableBuilder("统计表3",DataTables("退货单")) Dim dt3 As fxDataSource bd3.Groups.AddDef("日期", "月") bd3.Groups.AddDef("型号") \'根据型号分组 bd3.Totals.AddDef("数量","退货_数量") \'对数量进行统计 bd3.Totals.AddDef("金额","退货_金额") \'对金额进行统计 dt3 = bd3.BuildDataSource() dt1.Combine(nms,dt2,nms ) \'将销售统计数据组合到进货统计数据 dt1.Combine(nms ,dt3,nms ) \'将退货统计数据组合到进货统计数据 Tables("窗口1_Table1").DataSource = dt1 \'将统计结果绑定到Table With DataTables("窗口1_Table1").DataCols \'用表达式列计算库存数据 .Add("库存_数量",Gettype(Integer), "IsNull([进货_数量],0) - ISNULL([销售_数量],0) - ISNULL([退货_数量],0)") .Add("库存_金额",Gettype(Double), "[库存_数量] /[进货_数量] * [进货_金额]") End With Tables("窗口1_Table1").SetColVisibleWidth("月|90|型号|90|库存_数量|90|库存_金额|90") |
||||
-- 作者:石四 -- 发布时间:2013/11/19 11:53:00 -- 谢谢楼上,我明白错在哪了,正确的(没用窗口表):
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("进货单")) Dim bd2 As New GroupTableBuilder("统计表2",DataTables("销售单")) Dim bd3 As New GroupTableBuilder("统计表3",DataTables("退货单")) Dim nms As String() = {"月份","型号"} \'指定连接列 With DataTables("统计表1").DataCols \'用表达式列计算库存数据 MainTable=Tables("统计表1") |