This is a migrated thread and some comments may be shown as answers.

Event for saving an EXISTING appointment

1 Answer 116 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 30 Oct 2013, 11:46 PM
On the save of the appointment I need to differentiate between the save of new appointment vs. an existing appointment.

I am aware that the save of a new appointment triggers the following event:

this.radSchedulerControl.AppointmentAdded += new EventHandler<AppointmentAddedEventArgs>(radSchedulerControl_AppointmentAdded);

 



And the save of the existing event triggers the following event with the action of the event = "ItemChanged"

this.radSchedulerControl.Appointments.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(Appointments_CollectionChanged);
....however the problem with this event is that it get triggered multiple times based on what was changed for on the existing appointment.

A different thread suggested using the ApplySettingsToEvent function in the CustomAppointmentEditDialog class when saving an appointment to add my custom logic. However, in ApplySettingsToEvent I could not determine how to differentiate when a new Appointment is created vs an existing one is saved since this function gets executed on both the creation of a new appointment and the save of an existing.

Your help in determining how to execute custom logic only on the save of an existing appointment and have it triggered only once would be appreciated.

Thanks!
Vijay

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Nov 2013, 04:36 PM
Hello Vijay,

Thank you for contacting Telerik Support.

You can distinguish whether you have updated an existing appointment or created a new one using the following code snippet:
public Form1()
{
    InitializeComponent();
  
    for (int i = 0; i < 10; i++)
    {
        Appointment appointment = new Appointment(DateTime.Now.AddDays(i), TimeSpan.FromMinutes(30), "Summary", "Description");
        appointment.StatusId = 2;
        appointment.BackgroundId = 6;
        this.radScheduler1.Appointments.Add(appointment);
    }
  
    this.radScheduler1.AppointmentEditDialogShowing += radScheduler1_AppointmentEditDialogShowing;
}
  
private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
{
    e.AppointmentEditDialog = new CustomEditAppointmentDialog();
}
  
public class CustomEditAppointmentDialog : EditAppointmentDialog
{
    protected override void ApplySettingsToEvent(IEvent targetEvent)
    {
        RadScheduler scheduler = this.SchedulerData as RadScheduler;
        if (scheduler != null)
        {
            bool isEditedEvent = false; //true->edited an existing appointment; false->created a new appoitment
            if (targetEvent.MasterEvent == null)
            {
                isEditedEvent = scheduler.Appointments.Contains(targetEvent);
            }
            else
            {
                isEditedEvent = scheduler.Appointments.Contains(targetEvent.MasterEvent);
            }
        }
        base.ApplySettingsToEvent(targetEvent);
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Scheduler and Reminder
Asked by
Vijay
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or