如下图,组合统计,
If e.Form.Controls("CheckBox1").checked And e.Form.Controls("CheckBox2").checked And e.Form.Controls("CheckBox3").checked And e.Form.Controls("CheckBox4").checked And e.Form.Controls("CheckBox5").checked Then
Dim nms As String() = {"门店","库位","销售年度","销售季节","大类","品类","货号"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
关联列是根据用户选的来定的。那现在得一一将这些情况给列出来,如下代码,好繁琐啊。有没有用变量的方式来代替呢。。。
此主题相关图片如下:10.png
Dim bd4 As New SQLcrossTableBuilder("统计表4","库位销售分析")
Dim dt4 As fxDataSource
bd4.C
bd4.HGroups.AddDef("门店") '添加客户列用于水平分组
bd4.HGroups.AddDef("库位") '添加客户列用于水平分组
bd4.HGroups.AddDef("销售日期",DateGroupEnum.year,"区间") '添加客户列用于水平分组
bd4.vGroups.AddDef("调整期间","调整期间_{0}_销售金额") '添加客户列用于水平分组
If e.Form.Controls("CheckBox1").checked Then
bd4.HGroups.AddDef("销售年度") '添加客户列用于水平分组
End If
If e.Form.Controls("CheckBox2").checked Then
bd4.HGroups.AddDef("销售季节") '添加客户列用于水平分组
End If
If e.Form.Controls("CheckBox3").checked Then
bd4.HGroups.AddDef("大类") '添加客户列用于水平分组
End If
If e.Form.Controls("CheckBox4").checked Then
bd4.HGroups.AddDef("品类") '添加客户列用于水平分组
End If
If e.Form.Controls("CheckBox5").checked Then
bd4.HGroups.AddDef("货号") '添加客户列用于水平分组
End If
bd4.Totals.AddDef("销售金额") '添加数量列用于统计
If e.Form.Controls("CheckBox7").checked Then
bd4.VGroups.AddDef("陈列方式") '添加日期列用于垂直分组,按月分组
End If
bd4.filter = filter
bd4.CommandTimeOut = 600
dt4 = bd4.BuildDataSource()
If e.Form.Controls("CheckBox1").checked And e.Form.Controls("CheckBox2").checked And e.Form.Controls("CheckBox3").checked And e.Form.Controls("CheckBox4").checked And e.Form.Controls("CheckBox5").checked Then
Dim nms As String() = {"门店","库位","销售年度","销售季节","大类","品类","货号"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
ElseIf e.Form.Controls("CheckBox1").checked And e.Form.Controls("CheckBox2").checked And e.Form.Controls("CheckBox3").checked And e.Form.Controls("CheckBox4").checked Then
Dim nms As String() = {"门店","库位","销售年度","销售季节","大类","品类"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
ElseIf e.Form.Controls("CheckBox1").checked And e.Form.Controls("CheckBox2").checked And e.Form.Controls("CheckBox3").checked Then
Dim nms As String() = {"门店","库位","销售年度","销售季节","大类"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
ElseIf e.Form.Controls("CheckBox1").checked And e.Form.Controls("CheckBox2").checked Then
Dim nms As String() = {"门店","库位","销售年度","销售季节"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
ElseIf e.Form.Controls("CheckBox1").checked Then
Dim nms As String() = {"门店","库位","销售年度"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
Else
Dim nms As String() = {"门店","库位"} '指定连接列
dt1.Combine(nms,dt4,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
dt1.Combine(nms,dt3,nms) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1
End If
[此贴子已经被作者于2016/7/22 17:26:46编辑过]