以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]临时表统计 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=103889) |
-- 作者:lgj716330 -- 发布时间:2017/7/19 11:07:00 -- [求助]临时表统计 Dim Filter As String = "1=1" Dim Filter1 As String = "1=1" With e.Form.Controls("SYB") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "事业部 In ( \'" & .Value.replace(",","\',\'") & "\')" End If End With With e.Form.Controls("RQ1") If .Value IsNot Nothing Then If Filter1 > "" Then Filter1 = Filter1 & " And " End If Filter1 = Filter1 & "日期 >= \'" & .value & "\'" End If End With With e.Form.Controls("RQ2") If .Value IsNot Nothing Then If Filter1 > "" Then Filter1 = Filter1 & " And " End If Filter1 = Filter1 & "日期 <= \'" & .value & "\'" End If End With Dim dtb As New DataTableBuilder("表B") dtb.AddDef("日期", Gettype(Date), 4) dtb.AddDef("费用类型", Gettype(String), 10) dtb.AddDef("费用性质", Gettype(String), 10) dtb.AddDef("费用科目", Gettype(String), 10) dtb.AddDef("生产部门", Gettype(String), 10) dtb.AddDef("固定费用", Gettype(Double)) dtb.Build() Dim kms() As String = {"A1","A2","A3","A4","A5"} For Each dr1 As DataRow In DataTables("固定费用分配表").DataRows For Each km As String In kms Dim dr2 As DataRow = DataTables("表B").AddNew() dr2("日期") = dr1("日期") dr2("费用类型") = dr1("费用类型") dr2("费用性质") = dr1("费用性质") dr2("费用科目") = dr1("费用科目") dr2("生产部门") = km dr2("固定费用") = dr1(km) Next Next Dim b As New SQLCrossTableBuilder("统计表1","表B") Dim dt1 As fxDataSource b.AddTable("表B","生产部门","生产部门档案","部门名称") b.HGroups.AddDef("日期",DateGroupEnum.none) b.HGroups.AddDef("生产部门") b.VGroups.AddDef("费用性质") b.VGroups.AddDef("费用类型") b.Totals.AddDef("固定费用") b.Filter = Filter1 dt1 = b.BuildDataSource() dt1.Show("统计表1") 临时表可以用SQLCrossTableBuilder吗,上述代码显示错误,“多余的)在查询表达式‘[日期])‘中
|
-- 作者:有点蓝 -- 发布时间:2017/7/19 11:21:00 -- 临时表不可以用SQLCrossTableBuilder |
-- 作者:lgj716330 -- 发布时间:2017/7/19 12:36:00 -- Dim b0 As New GroupTableBuilder("表BB",DataTables("表B")) Dim dt10 As fxDataSource b0.Groups.AddDef("日期",DateGroupEnum.none) b0.Groups.AddDef("生产部门") b0.Groups.AddDef("费用性质") b0.Groups.AddDef("费用类型") b0.Totals.AddDef("固定费用") b0.Filter = Filter1 dt10 = b0.BuildDataSource() Dim b00 As New GroupTableBuilder("表BC",DataTables("生产部门档案")) Dim dt100 As fxDataSource b00.Groups.AddDef("部门名称") b00.Groups.AddDef("事业部") b00.Filter = Filter dt100 = b00.BuildDataSource() dt10.Combine("生产部门",dt100,"部门名称") dt10.Show("表BB") \'显示统计结果 嗯,我中间通过这样过渡了下,但表BB的“生产部门”同一个部门有多行,而表BC的“部门名称”是唯一的,如何将表BC的“事业部”匹配到表BB的每一行上呢
|
-- 作者:有点甜 -- 发布时间:2017/7/19 14:29:00 -- 生成表BB以后,循环每一行,去【部门档案】表查询对应的数据,然后赋值。 |
-- 作者:lgj716330 -- 发布时间:2017/7/19 15:30:00 -- 明白了 |