此主题相关图片如下:微信截图_20160726163137.png
如何才能让统计后的计算的列标题也可以合并。主要是中间的调整时间是动态的,没法:.Add("调整期间_{0}_销售折扣",
也不能直接在统计的时候计算,因为有的行没有销售金额,只有吊牌金额。
代码如下:
If e.Form.Controls("CheckBox12").checked Then
Dim bd5 As New SQLcrossTableBuilder("统计表1","库位销售分析")
bd5.C
bd5.HGroups.AddDef("门店") '添加客户列用于水平分组
bd5.HGroups.AddDef("库位") '添加客户列用于水平分组
bd5.HGroups.AddDef("销售日期",DateGroupEnum.year,"区间2") '添加客户列用于水平分组
bd5.vGroups.AddDef("调整期间","调整期间_{0}") '添加客户列用于水平分组
bd5.Totals.AddDef("销售金额") '添加数量列用于统计
bd5.Totals.AddDef("吊牌金额"") '添加数量列用于统计
bd5.filter = filter
bd5.CommandTimeOut = 600
dt5 = bd5.BuildDataSource()
End If
Dim ls As new List(of String)
ls.add("门店")
ls.add("库位")
For Each c As Object In e.Form.controls("groupbox3").children
If c.checked Then
ls.add(c.text)
End If
Next
Dim nms As String() = ls.ToArray
Dim dts() As fxDataSource = {dt3,dt2,dt1,dt4,dt5}
Dim pdt As fxDataSource = Nothing
For Each dt As object In dts
If pdt Is Nothing AndAlso dt IsNot Nothing Then
pdt = dt
Else
If pdt IsNot Nothing AndAlso dt IsNot Nothing Then
pdt.Combine(nms,dt,nms)
End If
End If
Next
Tables(e.Form.Name & "_table1").DataSource = pdt
For Each dc As DataCol In DataTables(e.Form.Name & "_table1").DataCols
messagebox.show(dc.name)
Next
If Tables(e.Form.Name & "_table1").Cols.Contains("区间") Then
Tables(e.Form.Name & "_table1").Cols.Remove("区间")
End If
If Tables(e.Form.Name & "_table1").Cols.Contains("区间1") Then
Tables(e.Form.Name & "_table1").Cols.Remove("区间1")
End If
If Tables(e.Form.Name & "_table1").Cols.Contains("区间2") Then
Tables(e.Form.Name & "_table1").Cols.Remove("区间2")
With DataTables(e.Form.Name & "_table1").DataCols '用表达式列计算库存数据
.Add("销售折扣",Gettype(Double), "销售金额_1 / 吊牌金额_1")
Tables(e.Form.Name & "_table1").Cols.Remove("销售金额_1")
Tables(e.Form.Name & "_table1").Cols.Remove("吊牌金额_1")
End With
End If
[此贴子已经被作者于2016/7/26 16:38:06编辑过]