A.
Dim tb As Table =Tables(e.Form.name & "_Table1")
Dim dt1,dt2 As fxDataSource
Dim g As New GroupTableBuilder("统计表1",DataTables("库存"))
g.Groups.AddDef("货品编码") '根据产品分组
g.Totals.AddDef("当前库存") '对数量进行统计
dt1 = g.BuildDataSource()
Dim g1 As New GroupTableBuilder("统计表1",DataTables("库存商品"))
g1.Groups.AddDef("货品编码")
g1.Groups.AddDef("货品类型")
g1.Groups.AddDef("计量单位")
g1.Groups.AddDef("货品名称")
g1.Groups.AddDef("规格型号")
g1.Groups.AddDef("备注")
g1.Totals.AddDef("库存上限")
g1.Totals.AddDef("库存下限")
g1.Totals.AddDef("入库参考价")
g1.Totals.AddDef("出库参考价")
dt2 = g1.BuildDataSource()
dt1.Combine("货品编码",dt2,"货品编码")
tb.DataSource = dt1
tb.SetColVisibleWidth("货品编码|-1|货品类型|-1|计量单位|-1|货品名称|-1|当前库存|-1|规格型号|-1|生产厂商|-1|库存上限|-1|库存下限|-1|入库参考价|-1|出库参考价|-1|备注|-1")
Dim kppms As List(Of String)
kppms = DataTables("库存").GetUniqueValues("", "货品编码")
For Each rrr As Row In tb.Rows
If kppms.Contains(rrr("货品编码"))=False Then
rrr.Delete
End If
Next
B.
Dim sql As String
Dim dst1 As Table = Tables(e.Form.name & "_Table1")
sql = "Select a.货品编码,当前库存,货品类型,计量单位,货品名称,规格型号,生产厂商,库存上限,库存下限,入库参考价,出库参考价,备注 from("
sql+ ="Select 货品编码,sum(当前库存) As 当前库存 From {库存} group by 货品编码) a Left jOIN {库存商品} b ON a.货品编码 = b.货品编码"
dst1.fill(sql,True)