Dim sql As String = "selec t 入库日期 As 日期,类别,库存编码,产品名称,规格,单位,商标,备注,入库数量,0 as 出库数量 fro m 入库明细 union selec t 出库日期 As 日期,类别,库存编码,产品名称,规格,单位,商标,备注,0 as 入库数量,出库数量 fro m 出库明细 "
Dim bd1 As New CrossTableBuilder("统计表1", sql, "fzsale")
Dim dt1 As fxDataSource
bd1.HGroups.AddDef("类别")
bd1.HGroups.AddDef("库存编码") '根据型号分组
bd1.HGroups.AddDef("产品名称")
bd1.HGroups.AddDef("规格")
bd1.HGroups.AddDef("单位")
bd1.HGroups.AddDef("商标")
bd1.HGroups.AddDef("备注")
bd1.VGroups.AddDef("日期", DateGroupEnum.Year, "{0}年")
bd1.VGroups.AddDef("日期", "{0}月")
bd1.Totals.AddDef("入库数量", "入库数量") '对数量进行统计
bd1.Totals.AddDef("出库数量", "出库数量") '对数量进行统计
dt1 = bd1.BuildDataSource()
Dim bd3 As New CrossTableBuilder("统计表2", DataTables("产品信息"))
bd3.C
Dim dt3 As fxDataSource
'bd3.HGroups.AddDef("类别")
bd3.HGroups.AddDef("库存编码") '根据型号分组
bd3.HGroups.AddDef("产品名称")
bd3.HGroups.AddDef("规格")
bd3.HGroups.AddDef("单位")
bd3.HGroups.AddDef("商标")
bd3.HGroups.AddDef("备注")
bd3.HGroups.AddDef("期初库存", "期初库存") '对数量进行统计
dt3 = bd3.BuildDataSource()
Dim nms As String() = { "库存编码", "产品名称", "规格", "单位", "商标", "备注"}
dt3.Combine(nms, dt1, nms)
Tables("库存信息_Table8").DataSource = dt3 '将统计结果绑定到Table
DataTables("入库明细").LoadFilter = ""
DataTables("入库明细").Load
DataTables("出库明细").loadFilter = ""
DataTables("出库明细").load
With DataTables("库存信息_Table8").DataCols '用表达式列计算库存数据
.Add("{0}月_库存数量", GetType(Integer), "IsNull([期初库存],0) + IsNull({0}月_[入库数量],0) - ISNULL({0}月_[出库数量],0)")
End With