Dim cmd As new SQLCommand
cmd.ConnectionName = "数据源名字"
cmd.CommandText = "select '按分组' as 分组, 省, 市, 区县, 乡镇, 街道居委 from {客户分组} where 省 is not null"
cmd.CommandText &= " union select '按等级', 客户等级, null, null, null, null from {客户等级} where 客户等级 is not null"
cmd.CommandText &= " union select '按来源', 来源, null, null, null, null from {等级} where 来源 is not null"
cmd.CommandText &= " union select '按状态', 客户状态, null, null, null, null from {客户状态} where 客户状态 is not null"
Dim dt As DataTable = cmd.ExecuteReader
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "分组|省|市|区县|乡镇|街道居委")
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView2")
trv1.BuildTree(dt, "分组|省|市|区县|乡镇|街道居委")
Dim cmd1 As new SQLCommand
cmd1.ConnectionName = "数据源名字"
cmd1.CommandText = "select '按分组' as 分组, 营业区, 营业部, 营业组 from {成员分组} where 营业区 is not null"
cmd1.CommandText &= " union select '按职级', 职级, null, null, null from {职级} where 职级 is not null"
cmd1.CommandText &= " union select '按来源', 来源, null, null, null from {等级} where 来源 is not null"
cmd1.CommandText &= " union select '按学历', 学历, null, null, null from {学历} where 学历 is not null"
cmd1.CommandText &= " union select '按类型', 成员类型, null, null, null from {成员类型} where 成员类型 is not null"
Dim dt1 As DataTable = cmd1.ExecuteReader
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView3")
trv2.BuildTree(dt1, "分组|营业区|营业部|营业组")