Version

Add an Activity to the Database

In server-side code behind you can add a new Activity to the Activity table in the database for persistence. This example makes use of the How to Create an Activity in Code topic. You will need three things to add an Activity to the database:

  1. A concrete instance of an Activity (for example, an Appointment object.)

  2. The Resource (person or thing) this Activity is owned by, organized by, or pertains to.

  3. A data provider derived from the WebScheduleDbProvider class.

Add an ASP.NET Button to your WebForm named "AddButton1", and handle it’s Click event to make a new Appointment object.

Pass this along with the Unassigned Resource (or other associated Resource) to the AddActivity method on the data provider.

In Visual Basic:

Imports Infragistics.WebUI.Shared
Imports Infragistics.WebUI.WebSchedule
...
Private Sub AddButton1_Click(ByVal sender As Object, _
	ByVal e As EventArgs) Handles AddButton1.Click
	' Create the Appointment object.
	Dim appt As Appointment = Me.CreateAppointment()
	' Add the Appointment to the database, associating
	' it with the Unassigned Resource.
	Me.WebScheduleSqlClientDataProvider1.AddActivity( _
	   appt, _
	   Me.WebScheduleInfo1.VisibleResources.UnassignedResource)
End Sub

In C#:

using Infragistics.WebUI.Shared;
using Infragistics.WebUI.WebSchedule;
...
private void AddButton1_Click(object sender, EventArgs e)
{
	// Create the Appointment object.
	Appointment appt = this.CreateAppointment();
	// Add the Appointment to the database, associating
	// it with the Unassigned Resource.
	this.WebScheduleSqlClientDataProvider1.AddActivity(
	   appt,
	   this.WebScheduleInfo1.VisibleResources.UnassignedResource);
}
Note
Note:

Although this example shows the Microsoft SQL Server data provider being used, this works with any data provider derived from WebScheduleDbProvider including OLE DB.