Question

Using WPF I would like to have a TreeView that displays data from a Compact Database variably. That means I would like to change the view based on how the user would like it sorted.

Assuming that the database has the following tables and schema, how can I set up my views? As I said, they should be variable, but I would consider multiple HierarchialDataTemplates if that is possible. A few potential views that come to mind are listed below.

Thanks for any help offered!

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

Potential Views

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
Was it helpful?

Solution

I wound up using a generic object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top