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

Rad Scheduler - Suitability Question

1 Answer 65 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 07 Jan 2009, 09:32 PM
I am wondering whether the RAD Scheduler could be made to work in the scenario below.  The documentation leads me to think that the scheduler is intended primarily to track schedules for one person at a time.  Eg, I can set my schedule up, and you can set yours up, but the two must be viewed separately.

This scenario is for a school which needs to make schedules for students, staff, locations, and groups of the three.

So, for example, the scheduler should drop two students and one staff member into a 45 minute meeting in room A on a given day at 10:45.  On the same day, it should drop different students and staff members into a different room at the same time.  If someone tries to put the same student in different places at overlapping times, it would be rejected.

I cannot tell from skimming the documentation whether this is feasible with the scheduler.  As mentioned above, it looks like a tool for dealing with one individual, not with groups resources.

Thanks
Mike Thomas

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 09 Jan 2009, 03:33 PM
Hi Mike,

I am glad to inform you that RadScheduler supports the functionality which you desire and its implementation is quite simple in fact. Please, check the Resource Grouping example.
 
Also, to limit the number of concurrent appointments, please use the following code:
C#
protected bool ExceedsLimit(Appointment apt)  
{  
    int appointmentsCount = RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.End).Count;  
    return (appointmentsCount > AppointmentsLimit - 1);  
}  
 
protected bool HasSameResource(Appointment apt, RadScheduler scheduler)  
{  
    foreach (Appointment otherApt in RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.End)) {  
        foreach (Resource otherAptRes in otherApt.Resources.GetResourcesByType(scheduler.GroupBy)) {  
            foreach (Resource res in apt.Resources.GetResourcesByType(scheduler.GroupBy)) {  
                if (otherAptRes.Key.Equals(res.Key)) {  
                    return true;  
                }  
            }  
        }  
    }  
    return false;  
}  
 
protected void RadScheduler1_AppointmentInsert(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
{  
    if (RadScheduler1.SelectedView == SchedulerViewType.ResourceView) {  
        if (ExceedsLimit(e.Appointment) & HasSameResource(e.Appointment, RadScheduler1)) {  
            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;  
        }  
    }  
}  
 
 

VB.NET
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    
 



Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Mike
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or