-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.cs
68 lines (57 loc) · 3.2 KB
/
Form1.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
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
using DevExpress.Xpo;
using DevExpress.XtraScheduler;
using System.Windows.Forms;
namespace XPO_MultiResource_Example {
public partial class Form1 : Form {
string[] resourceNames = { "Andrew Fuller", "Nancy Davolio", "Janet Leverling", "Margaret Peacock" };
string[] resourceColors = { "Cornsilk", "Lavender", "PaleGreen", "0xFF8E4585" };
public Form1() {
InitializeComponent();
session1.ConnectionString = DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("XPO_MultiResource_Example.mdb");
schedulerStorage1.Appointments.DataSource = xpCollectionAppointments;
schedulerStorage1.Resources.DataSource = xpCollectionResources;
CreateMappings();
InitResources();
this.schedulerStorage1.AppointmentsChanged += schedulerStorage1_AppointmentsChanged;
this.schedulerStorage1.AppointmentsInserted += schedulerStorage1_AppointmentsChanged;
this.schedulerStorage1.Appointments.ResourceSharing = true;
this.schedulerControl1.Views.DayView.GroupType = SchedulerGroupType.Resource;
}
private void CreateMappings() {
this.schedulerStorage1.Appointments.Mappings.AllDay = "AllDay";
this.schedulerStorage1.Appointments.Mappings.Description = "Description";
this.schedulerStorage1.Appointments.Mappings.End = "Finish";
this.schedulerStorage1.Appointments.Mappings.Label = "Label";
this.schedulerStorage1.Appointments.Mappings.Location = "Location";
this.schedulerStorage1.Appointments.Mappings.RecurrenceInfo = "Recurrence";
this.schedulerStorage1.Appointments.Mappings.ReminderInfo = "Reminder";
this.schedulerStorage1.Appointments.Mappings.ResourceId = "ResourceIds";
this.schedulerStorage1.Appointments.Mappings.Start = "Created";
this.schedulerStorage1.Appointments.Mappings.Status = "Status";
this.schedulerStorage1.Appointments.Mappings.Subject = "Subject";
this.schedulerStorage1.Appointments.Mappings.Type = "AppointmentType";
this.schedulerStorage1.Resources.Mappings.Caption = "Name";
this.schedulerStorage1.Resources.Mappings.Color = "Color";
this.schedulerStorage1.Resources.Mappings.Id = "ResId";
this.schedulerStorage1.Resources.Mappings.Image = "Image";
}
private void InitResources() {
if (xpCollectionResources.Count <= 0) {
for (int i = 0; i < resourceNames.Length; i++) {
Resource res = schedulerStorage1.Resources.CreateResource(i);
res.Caption = resourceNames[i];
res.ColorValue = resourceColors[i];
schedulerStorage1.Resources.Add(res);
}
session1.Save(xpCollectionResources);
}
}
void schedulerStorage1_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) {
foreach (Appointment apt in e.Objects) {
XPBaseObject o = apt.GetSourceObject(schedulerStorage1) as XPBaseObject;
if (o != null)
o.Save();
}
}
}
}