-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
65 lines (57 loc) · 2.83 KB
/
Form1.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
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.Xpo
Imports Northwind
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpo.DB
Namespace Q205267_4
Public Partial Class Form1
Inherits Form
Public Sub New()
XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString("..\..\nwind.mdb")
' Uncomment this code to create new database
'using (UnitOfWork uow = new UnitOfWork()) {
' uow.ClearDatabase();
' Employees employee = new Employees(uow);
' employee.FirstName = "Thomas";
' employee.Save();
' uow.CommitChanges();
' for (int i = 0; i < 10; i++) {
' for (int j = 0; j < 10000; j++) {
' Orders order = new Orders(uow);
' order.ShipCity = "City";
' order.EmployeeID = employee;
' }
' uow.CommitChanges();
' Console.WriteLine(string.Format("{0} objects already created", i * 10000));
' }
'}
InitializeComponent()
End Sub
Private Sub myGridView1_MasterRowGetChildList(ByVal sender As Object, ByVal e As MasterRowGetChildListEventArgs)
Dim view As GridView = CType(sender, GridView)
Dim employee As Employees = CType(view.GetRow(e.RowHandle), Employees)
Dim source As XPServerCollectionSource = CreateChildServerModeSource(employee)
e.ChildList = CType(source, IListSource).GetList()
End Sub
Private Function CreateChildServerModeSource(ByVal employee As Employees) As XPServerCollectionSource
Dim employeeId As Integer = employee.EmployeeID
Dim op As CriteriaOperator = New BinaryOperator("EmployeeID", employeeId)
Return New XPServerCollectionSource(employee.Session, GetType(Orders), op)
End Function
Private Sub myGridView1_MasterRowEmpty(ByVal sender As Object, ByVal e As MasterRowEmptyEventArgs)
Dim view As GridView = CType(sender, GridView)
Dim employee As Employees = CType(view.GetRow(e.RowHandle), Employees)
Dim source As XPServerCollectionSource = CreateChildServerModeSource(employee)
e.IsEmpty = CType(source, IListSource).GetList().Count = 0
End Sub
Private Sub myGridView1_MasterRowGetRelationCount(ByVal sender As Object, ByVal e As MasterRowGetRelationCountEventArgs)
e.RelationCount = 1
End Sub
Private Sub myGridView1_MasterRowGetRelationName(ByVal sender As Object, ByVal e As MasterRowGetRelationNameEventArgs)
e.RelationName = "Employee_Orders"
End Sub
End Class
End Namespace