-- 代码
Dim T1 As Table = e.Form.Controls("Table1").Table
Dim DTP1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1") \'起始日期
Dim DTP2 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2") \'终止日期
Dim cmb4 As WinForm.ComboBox = e.Form.Controls("ComboBox4")
Dim cmb1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim cmb2 As WinForm.ComboBox = e.Form.Controls("ComboBox2") \'ComboBox3出库类型不参与
dhtjbm = e.Sender.Text & Format(DTP1.VALUE,"yy年M月d日") & "-" & Format(DTP2.VALUE,"yy年M月d日")\'全局全局代码,打印的表名
\'+++++处理pp1+++++++++++++++++++++++++++++++++++++++
Dim sql As String
pp1 = cmb4.value \'将所选品牌赋值给pp1
spb = pp1 & "商品表"
ckb = pp1 & "出库记录表"
\'++++++构造查询条件++++++++递推法++++++++++++++++++
Dim filter As String = " [日期] >= \'" & DTP1.VALUE & "\' And [日期] <= \'" & DTP2.VALUE & "\'and [已处理]= 1 and [类型] in (\'调货\',\'配货\') " \'只统计调货与配货
If cmb1.value <> Nothing Then \'店铺条件
filter & = " and [店铺] = \'" & cmb1.value & "\'"
End If
If cmb2.value <> Nothing Then \'去向条件
filter & =" and [去向] = \'" & cmb2.value & "\'"
End If
\'++++++构造sql语句+++++++++++
sql = "Se lect 店铺,去向,日期,类型,a.条码,数量,(数量*标准价) As 标准金额,已处理,编码 As 出库方编码 f rom {" & ckb & "} As a LEFT JOIN {" & spb & "} As b ON a.条码 = b.条码 WHERE " & filter
\'\'+++++交叉统计++++++++
Dim g As New CrossTableBuilder("统计表1",sql,CONN )
g.HGroups.AddDef("店铺","调出店铺") \'水平分组列
g.HGroups.AddDef("去向","调入店铺") \'水平分组列
\'g.HGroups.AddDef("日期",DateGroupEnum.none) \'水平分组列
g.VGroups.AddDef("类型") \'垂直分组列
g.Totals.AddDef("数量", "数量") \'统计列
g.Totals.AddDef("标准金额", "标准金额") \'统计列
g.HorizontalTotal = True \'水平求和
g.Subtotal = True \'启用汇总模式,才有小计
g.SubtotalLevel = 2 \'参加汇总的分组数,先小计调入店铺,再小计调出店铺
\'g.VerticalTotal = True \'垂直方向自动汇总 \'后面要启用汇总模式,有垂直方向的总计
\'+++++++将统计表绑定到窗口表+++++++++++++
T1.DataSource = g.BuildDataSource
T1.AutoSizeCols