Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Selec t 接单日期,{接单登记}.接单单号,客户名称,产品名称,规格型号,单位,单价,销售数量,发货数量 as 已发货数量,(销售数量 - 发货数量) AS 未发货数量 Fro m ({接单登记} Inner JOIN {接单明细} ON {接单明细}.[接单单号] = {接单登记}.[接单单号]) ORDER BY 接单日期"
Dim sql As DataTable = cmd.ExecuteReader()
cmd.CommandText = "Selec t 发货日期,{发货表}.发货单号,{发货表}.接单单号,{发货表}.客户名称,产品名称,规格型号,单位,发货数量,接单日期 Fro m ({发货表} Inner JOIN {发货明细} ON {发货明细}.[发货单号] = {发货表}.[发货单号]) inner join {接单登记} on {接单登记}.接单单号 = {发货表}.接单单号 ORDER BY 发货日期"
Dim sqlf As DataTable = cmd.ExecuteReader()
Dim bd1 As New CrossTableBuilder("统计表1", sql)
Dim dt1 As fxDataSource
bd1.HGroups.AddDef("接单日期", DateGroupEnum.none)
bd1.HGroups.AddDef("接单单号")
bd1.HGroups.AddDef("客户名称")
bd1.HGroups.AddDef("产品名称") '添加客户列用于水平分组
bd1.HGroups.AddDef("规格型号") '添加客户列用于水平分组
bd1.HGroups.AddDef("单位") '添加客户列用于水平分组
bd1.HGroups.AddDef("销售数量")
bd1.HGroups.AddDef("已发货数量")
bd1.HGroups.AddDef("未发货数量")
dt1 = bd1.BuildDataSource()
Dim bd2 As New CrossTableBuilder("统计表2", sqlf )
Dim dt2 As fxDataSource
bd2.HGroups.AddDef("接单日期", DateGroupEnum.none)
bd2.HGroups.AddDef("接单单号")
bd2.HGroups.AddDef("客户名称")
bd2.HGroups.AddDef("产品名称") '添加客户列用于水平分组
bd2.HGroups.AddDef("规格型号") '添加客户列用于水平分组
bd2.HGroups.AddDef("单位") '添加客户列用于水平分组
bd2.VGroups.AddDef("发货日期", DateGroupEnum.none)
bd2.Totals.AddDef("发货数量")
dt2 = bd2.BuildDataSource()
Dim nms As String() = {"接单日期", "接单单号", "客户名称", "产品名称", "规格型号", "单位" }
dt1.Combine(nms, dt2, nms)
Tables("统计汇总_Table3").DataSource = dt1
Tables("统计汇总_Table3").cols("接单日期").width = 120
Tables("统计汇总_Table3").cols("接单单号").width = 100
Tables("统计汇总_Table3").cols("客户名称").width = 220
Tables("统计汇总_Table3").cols("产品名称").width = 220
Tables("统计汇总_Table3").cols("规格型号").width = 180
Tables("统计汇总_Table3").cols("单位").width = 50
For Each cl As Col In Tables("统计汇总_Table3").Cols
cl.TextAlign = TextAlignEnum.Center
Next