Skip to main content Skip to footer

Avoid Overlapping Appointments in C1Schedule for Silverlight

C1Schedule for Silverlight comes with loads of features and UI customization options for its users. However, at times customers may have such requirements which are very user specific and even the best of the controls (C1Schedule) does not support that. Recently, I came across a requirement where customer wanted to avoid adding any overlapping Appointments. Now from the first look it appeared quite a simple task to achieve. However, when I started implementing it, I realized it requires brainstorming more than I thought. In this blog implementation, I make an effort to provide a small headstart for the users who may have the similar kind of requirement. Basic logic in this implementation checks the Time Interval for which the new appointment would be added. It loops through all the appointments and verify if any of these appointments already cover the time interval of the new appointment. If so, cancel the addition of the new appointment. Before we begin, there are few other points that need to be taken into consideration. For ex. a Recurring Appointment is registered only once in the AppointmentStorage collection as Master Appointment for the first day. However, since no specific appointment object is added for the next recurring periods, above logic will fail. So we have to modify our logic. While looping, for every recurring appointment, calculate all the recurring child appointments and check if any of them clashes with the new appointment. Again if any of them does, cancel the new appointment. Similar kind of considerations have to be done for All Day Appointments which span the whole day or for those appointments which span multiple days. Once we have covered all the possible points, start coding the implementation in the BeforeAppointmentSave event. This event block handles the complete code and provides the option as event argument to cancel the appointment by setting the e.handled property to True. As the code snippet is long, please download the attached sample for complete implementation. Download Sample Before I end this blog, I would like to mention again that this implementation is just a suggestive solution. You may have to modify this further as per your application requirements or any other case scenarios.


comments powered by Disqus