This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
60 lines (52 loc) · 2.61 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
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.Objects
Namespace BindSchedulerToEF
Partial Public Class Form1
Inherits Form
Private entities As CarsDBEntities
Public Sub New()
InitializeComponent()
SubscribeToEvents()
SetupMappings()
entities = New CarsDBEntities()
schedulerStorage1.Appointments.DataSource = entities.CarSchedulings
schedulerStorage1.Resources.DataSource = entities.Cars
End Sub
Private Sub SubscribeToEvents()
AddHandler Me.schedulerStorage1.AppointmentsInserted, AddressOf Me.schedulerStorage1_AppointmentsModified
AddHandler Me.schedulerStorage1.AppointmentsChanged, AddressOf Me.schedulerStorage1_AppointmentsModified
AddHandler Me.schedulerStorage1.AppointmentsDeleted, AddressOf Me.schedulerStorage1_AppointmentsModified
End Sub
Private Sub SetupMappings()
' appointment mappings
Me.schedulerStorage1.Appointments.Mappings.AllDay = "AllDay"
Me.schedulerStorage1.Appointments.Mappings.AppointmentId = "ID"
Me.schedulerStorage1.Appointments.Mappings.Description = "Description"
Me.schedulerStorage1.Appointments.Mappings.End = "EndTime"
Me.schedulerStorage1.Appointments.Mappings.Label = "Label"
Me.schedulerStorage1.Appointments.Mappings.Location = "Location"
Me.schedulerStorage1.Appointments.Mappings.RecurrenceInfo = "RecurrenceInfo"
Me.schedulerStorage1.Appointments.Mappings.ReminderInfo = "ReminderInfo"
Me.schedulerStorage1.Appointments.Mappings.ResourceId = "CarId"
Me.schedulerStorage1.Appointments.Mappings.Start = "StartTime"
Me.schedulerStorage1.Appointments.Mappings.Status = "Status"
Me.schedulerStorage1.Appointments.Mappings.Subject = "Subject"
Me.schedulerStorage1.Appointments.Mappings.Type = "EventType"
' resource mappings
Me.schedulerStorage1.Resources.Mappings.Caption = "Model"
Me.schedulerStorage1.Resources.Mappings.Id = "ID"
Me.schedulerStorage1.Resources.Mappings.Image = "Picture"
End Sub
Private Sub schedulerStorage1_AppointmentsModified(ByVal sender As Object, ByVal e As DevExpress.XtraScheduler.PersistentObjectsEventArgs)
entities.SaveChanges()
entities.AcceptAllChanges()
End Sub
End Class
End Namespace