Xtrascheduler Binding to Data

XtraScheduler – Binding to Data

The purpose of this lesson is to show you how to bind XtraScheduler to data.

We’ll start from the simple application we created in Lesson 1.

1.  First, we need to create a data source and bind it to the scheduler.

2.  We’ll use the already present SchedulerStorage control, since it stores all data for appointments and resources.

3.  Expanding the Appointments property branch, I click the DataSource item…

4.  …and then the Add Project Data Source link to start the data source configuration wizard.

5.  The first step is to choose the data type, which is “Database” in our case.

6.  I’ll proceed to the connection string configuration to create a new connection.

7.  All I have to do is locate the desired MDB file on the disk.

8.  I am asked whether the database should be copied and added to the project. The answer is “No”.

9.  Then, I shall choose the data tables that will supply the data, and click “Finish”.

10.  Since I need data for the appointments, I select the CarScheduling table.

11.  The “Setup Appointment Storage” window pops up.

12.  The wizard has automatically mapped the standard appointment properties to the data fields. Make sure to check this manually, since incorrect mappings will cause problems later.
XtraScheduler Setup Appointment Storage jpg

13.  And now I will manage the “Resources” storage section . . . assigning the data source and mapping the fields.

14.  Pay attention to the new components, which were created automatically after the data source creation and assignment.

15.  Let’s look at the CarsDBDataSet control. I select it in the tray and click the “Edit in DataSet Designer…” task.

16.  This is a place where you can edit relations and change the queries used to obtain the data.

17.  I do not have to write the code to populate the controls with data at run time. The Studio designer has already done it.

18.  Since my appointments belong to July of 2008, I must set the Start date for the scheduler accordingly, so that I can view them straightway, when the application runs.

19.  I can change the ActiveView to “Week” to display more appointments at a time.

20.  If I run the project now, the changes will be saved in the DataTable objects, but not in the database.

21.  I have to write some code myself for posting the data back to the database. The SchedulerStorage events should be handled for this purpose.

22.  When changes occur, I must resolve them back to the data source and accept the changes by my DataSet.
CODE:
carSchedulingTableAdapter.Update(carsDBDataSet);
carsDBDataSet.AcceptChanges();

23.  I can assign the same procedure to handle events when appointments are deleted or inserted.

24.  Now, I’m done with customization.

25.  A Scheduler, bound to the database.