哈,谢谢lsy老师!!lsy老师,麻烦你帮我把那个例子删掉。。。
贴出代码,供有需要的人参考:
VIP月经营门店对比_TreeView1_AfterCheckNode
Forms("等待窗口").open()
Application.DoEvents
Dim s As String = "Year(日期)|Month(日期)|消费门店"
Dim Colstr() As String
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
Dim notchecked As Integer
Dim t As Table
Colstr = s.Split("|")
For Each nd In e.node.allNodes
nd.Checked = False
Next
pd = e.Node.ParentNode
Do While pd IsNot Nothing
pd.Checked = False
pd = pd.ParentNode
Loop
For Each nd In trv.AllNodes
If nd.Checked Then
Dim rts() As String = nd.FullName.Split("\")
Dim vals As String = ""
For i As Integer = 0 To rts.length - 1
If vals > "" Then
vals = vals & " And "
vals = vals & Colstr(i) & " = '" & rts(i) & "'"
Else
vals = vals & Colstr(i) & " = '" & rts(i) & "'"
End If
Next
If flt > "" Then
flt = flt & " Or (" & vals & ")"
Else
flt = vals
End If
notchecked + = 1
End If
Next
'MessageBox.Show("您的查询条件是:" & flt)
Dim rgd As WinForm.RecordGrid = e.Form.Controls("RecordGrid1")
rgd.Table = Nothing '指定绑定表
Dim sql As String
Dim filter As String = flt
sql = "select * from ( Select 消费日期 As 日期, {rjsytVIP消费信息}.消费门店 , SUM(实销金额) As VIP销售额, COUNT(DISTINCT VIP卡号) As VIP销售笔数,SUM(数量) As VIP销售件数, 门店登录账号, 销售主管登录账号 ,客服主管登录账号 ,IT主管登录账号 ,营销总监登录账号 , 总经理登录账号 FROM "
sql+ = "(rjsyt管理层名单 RIGHT JOIN rjsytVIP消费信息 ON {rjsyt管理层名单}.消费门店 = {rjsytVIP消费信息}.消费门店 ) GROUP BY 消费日期, {rjsytVIP消费信息}.消费门店, 门店登录账号 ,销售主管登录账号,客服主管登录账号,IT主管登录账号,营销总监登录账号,总经理登录账号 ) As a where " & Filter & IIF( Filter>"", " and "," " ) & " (门店登录账号='" & User.name & "'" & " Or 销售主管登录账号='" & User.name & "'" & " Or 客服主管登录账号='" & User.name & "'" & " Or IT主管登录账号='" & User.name & "'" & " Or 营销总监登录账号='" & User.name & "'" & " Or 总经理登录账号='" & User.name & "')"
'MessageBox.Show(sql)
'DataTables("VIP月经营门店对比_VIP月经营门店对比").SQLLoad(sql)
Tables("VIP月经营门店对比_VIP月经营门店对比").Fill(sql,"VIP数据", True)
Dim g As New GroupTableBuilder("统计表2",Tables("VIP月经营门店对比_VIP月经营门店对比").DataTable)
g.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g.Groups.AddDef("日期",DateGroupEnum.Month , "月")
g.Groups.AddDef("消费门店")
g.Totals.AddDef("VIP销售额", "" ,"VIP销售额_值")
g.Totals.AddDef("VIP销售笔数", "" ,"VIP销售笔数_值")
g.Totals.AddDef("VIP销售件数", "" ,"VIP销售件数_值")
g.SamePeriodGrowth = True
g.CircleGrowth = True
g.GrandProportion = True
Tables("VIP月经营门店对比_VIP月经营门店对比").DataSource = g.BuildDataSource()
Tables("VIP月经营门店对比_VIP月经营门店对比").DataTable.DataCols.Add("VIP客单价", Gettype(Double), "VIP销售额 / VIP销售笔数")
Tables("VIP月经营门店对比_VIP月经营门店对比").DataTable.DataCols.Add("VIP物单价", Gettype(Double), "VIP销售额 / VIP销售件数")
Tables("VIP月经营门店对比_VIP月经营门店对比").DataTable.DataCols.Add("VIP连带率", Gettype(Double), "VIP销售件数 / VIP销售笔数")
Tables("VIP月经营门店对比_VIP月经营门店对比").Cols("VIP销售额").GrandTotal = True '指定要合计的列
'Tables("VIP月经营门店对比_VIP月经营门店对比").Cols("门店整体销售额").GrandTotal = True '指定要合计的列
Tables("VIP月经营门店对比_VIP月经营门店对比").Cols("VIP销售笔数").GrandTotal = True '指定要合计的列
Tables("VIP月经营门店对比_VIP月经营门店对比").Cols("VIP销售件数").GrandTotal = True '指定要合计的列
Tables("VIP月经营门店对比_VIP月经营门店对比").GrandTotal = True '显示合计模式
rgd.Table = Tables("VIP月经营门店对比_VIP月经营门店对比")
rgd.Build
Forms("等待窗口").close()
[此贴子已经被作者于2014-5-1 17:24:51编辑过]