-- 作者:fubblyc
-- 发布时间:2016/7/22 17:26:00
-- 代码太繁琐。。求简洁的代码
如下图,组合统计,
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编辑过]
|
-- 作者:fubblyc
-- 发布时间:2016/7/26 10:47:00
--
太好了,简洁。谢谢!!
对了,大红袍老师,根据多选复选框 的选择情况,来进行不同表的组合统计。
此主题相关图片如下:微信截图_20160726103717.png
我现在是自己去组合,也是很繁琐:
If e.Form.Controls("CheckBox10").checked And e.Form.Controls("CheckBox8").checked and And e.Form.Controls("CheckBox9").checked Then
。。。
elseIf e.Form.Controls("CheckBox10").checked And e.Form.Controls("CheckBox9").checked Then
Dim bd3 As New SQLcrossTableBuilder("统计表3","陈列量") Dim dt3 As fxDataSource bd3.C bd3.HGroups.AddDef("门店") \'添加客户列用于水平分组 bd3.HGroups.AddDef("库位") \'添加客户列用于水平分组 bd3.vGroups.AddDef("调整期间","调整期间_{0}_陈列sku数") \'添加客户列用于水平分组 bd2.Totals.AddDef("动销量") \'添加数量列用于统计 bd2.filter = filter bd2.CommandTimeOut = 600 dt2 = bd2.BuildDataSource()
Dim bd1 As New SQLcrossTableBuilder("统计表1","库位销售分析") Dim dt1 As fxDataSource bd1.C bd1.HGroups.AddDef("门店") \'添加客户列用于水平分组 bd1.HGroups.AddDef("库位") \'添加客户列用于水平分组 bd1.HGroups.AddDef("销售日期",DateGroupEnum.year,"区间") \'添加客户列用于水平分组 bd1.Totals.AddDef("销售数量","销售件数") \'添加数量列用于统计 If e.Form.Controls("CheckBox6").checked Then bd1.Totals.AddDef("销售金额") \'添加数量列用于统计 End If bd1.filter = filter bd1.CommandTimeOut = 600 dt1 = bd1.BuildDataSource() Dim nms As String() = {"门店","库位"} \'指定连接列 dt3.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据 dt3.Combine(nms,dt1,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt3
ElseIf e.Form.Controls("CheckBox10").checked And e.Form.Controls("CheckBox8").checked Then
Dim bd2 As New SQLcrossTableBuilder("统计表2","动销量") Dim dt2 As fxDataSource bd2.C bd2.HGroups.AddDef("门店") \'添加客户列用于水平分组 bd2.HGroups.AddDef("库位") \'添加客户列用于水平分组 bd2.vGroups.AddDef("调整期间","调整期间_{0}_动销量") \'添加客户列用于水平分组 If e.Form.Controls("CheckBox7").checked Then bd2.VGroups.AddDef("陈列方式") \'添加日期列用于垂直分组,按月分组 End If bd2.Totals.AddDef("动销量") \'添加数量列用于统计 bd2.filter = filter bd2.CommandTimeOut = 600 dt2 = bd2.BuildDataSource()
Dim bd1 As New SQLcrossTableBuilder("统计表1","库位销售分析") Dim dt1 As fxDataSource bd1.C bd1.HGroups.AddDef("门店") \'添加客户列用于水平分组 bd1.HGroups.AddDef("库位") \'添加客户列用于水平分组 bd1.HGroups.AddDef("销售日期",DateGroupEnum.year,"区间") \'添加客户列用于水平分组 bd1.Totals.AddDef("销售数量","销售量") \'添加数量列用于统计 If e.Form.Controls("CheckBox6").checked Then bd1.Totals.AddDef("销售金额","销售额") \'添加数量列用于统计 End If bd1.filter = filter bd1.CommandTimeOut = 600 dt1 = bd1.BuildDataSource()
Dim nms As String() = {"门店","库位"} \'指定连接列 dt1.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt1
ElseIf e.Form.Controls("CheckBox10").checked And e.Form.Controls("CheckBox9").checked Then
.....
ElseIf e.Form.Controls("CheckBox10").checked Then
....
ElseIf e.Form.Controls("CheckBox9").checked Then
....
ElseIf e.Form.Controls("CheckBox8").checked Then
....
不知道有没有更简洁的办法。。。
|
-- 作者:fubblyc
-- 发布时间:2016/7/26 12:04:00
--
红袍老师,组合dt1、dt2、dt3 还是要这样判断对吧,还是说有别的简洁的方法:
Dim nms As String() = {"门店","库位"} \'指定连接列 If e.Form.Controls("CheckBox8").checked And e.Form.Controls("CheckBox9").checked And e.Form.Controls("CheckBox10").checked Then dt3.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据 dt3.Combine(nms,dt1,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt3 ElseIf e.Form.Controls("CheckBox8").checked And e.Form.Controls("CheckBox9").checked Then dt3.Combine(nms,dt2,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt3 ElseIf e.Form.Controls("CheckBox8").checked And e.Form.Controls("CheckBox10").checked Then dt3.Combine(nms,dt1,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt3 ElseIf e.Form.Controls("CheckBox9").checked And e.Form.Controls("CheckBox10").checked Then dt2.Combine(nms,dt1,nms) \'将销售统计数据组合到进货统计数据 Tables(e.Form.Name & "_table1").DataSource = dt2 End If
|