AppointmentUpdate
The AppointmentUpdate event occurs just before the scheduler calls its data source to update an appointment.
AppointmentUpdate has two parameters:
-
sender is the scheduler control.
-
e is an object of type AppointmentUpdateEventArgs. It has three properties:
-
Appointment is the original appointment before any updates. Any modifications you make to this object are discarded.
-
ModifiedAppointment is the updated appointment that is about to be written to the data source. You can modify the updated appointment to change the way the updates are written to the data source.
-
Cancel is a boolean value that lets you prevent the update.
Example
protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
{
e.ModifiedAppointment.End = e.ModifiedAppointment.End.AddHours(1);
}
Getting recurrence rule when a recurring appointment is dragged or resized
It is a known issue that occurs in cases when a recurring Appointment is dragged or resized the recurrence rule of the ModifiedAppointment is not updated properly. It can be generated correctly by using the following code:
protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
{
RecurrenceRule rrule;
if (RecurrenceRule.TryParse(e.ModifiedAppointment.RecurrenceRule, out rrule))
{
rrule.Range.Start = e.ModifiedAppointment.Start;
rrule.Range.EventDuration = e.ModifiedAppointment.End - e.ModifiedAppointment.Start;
TimeSpan startTimeChange = e.ModifiedAppointment.Start - e.Appointment.Start;
for (int i = 0; i < rrule.Exceptions.Count; i++)
{
rrule.Exceptions[i] = rrule.Exceptions[i].Add(startTimeChange);
}
e.ModifiedAppointment.RecurrenceRule = rrule.ToString();
}
//here goes your custom logic for the appointment update event handler
}