-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMyController.cs
43 lines (42 loc) · 2.17 KB
/
MyController.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.Editors;
using ComplexDialogSample.Module.BusinessObjects;
namespace ComplexDialogSample.Module.Controllers {
public class MyController : ObjectViewController<ListView, Office> {
public MyController() {
PopupWindowShowAction action = new PopupWindowShowAction(this, "AssignJobs", PredefinedCategory.RecordEdit);
action.SelectionDependencyType = SelectionDependencyType.RequireMultipleObjects;
action.CustomizePopupWindowParams += new CustomizePopupWindowParamsEventHandler(action_CustomizePopupWindowParams);
action.Execute += new PopupWindowShowActionExecuteEventHandler(action_Execute);
}
void action_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) {
IObjectSpace os = Application.CreateObjectSpace(typeof(OrderTemplate));
e.Context = TemplateContext.PopupWindow;
var template = os.CreateObject<OrderTemplate>();
e.View = Application.CreateDetailView(os, template);
}
void action_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) {
OrderTemplate parameters = (OrderTemplate)e.PopupWindow.View.CurrentObject;
ListPropertyEditor listPropertyEditor = ((DetailView)e.PopupWindow.View).FindItem("Services") as ListPropertyEditor;
IObjectSpace os = Application.CreateObjectSpace(typeof(Team));
Team team = os.GetObject<Team>(parameters.Team);
foreach (Office b in e.SelectedObjects) {
foreach (Service service in listPropertyEditor.ListView.SelectedObjects) {
Order order = os.CreateObject<Order>();
order.DueDate = parameters.DueDate;
order.Team = team;
order.Office = os.GetObject<Office>(b);
order.Service = os.GetObject<Service>(service);
}
}
os.CommitChanges();
}
}
}