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

[Solved] Concurrent appointment in ResourceView

2 Answers 174 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 03 Jun 2008, 10:33 AM
Hi, I would like to use Scheduler to book our cars. So far everything look good, but I am trying to implement your example from:  Limiting the number of concurrent appointments. The example works fine, when I an looking at the calendar for one car, if a timeslot is already in use, I get my  message.

But when in ResourceView, I also get a message, when I try to book a car at a time, when one of the others cars is already booked. How do change your example to count only the selected car. A VB example will be very appriciated.

Thanks

Brian

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 04 Jun 2008, 11:44 AM
Hi Brian,

We have omitted the case with ResourceView to keep things simple. However, you can modify the code as follows to achieve the desired functionality:

Protected Function ExceedsLimit(ByVal apt As Appointment) As Boolean 
    Dim appointmentsCount As Integer = RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.[End]).Count  
    Return (appointmentsCount > AppointmentsLimit - 1)  
End Function 
 
Protected Function HasSameResource(ByVal apt As Appointment, ByVal scheduler As RadScheduler) As Boolean 
    For Each otherApt As Appointment In RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.[End])  
        For Each otherAptRes As Resource In otherApt.Resources.GetResourcesByType(scheduler.GroupBy)  
            For Each res As Resource In apt.Resources.GetResourcesByType(scheduler.GroupBy)  
                If otherAptRes.Key.Equals(res.Key) Then 
                    Return True 
                End If 
            Next 
        Next 
    Next 
    Return False 
End Function 
 
Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerCancelEventArgs)  
    If RadScheduler1.SelectedView = SchedulerViewType.ResourceView Then 
        If ExceedsLimit(e.Appointment) And HasSameResource(e.Appointment, RadScheduler1) Then 
            Label1.Text = "Another appointment exists in this time slot." 
            e.Cancel = True 
        End If 
    Else 
        If ExceedsLimit(e.Appointment) Then 
            Label1.Text = "Another appointment exists in this time slot." 
            e.Cancel = True 
        End If 
    End If 
End Sub 
 


Best wishes,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brian
Top achievements
Rank 1
answered on 05 Jun 2008, 08:22 AM
Excellent, works like a charm.

Thanks,

Brian
Tags
Scheduler
Asked by
Brian
Top achievements
Rank 1
Answers by
Peter
Telerik team
Brian
Top achievements
Rank 1
Share this question
or