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

Preventing Appointment Conflict

2 Answers 140 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
salman
Top achievements
Rank 1
salman asked on 29 Jul 2008, 06:09 PM
Hello,

Do you know the best way of preventing the appointment conflict while creating a Recurring appointment?

For example, let see if I already have a resource reserved for 08/1/2008 between 9AM to 12PM on Friday .
When I try to create a new appointment with the same resource today as a recurrning appointment, Weekly, Every Friday, 10 occurences.  Now, it should not let me create the appointment since there is a conflict.

I will really appereciate if you can either direct me what to do here or show a some sort of example.

Thank you,
-Salman

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 31 Jul 2008, 10:26 AM
Hi Salman,

Thank you for your question. We might add this functionality in our online examples. Meanwhile, I am sending you a sample for reference (please, find it attached). The key point here is to loop through all occurences and campare their times.

protected bool ExceedsLimit(Appointment apt, DateTime recurrenceDateTime)  
        {  
            int appointmentsCount = RadScheduler1.Appointments.GetAppointmentsInRange(recurrenceDateTime, recurrenceDateTime.Add(apt.Duration)).Count;  
            return (appointmentsCount > AppointmentsLimit - 1);  
 
            //occurrence.ToString(), occurrence.Add(a.Duration);  
 
              
        }  
 
        protected void RadScheduler1_AppointmentInsert(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
        {  
            if (e.Appointment.RecurrenceRule != "")  
            {  
                RecurrenceRule parsedRule;  
                RecurrenceRule.TryParse(e.Appointment.RecurrenceRule.ToString(), out parsedRule);  
 
                foreach (DateTime occurrence in parsedRule.Occurrences)  
                {  
                    if (ExceedsLimit(e.Appointment, occurrence))  
                    {  
                        Label1.Text = "Another appointment exists in this time slot.";  
                        e.Cancel = true;  
                    }       
                }  
            }  
            else 
            {  
                if (ExceedsLimit(e.Appointment))  
                {  
                    Label1.Text = "Another appointment exists in this time slot.";  
                    e.Cancel = true;  
                }              
            }              
        } 






Kind regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
salman
Top achievements
Rank 1
answered on 04 Aug 2008, 06:47 PM
That's what I was looking for. 

Thank you!
Tags
Scheduler
Asked by
salman
Top achievements
Rank 1
Answers by
Peter
Telerik team
salman
Top achievements
Rank 1
Share this question
or