以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  多表统计组合  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=88168)

--  作者:lk15502
--  发布时间:2016/7/28 10:11:00
--  多表统计组合
老师,下面的代码你执行,你看看有什么问题,好像前面的代码没有用;

Dim str As String = DataTables("出库表").getcomboliststring("入库编号")
Str = str.replace("|","\',\'")
Dim ckbs As List(of String)
Ckbs = DataTables("库存表").getvalues("入库编号","入库编号 In(\'" & str & "\')")

Dim bd1 As New GroupTableBuilder("统计表1",DataTables("入库表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("品名大类") \'根据品名大类分组
bd1.Totals.AddDef("重量","入库_重量") \'对重量进行统计
bd1.Totals.AddDef("匹数","入库_匹数") \'对匹数进行统计
bd1.fromserver = True
For Each ckb As String In ckbs
    bd1.filter = "[入库编号] = \'ckb\'"
Next
dt1 = bd1.BuildDataSource()

Dim bd2 As New GroupTableBuilder("统计表2",DataTables("库存表"))
Dim dt2  As fxDataSource
bd2.Groups.AddDef("品名大类") \'根据品名大类分组
bd2.Totals.AddDef("重量","库存_重量") \'对重量进行统计
bd2.Totals.AddDef("匹数","库存_匹数") \'对匹数进行统计
bd2.fromserver = True
For Each ckb As String In ckbs
    Bd2.filter = "[入库编号] = \'ckb\'"
Next
dt2 = bd2.BuildDataSource()

Dim bd3 As New GroupTableBuilder("统计表3",DataTables("出库表"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("品名大类") \'根据品名大类分组
bd3.Totals.AddDef("重量","出库_重量") \'对重量进行统计
bd3.Totals.AddDef("匹数","出库_匹数") \'对匹数进行统计
bd3.fromserver = True
For Each ckb As String In ckbs
    Bd3.filter = "[入库编号] = \'ckb\'"
Next
dt3 = bd3.BuildDataSource()

dt1.Combine("品名大类",dt2,"品名大类") \'将库存统计数据组合到入库统计数据
dt1.Combine("品名大类",dt3,"品名大类") \'将出库统计数据组合到入库统计数据

Tables("统计窗口_Table1").DataSource = dt1 \'将统计结果绑定到Table
Dim t As Table = Tables("统计窗口_Table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True

g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "入库_重量,入库_匹数,库存_重量,库存_匹数,出库_重量,出库_匹数"
g.Caption = "总计"
t.SubtotalGroups.Add(g)

t.Subtotal()

--  作者:狐狸爸爸
--  发布时间:2016/7/28 10:29:00
--  

Dim Ckbs As String = DataTables("出库表").getcomboliststring("入库编号")
Ckbs = "(\'"& ckbs.replace("|","\',\'") & "\')"

 

Dim bd1 As New GroupTableBuilder("统计表1",DataTables("入库表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("品名大类") \'根据品名大类分组
bd1.Totals.AddDef("重量","入库_重量") \'对重量进行统计
bd1.Totals.AddDef("匹数","入库_匹数") \'对匹数进行统计
bd1.fromserver = True
bd1.filter = "[入库编号] = in " & cbks
dt1 = bd1.BuildDataSource()

 

。。。。。


--  作者:Hyphen
--  发布时间:2016/7/28 10:32:00
--  一种窗口传值和共用查询窗口的简单应用
bd1.filter = "入库编号 In (\'" & str & "\')"
...
Bd2.filter = "入库编号 In (\'" & str & "\')"
...
 Bd3.filter = "入库编号 In (\'" & str & "\')"

--  作者:lk15502
--  发布时间:2016/7/28 10:45:00
--  
狐爸,我需要的是出库表和库存表都有的入库编号;:然后再在入库表;库存表;出库表在查,是仓管中“余布”的概念,就是入库好事800公斤,出库没有一次出清,比如出了600公斤,库存200公斤就是余布,我要把库存中的余布都找出来,用入库编号一一对应,下面的代码,能达到要求吗,谢谢

Dim Ckbs As String = DataTables("出库表").getcomboliststring("入库编号")
Ckbs = "(\'"& ckbs.replace("|","\',\'") & "\')"


--  作者:Hyphen
--  发布时间:2016/7/28 10:48:00
--  
上传例子
--  作者:lk15502
--  发布时间:2016/7/28 11:07:00
--  
Dim str As String = DataTables("库存表").getcomboliststring("入库编号")
Str = str.replace("|","\',\'")
Dim ckbs As List(of String)
Ckbs = DataTables("出库表").getvalues("入库编号","入库编号 In(\'" & str & "\')")
Ckbs = ckbs.replace("|","\',\'")

Dim bd1 As New GroupTableBuilder("统计表1",DataTables("入库表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("品名大类") \'根据品名大类分组
bd1.Totals.AddDef("重量","入库_重量") \'对重量进行统计
bd1.Totals.AddDef("匹数","入库_匹数") \'对匹数进行统计
bd1.fromserver = True
bd1.filter = "[入库编号] = in " & ckbs
dt1 = bd1.BuildDataSource()

Dim bd2 As New GroupTableBuilder("统计表2",DataTables("库存表"))
Dim dt2  As fxDataSource
bd2.Groups.AddDef("品名大类") \'根据品名大类分组
bd2.Totals.AddDef("重量","库存_重量") \'对重量进行统计
bd2.Totals.AddDef("匹数","库存_匹数") \'对匹数进行统计
bd2.fromserver = True
bd2.filter = "[入库编号] = in " & ckbs
dt2 = bd2.BuildDataSource()

Dim bd3 As New GroupTableBuilder("统计表3",DataTables("出库表"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("品名大类") \'根据品名大类分组
bd3.Totals.AddDef("重量","出库_重量") \'对重量进行统计
bd3.Totals.AddDef("匹数","出库_匹数") \'对匹数进行统计
bd3.fromserver = True
bd3.filter = "[入库编号] = in " & ckbs
dt3 = bd3.BuildDataSource()

dt1.Combine("品名大类",dt2,"品名大类") \'将库存统计数据组合到入库统计数据
dt1.Combine("品名大类",dt3,"品名大类") \'将出库统计数据组合到入库统计数据

Tables("统计窗口_Table1").DataSource = dt1 \'将统计结果绑定到Table
Dim t As Table = Tables("统计窗口_Table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True

g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "入库_重量,入库_匹数,库存_重量,库存_匹数,出库_重量,出库_匹数"
g.Caption = "总计"
t.SubtotalGroups.Add(g)

t.Subtotal()

--  作者:Hyphen
--  发布时间:2016/7/28 11:10:00
--  
上传项目实例
--  作者:lk15502
--  发布时间:2016/7/28 16:55:00
--  
结合狐表和其他狐友的共同努力代码能用了:
Dim kcbs As String = DataTables("库存表").getcomboliststring("入库编号")
kcbs = "(\'"& kcbs.replace("|","\',\'") & "\')"

Dim Ckbs As String = DataTables("出库表").getcomboliststring("入库编号","入库编号 in " & kcbs)
Ckbs = "(\'"& ckbs.replace("|","\',\'") & "\')"

Dim bd1 As New GroupTableBuilder("统计表1",DataTables("入库表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("品名大类") \'根据品名大类分组
bd1.Totals.AddDef("重量","入库_重量") \'对重量进行统计
bd1.Totals.AddDef("匹数","入库_匹数") \'对匹数进行统计
bd1.fromserver = True
bd1.filter = "入库编号 In (\'" & ckbs & "\')"
dt1 = bd1.BuildDataSource()

Dim bd2 As New GroupTableBuilder("统计表2",DataTables("库存表"))
Dim dt2  As fxDataSource
bd2.Groups.AddDef("品名大类") \'根据品名大类分组
bd2.Totals.AddDef("重量","库存_重量") \'对重量进行统计
bd2.Totals.AddDef("匹数","库存_匹数") \'对匹数进行统计
bd2.fromserver = True
bd2.filter = "入库编号 In (\'" & ckbs & "\')"
dt2 = bd2.BuildDataSource()

Dim bd3 As New GroupTableBuilder("统计表3",DataTables("出库表"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("品名大类") \'根据品名大类分组
bd3.Totals.AddDef("重量","出库_重量") \'对重量进行统计
bd3.Totals.AddDef("匹数","出库_匹数") \'对匹数进行统计
bd3.fromserver = True
bd3.filter = "入库编号 In (\'" & ckbs & "\')"
dt3 = bd3.BuildDataSource()

dt1.Combine("品名大类",dt2,"品名大类") \'将库存统计数据组合到入库统计数据
dt1.Combine("品名大类",dt3,"品名大类") \'将出库统计数据组合到入库统计数据

Tables("统计窗口_Table1").DataSource = dt1 \'将统计结果绑定到Table
Dim t As Table = Tables("统计窗口_Table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True

g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "入库_重量,入库_匹数,库存_重量,库存_匹数,出库_重量,出库_匹数"
g.Caption = "总计"
t.SubtotalGroups.Add(g)

t.Subtotal()
图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看