Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Use RadScheduler for Windows Forms with OpenAccess
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Integration and Installation > How to: Use RadScheduler for Windows Forms with OpenAccess

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

This task is going to guide you on using OpenAccess for accessing data with the RadScheduler windows forms control. Before reading this article refer to the general use of data providers for RadScheduler in the following documentation topic.

Having a sample models for the RadScheduler like the one in the following diagram there are few steps that should be accomplished before using the scheduler interactively in a windows forms application.

1.    Drag an “ObjectProvider” component called “ObjectProviderAppointments” from the toolbox and configure it so that it provides representation for the “MyAppointment” objects in the application.

2.    Add an “ObjectView” called “ObjectViewAppointments” which has its “ObjectProvider” property set to the object provider created in the previous step and the root type to the MyAppointment persistent class.

3.    Do steps 1 and 2 for the MyResource persistent class which represents the resources used in an appointment - create “ObjectProviderResources” and “ObjectViewResources”.

4.    Set the property UsePrivateObjectContext of both object providers to false. You can do that in the design time by un-checking the “Use private Object Context” checkbox. That way both object providers will use the same instance of an object scope to manipulate their data. The reason for that is to be able to interact between objects from both providers e.g. an appointment from “ObjectProviderAppointments” uses resource from “ObjectViewResources”.

5.    Drag a RadScheduler from the Visual Studio toolbox on the form.

6.    In the code-behind we should write the following method that binds the RadScheduler to use our object views as datasources for the appointments and resources.

C# Copy Code
private void BindToOpenAccessObjects()

   SchedulerBindingDataSource dataSource =
new SchedulerBindingDataSource();
   AppointmentMappingInfo appointmentMappingInfo =
new AppointmentMappingInfo();
   appointmentMappingInfo.Start =
   appointmentMappingInfo.End =
   appointmentMappingInfo.Summary =
   appointmentMappingInfo.Description =
   appointmentMappingInfo.Location =
   appointmentMappingInfo.Resources =
   appointmentMappingInfo.ResourceId =
   dataSource.EventProvider.Mapping = appointmentMappingInfo;
   dataSource.EventProvider.DataSource =

   ResourceMappingInfo resourceMappingInfo =
new ResourceMappingInfo();
   resourceMappingInfo.Id =
   resourceMappingInfo.Name =
   dataSource.ResourceProvider.Mapping = resourceMappingInfo;
   dataSource.ResourceProvider.DataSource =
this.radScheduler1.DataSource = dataSource;

VB .NET Copy Code
Private Sub BindToOpenAccessObjects()
 Dim dataSource As New SchedulerBindingDataSource()
 Dim appointmentMappingInfo As New AppointmentMappingInfo()
 appointmentMappingInfo.Start = "Start"
 appointmentMappingInfo.End = "End"
 appointmentMappingInfo.Summary = "Subject"
 appointmentMappingInfo.Description = "Description"
 appointmentMappingInfo.Location = "Location"
 appointmentMappingInfo.Resources = "Resources"
 appointmentMappingInfo.ResourceId = "Id"
 dataSource.EventProvider.Mapping = appointmentMappingInfo
 dataSource.EventProvider.DataSource = Me.objectViewAppointments
 Dim resourceMappingInfo As New ResourceMappingInfo()
 resourceMappingInfo.Id = "Id"
 resourceMappingInfo.Name = "Name"
 dataSource.ResourceProvider.Mapping = resourceMappingInfo
 dataSource.ResourceProvider.DataSource = Me.objectViewResources
 Me.radScheduler1.DataSource = dataSource
End Sub
We should call this method after the initialization of the form.
C# Copy Code
public Form1()
VB .NET Copy Code
Public Function Form1()
End Function

The only thing that is left is a button that saves all the changes done in the RadScheduler on its click event.

C# Copy Code
private void btnSave_Click(object sender, EventArgs e)
VB .NET Copy Code
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub