Navigation bar
  Print document Start Previous page
 20 of 30 
Next page End  

Gravitybox Schedule.NET User’s Guide
Page 18 
1998-2004 Gravitybox Software LLC
appointments in the database by calling the “FillAppointments” method with no
parameters. You could optionally send two date parameters to load only appointments
in a date range.
private void Form1_Load(object sender, System.EventArgs e)
{
    webServiceController1.WebServiceURL = 
    webServiceController1.FillAppointments();
}
Note:
The address in the example above is set in code and compiled into the application. It is
not changeable at run-time. This is obviously a very simple scenario. You can build a
setup screen to allow the user to specify the server at run-time. Or you can read the
connection information from a configuration file. To keep this example simple, the URL
is compiled into the application.
When the “FillAppointments” method is called is returns nothing. It does however start
an asynchronous action that loads the appointments from the server. When completed it
raises the “DataUpdated” event on the WebServiceController. This is the way in which
the controller informs its container that the load is complete. You then set the schedule
datasource to the newly loaded controller datasource. This code snippet will cause the
schedule to refresh itself with the new data.
private void webServiceController1_DataUpdated(object sender, 
  System.EventArgs e)
{
    schedule1.DataSource = webServiceController1.DataSource;
}
Data saving is not automatic because the user could make many changes and cause
updates to be done several times a second at times. This is not an acceptable refresh
rate. To combat this issue the schedule must be saved manually. In this example, there
is a save button, but you may add a menu or a timer or some other mechanism for
saving information. When the save button is pressed the controller method
“UpdateData” is called. This sends the schedule’s datasource to the server to update
the database. This is a synchronous call and will not return until the save is complete.
After this method call, the “FillAppointments” method is called again. This is an optional
call. If more than one user is accessing the database then it might have changed since
the last load. Reloading the appointments ensures that the client now has the most
recent copy of the appointment set in the database. Also notice that the form’s caption
is changed. After the reload, the schedule is fresh with no modifications. The caption is
changed to reflect this state.
private void cmdSave_Click(object sender, System.EventArgs e)
{
    webServiceController1.UpdateData();
    webServiceController1.FillAppointments();
http://www.purepage.com