|
Client Controller
The client controller is a component that is used to coordinate a Schedule.NET control
to the backend enterprise server. It is a non-visual, Windows component that sits
on a form and shuttles data between a bound schedule and a Gravitybox Enterprise
Server.
The controller is very simple to use. You need only specify a valid web service
URL for it to be configured properly. To begin, drag a ScheduleController object
from the toolbox and drop it on a form with a Schedule control. Then create an event
handler for the ScheduleController’s DataUpdated event. In the event set the schedule's
Datasource property to the ScheduleController Datasource property. This will reset
and repaint the schedule each time that the controller's data changes.
To get an appointment dataset from the server after you properly setup the controller,
call its "FillAppointments" method. This will query the enterprise server
for appointments. The controller's "DataUpdated" event will be raised
when the operation is complete. If you set the schedule's Datasource property to
the new Datasource of the controller as described above then the schedule will reload
it self automatically.
When you wish to save the changes of a schedule that is bound to a controller,
call the controller's UpdateData method. This will send the schedule's underlying
dataset (its Datasource) to the server for database updating.
The code snippet below shows the form load event setting controller WebServerURL
property. This creates a connection to a Gravitybox Enterprise Server. Also an event
handler is created for the controller's "DataUpdated" event. This handler
resets the schedule's data, which in turn repaints the schedule. Finally a method
named "Reload" is created that would be called anytime you need
to save a changed schedule. You might call this method from a save button to allow
the user to commit changes to the database.
Alternatively if you wish a schedule to update the database automatically whenever
there is a changed you may use the schedule's DataSourceChanged event to save changes.
This event is raised when there is any change to the schedule. This might have the
disadvantage of creating more network traffic since any schedule changes will raise
this event. However it does provide you a way to add update functionality that is
guaranteed to update all changes with very minimal code. This event is triggered
by, but not limited to, the following actions: add, move, copy, delete, edit, inplace-edit.
|
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
ScheduleController1.WebServiceURL = _
"http://localhost/GravityboxWebServices/EnterpriseService.asmx"
End Sub
Private Sub ScheduleController1_DataUpdated( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ScheduleController1.DataUpdated
Schedule1.Datasource = ScheduleController1.Datasource
End Sub
Private Sub Reload()
'Save the current appointments
ScheduleController1.UpdateData()
'Reload appointments from database
ScheduleController1.FillAppointments( _
Schedule1.MinDate, Schedule1.MaxDate)
End Sub
|
|
|