We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Conflicting appointments

Hi,

How do we check conflicting appointment in a schedule, while adding appointment to the schedule?

Please provide a sample application, that implements the above requirement.


Regards,

Mohit Saxena

3 Replies

MG Mohanraj Gunasekaran Syncfusion Team July 27, 2017 11:05 AM UTC

Hi Mohit,   
  
Thanks for using Syncfusion product.   
  
To find the conflicting appointment, we can use the GetSchedule method, to get the list of appointment in that specified date and use the ItemChanging event to handle an appointment. Please refer to the code example and a sample,   
  
Code example   
this.scheduleControl1.ItemChanging += scheduleControl1_ItemChanging;   
   
void scheduleControl1_ItemChanging(object sender,ScheduleAppointmentCancelEventArgs e)   
{   
    if (e.Action == ItemAction.Add)   
    {   
        bool isConflict = false;   
        SimpleScheduleDataProvider provider = this.scheduleControl1.DataSource asSimpleScheduleDataProvider;   
        IScheduleAppointmentList list = provider.GetSchedule(e.ProposedItem.StartTime, e.ProposedItem.EndTime);   
        if (list is ScheduleAppointmentList)   
        {   
            ScheduleAppointmentList applist = list as ScheduleAppointmentList;   
                       
            foreach (IScheduleAppointment item in applist)   
            {   
                           
                if (item.StartTime <= e.ProposedItem.EndTime && e.ProposedItem.StartTime <= item.EndTime)   
                {   
                    isConflict = true;   
                }   
            }   
   
            if (isConflict)   
            {   
                //Handle the appointments.   
                e.Cancel = true;   
             }   
        }   
   
    }      
}   
   
Sample link: ScheduleControl   
   
Regards,   
Mohanraj G   
 



MO Mohit July 27, 2017 12:16 PM UTC

Hi Gunasekaran,

Thank you very much for your help!



MG Mohanraj Gunasekaran Syncfusion Team July 28, 2017 05:14 AM UTC

Hi Mohit,    
 
Thanks for your update. 
 
We are glad to know that your reported problem has resolved.  
 
Please let us know, if you have any concerns. 
 
Regards, 
Mohanraj G 


Loader.
Live Chat Icon For mobile
Up arrow icon