-
Notifications
You must be signed in to change notification settings - Fork 1
/
Northwind.vb
149 lines (136 loc) · 4.21 KB
/
Northwind.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.Xpo
Imports DevExpress.XtraTreeList
Imports System.Collections.Generic
Imports System.Collections
Namespace Northwind
Public Class Categories
Inherits XPVirtualTreeListDataBase
Private fCategoryID As Integer
<Key(True)> _
Public Property CategoryID() As Integer
Get
Return fCategoryID
End Get
Set(ByVal value As Integer)
SetPropertyValue(Of Integer)("CategoryID", fCategoryID, value)
End Set
End Property
Private fCategoryName As String
<Size(15)> _
Public Property CategoryName() As String
Get
Return fCategoryName
End Get
Set(ByVal value As String)
SetPropertyValue(Of String)("CategoryName", fCategoryName, value)
End Set
End Property
<Association("Category-Products", GetType(Products))> _
Public ReadOnly Property Products() As XPCollection(Of Products)
Get
Return GetCollection(Of Products)("Products")
End Get
End Property
Protected Overrides ReadOnly Property ChildrenCollectionName() As String
Get
Return "Products"
End Get
End Property
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Sub New()
Me.New(Session.DefaultSession)
End Sub
End Class
Public Class Products
Inherits XPVirtualTreeListDataBase
Private fProductID As Integer
<Key(True)> _
Public Property ProductID() As Integer
Get
Return fProductID
End Get
Set(ByVal value As Integer)
SetPropertyValue(Of Integer)("ProductID", fProductID, value)
End Set
End Property
Private fProductName As String
<Size(40)> _
Public Property ProductName() As String
Get
Return fProductName
End Get
Set(ByVal value As String)
SetPropertyValue(Of String)("ProductName", fProductName, value)
End Set
End Property
Private fCategoryID As Categories
<Association("Category-Products")> _
Public Property CategoryID() As Categories
Get
Return fCategoryID
End Get
Set(ByVal value As Categories)
SetPropertyValue(Of Categories)("CategoryID", fCategoryID, value)
End Set
End Property
Public Sub New(ByVal session As Session)
MyBase.New(session)
fieldMap.Add("CategoryName", "ProductName")
End Sub
Public Sub New()
Me.New(Session.DefaultSession)
End Sub
End Class
<NonPersistent> _
Public Class XPVirtualTreeListDataBase
Inherits XPLiteObject
Implements TreeList.IVirtualTreeListData
Protected childrenCore As XPCollection
Protected fieldMap As New Dictionary(Of String, String)()
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Protected Overridable ReadOnly Property ChildrenCollectionName() As String
Get
Return String.Empty
End Get
End Property
Private Function GetTreeListDataFieldName(ByVal fieldName As String) As String
If fieldMap.ContainsKey(fieldName) Then
Return fieldMap(fieldName)
Else
Return fieldName
End If
End Function
Public Sub SetChildren(ByVal children As XPCollection)
childrenCore = children
End Sub
#Region "IVirtualTreeListData Members"
Public Sub VirtualTreeGetCellValue(ByVal info As VirtualTreeGetCellValueInfo) _
Implements TreeList.IVirtualTreeListData.VirtualTreeGetCellValue
Dim fieldName As String = GetTreeListDataFieldName(info.Column.FieldName)
info.CellData = ClassInfo.GetMember(fieldName).GetValue(Me)
End Sub
Public Sub VirtualTreeGetChildNodes(ByVal info As VirtualTreeGetChildNodesInfo) _
Implements TreeList.IVirtualTreeListData.VirtualTreeGetChildNodes
If String.IsNullOrEmpty(ChildrenCollectionName) Then
info.Children = childrenCore
Else
info.Children = CType(ClassInfo.GetMember(ChildrenCollectionName).GetValue(Me), IList)
End If
End Sub
Public Sub VirtualTreeSetCellValue(ByVal info As VirtualTreeSetCellValueInfo) _
Implements TreeList.IVirtualTreeListData.VirtualTreeSetCellValue
Dim fieldName As String = GetTreeListDataFieldName(info.Column.FieldName)
ClassInfo.GetMember(fieldName).SetValue(Me, info.NewCellData)
End Sub
#End Region
End Class
End Namespace