2013-08-30 45 views
0

使用WPF我想有一個從數據庫壓縮可變數據顯示一個TreeView。這意味着我想根據用戶的喜好來對視圖進行排序。如何動態設置的TreeView

假設數據庫具有以下表和模式,我該怎麼設置我的看法?正如我所說的,它們應該是可變的,但如果可能的話,我會考慮多個HierarchialDataTemplates。下面列出了一些可能的想法。

感謝您提供的任何幫助!

Employee 
ID - Int primary Unique AutoIncrement 
Name – string 
Department - int (foreign relation to Department. ID) 
Supervisor - int (ID of Employee in this table) 

Division 
ID - Int primary Unique AutoIncrement 
Name – Unique string 
DivisionLeader - int (foreign relation to Employee. ID) 

Department 
ID - Int primary Unique AutoIncrement 
Name – Unique string 
DepartmentLeader - int (foreign relation to Employee. ID) 
Division – int (foreign relation to Division. ID) 

CustomerSupportDepartments 
ID - Int primary Unique AutoIncrement 
Name – string 
Department - int (foreign relation to Department. ID) 
Continent - int (foreign relation to Continent. ID) 
Country - int (foreign relation to Country. ID) 
State - int (foreign relation to State. ID) 
City - int (foreign relation to City. ID) 

Customer 
ID - Int primary Unique AutoIncrement 
Name – string 
SalesRep - (foreign relation to Employee. ID) 
Revenue . int 
Continent - int (foreign relation to Continent. ID) 
Country - int (foreign relation to Country. ID) 
State - int (foreign relation to State. ID) 
City - int (foreign relation to City. ID) 

Continent 
ID - Int primary Unique AutoIncrement 
Name – Unique string 

Country 
ID - Int primary Unique AutoIncrement 
Name – Unique string 

State 
ID - Int primary Unique AutoIncrement 
Name – Unique string 

City 
ID - Int primary Unique AutoIncrement 
Name – Unique string 

潛力查看

View 1 
Employees 
    Employee Name 1 
     Supervisor 
      Name 
     Department 
      Name 
     Customers 
      Name 1 
      Name 2 
      Name 3 
    Employee Name 2 
     Supervisor 
      Name 
     Department 
      Name 
     Customers 
      Name 1 
      Name 2 
      Name 3 
    View 2 
    Departments 
     Department Name 1 
      Division 
       Name 
      Supervisor 
       Name 
      Employees 
       Employee Name 1 
       Employee Name 2 
     Department Name 2 
      Division 
       Name 
      Supervisor 
       Name 
      Employees 
       Employee Name 1 
       Employee Name 2 


View 3 
Divisions 
    Division Name 1 
     Departments 
      Department Name 1 
      Department Name 2 
    Division Name 2 
     Departments 
      Department Name 1 
      Department Name 2 

View 4 
Continents 
    Continent Name 1 
     Country Name 1 
      City Name 1 
       Customers 
        Customer Name 1 
        Sales Representative 
         Employee Name 
        Revenue 
         Sum 
        Customer Name 2 
        Sales Representative 
         Employee Name 
        Revenue 
         Sum 
     Country Name 2 
      City Name 1 
       Customers 
        Customer Name 1 
        Sales Representative 
         Employee Name 1 
        Revenue 
         Sum 
      City Name 2 
       Customers 
        Customer Name 1 
        Sales Representative 
         Employee Name 1 
        Revenue 
         Sum 
        Customer Name 2 
        Sales Representative 
         Employee Name 
        Revenue 
         Sum 

View 5 
Customers 
    Customer Name 1 
     Sales Representative 
      Employee Name 
     Sales Representative’s Supervisor 
      Employee Name 
     Location 
      Continent 
      Country 
      State 
      City 
     Revenue 
      Sum 
    Customer Name 2 
     Sales Representative 
      Employee Name 
     Sales Representative’s Supervisor 
      Employee Name 
     Location 
      Continent 
      Country 
      State 
      City 
     Revenue 
      Sum 

回答

0

我結束了使用通用對象。