'统计各员工销量
Dim st As new InlineGroupTableBuilder("统计表1")
st.DataTable = DataTables("销售A")
st.ParentCol = "上级"
st.ChildCol = "员工"
st.GridTree = True '一定要开启折叠模式
st.AddTotal("数量","销量", 0)
st.Build()
'增加一个提成列, 并计算出每个员工的直接销售提成
DataTables("统计表1").DataCols.Add("提成", Gettype(Double))
DataTables("统计表1").DataCols("提成").SetFormat("0.00") '提成列保留两位小数
Dim tbl As Table = Tables("统计表1")
For n As Integer = 0 To tbl.Rows.Count - 1
tbl.Rows(n)("提成") = tbl.Rows(n)("销量") * 8
Next
For n As Integer = 0 To tbl.Rows.Count - 1
Dim pr As Row = tbl.Rows(n) '上级行
Dim pHierarchy As Integer = pr.Hierarchy '上级 行的层级
For m As Integer = n + 1 To tbl.Rows.Count - 1 '从 上级行的下一行位置开始遍历,找出全部下级行
Dim cr As Row = tbl.Rows(m)
Dim cHierarchy As Integer = cr.Hierarchy '下级行层级
If cr.Hierarchy <= pHierarchy Then '如果并非下级行,则终止遍历。
Exit For
End If
Dim deduct As Double = cr("销量") * 8 * 0.2 / 2 ^ (cHierarchy - pHierarchy - 1) '计算扣除额
cr("提成") = cr("提成") - deduct '从下级行减去扣除额
pr("提成") = pr("提成") + deduct '将扣除额加到本行中
Next
Next
MainTable = Tables("统计表1")
上面红字代码改为下面,提成没计算出来,也没分级显示,如何解决?
Tables("窗口1_Table1").DataSource = st.BuildDataSource()