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

How to access deny to add appointment on particular time on Radscheuduler

7 Answers 155 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Venkateswara
Top achievements
Rank 1
Venkateswara asked on 30 Jul 2011, 01:57 PM
Hi,

 I am using  Rad Scheduler and rad calender to display Appointment .I want to restrict the user for particular time slot.please let me know how can i restrict to add appointment  at that time.
for example today at 12 am i don't want to access the user to add appointment how can i do this let me know how can resolve this issue

regards,
venkateswararao

7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 03 Aug 2011, 12:09 PM
Hi Venkateswararao,

There is more than one way to achieve this. Please, review the following resources and decide which way will best suit your case:

http://www.telerik.com/support/kb/aspnet-ajax/scheduler/setting-special-days-or-time-slots-in-radscheduler.aspx

http://demos.telerik.com/aspnet-ajax/scheduler/examples/resourceavailability/defaultcs.aspx

http://demos.telerik.com/aspnet-ajax/scheduler/examples/limitconcurrentappointments/defaultcs.aspx


Kind regards,
Peter
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Allen
Top achievements
Rank 1
answered on 21 May 2012, 08:33 PM
I have a similar question.
Please refer to the attached file:  
How to make the time range of the Prefered Availability within the time range of the Availability.  It means the Prefered Availability have to be in the time frame of the Availability.
0
Plamen
Telerik team
answered on 24 May 2012, 02:59 PM
Hi Allen,

 
In such scenarios we recommend setting the time restrictions by customizing the time slots instead of adding other appointments and inspecting their start time and end time because they are defining the start and end of each appointment.

Hope this will be helpful.

Regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Allen
Top achievements
Rank 1
answered on 24 May 2012, 06:29 PM
I have checked the Time Slot sample, but couldn't find the function that fit my needs.
My request is simple:  If the user change the time , the Prefered Availability (green bar) can't exceed the time range of the Availability (yellow bar).
eg:  Availability (from 9am to 6pm),  the Prefered Availability need to be in the time range of "9am to 6pm". Please refer to the attached file again:  All of the Availability bars are larger than the Prefered availability bars.
0
Plamen
Telerik team
answered on 25 May 2012, 02:44 PM
Hello Allen,

 
I have inspected the scenario you described once again and prepared a sample page that shows one way how to implement a similar scenario . I am attaching my test project.

Hope this will be helpful.

All the best,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Allen
Top achievements
Rank 1
answered on 31 May 2012, 09:01 PM

However, I'm using "AppointmentDataBound", not the XML file.  It won't involk AppointmentUpdate.
Here is my code:

 

Imports Microsoft.VisualBasic

Imports System.Collections.Generic

Imports System.Web

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Data

Imports System.Configuration

Imports System.Web.Security

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Imports Telerik.Web.UI

 

Partial Class _Default

    Inherits System.Web.UI.Page

    Private Class CustomAppointmentComparer

        Implements IComparer(Of Appointment)

        Public Function Compare(first As Appointment, second As Appointment) As Integer Implements IComparer(Of Telerik.Web.UI.Appointment).Compare

            Dim infoStart1 As String = first.Start.ToString

            Dim infoend1 As String = first.End.ToString

            Dim infoStar2 As String = second.Start.ToString

            Dim infoend2 As String = second.End.ToString

            If first Is Nothing OrElse second Is Nothing Then

                Throw New InvalidOperationException("Can't compare null object(s).")

            End If

 

            If [String].Compare(first.Subject.ToString, second.Subject.ToString) < 0 Then

                Return -1

            End If

 

 

            If [String].Compare(first.Subject.ToString, second.Subject.ToString) > 0 Then

                Return 1

            End If

 

            Return 0

        End Function

    End Class

    ''Protected Sub Page_Init(sender As Object, e As EventArgs)

    ''Dim provider As New XmlSchedulerProvider(Server.MapPath("~/App_Data/AppointmentsA.xml"), True)

    ''RadScheduler2.AppointmentComparer = New CustomAppointmentComparer()

    ''End Sub

 

    ''Protected Overrides Sub OnInit(e As EventArgs)

    ''MyBase.OnInit(e)

    ''RadScheduler2.Provider = New XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), True)

    ''RadScheduler2.Provider = New XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), True)

    ''End Sub

 

 

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        RadScheduler2.AppointmentComparer = New CustomAppointmentComparer()

        Dim appointments As Appointment() = RadScheduler2.Appointments.ToArray()

        Array.Sort(appointments, New CustomAppointmentComparer())

        For Each appointment As Appointment In appointments

            Dim appointmentStart As DateTime = RadScheduler2.UtcToDisplay(appointment.Start)

            If appointmentStart > RadScheduler2.SelectedDate Then

                RadScheduler2.SelectedDate = appointmentStart.[Date]

                Exit For

            End If

        Next

    End Sub

 

 

    Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler2.AppointmentDataBound

        e.Appointment.CssClass = "MyCustomAppointmentStyle"

        If e.Appointment.Subject = "Availability" Then

            e.Appointment.CssClass = "•rsCategoryYellow"

        Else

            e.Appointment.CssClass = "rsCategoryGreen"

        End If

 

    End Sub

 

    Protected Sub RadScheduler2_FormCreated(ByVal sender As Object, ByVal e As SchedulerFormCreatedEventArgs) Handles RadScheduler2.FormCreated

        If (e.Container.Mode = SchedulerFormMode.AdvancedEdit) OrElse (e.Container.Mode = SchedulerFormMode.AdvancedInsert) Then

            Dim allDayCheckbox As CheckBox = DirectCast(e.Container.FindControl("AllDayEvent"), CheckBox)

            allDayCheckbox.Style.Add("visibility", "hidden")

            Dim attrAnnotationsTextbox As RadTextBox = DirectCast(e.Container.FindControl("Subject"), RadTextBox)

            attrAnnotationsTextbox.Label = "Type"

            attrAnnotationsTextbox.Enabled = False

            Dim startPicker As RadTimePicker = DirectCast(e.Container.FindControl("StartTime"), RadTimePicker)

            startPicker.TimeView.StartTime = TimeSpan.FromHours(8)

            startPicker.TimeView.EndTime = TimeSpan.FromHours(24)

            startPicker.TimeView.DataList.DataSource = Nothing

            startPicker.TimeView.DataBind()

            Dim endPicker As RadTimePicker = DirectCast(e.Container.FindControl("EndTime"), RadTimePicker)

            endPicker.TimeView.StartTime = TimeSpan.FromHours(8)

            endPicker.TimeView.EndTime = TimeSpan.FromHours(24)

            endPicker.TimeView.DataList.DataSource = Nothing

            endPicker.TimeView.DataBind()

        End If

    End Sub

 

    Protected Sub RadScheduler2_AppointmentInsert(sender As Object, e As AppointmentInsertEventArgs)

        If e.Appointment.Subject = "Prefered Availability" Then

            Dim scheduler As RadScheduler = DirectCast(sender, RadScheduler)

            For Each app As Appointment In scheduler.Appointments.GetAppointmentsInRange(e.Appointment.Start, e.Appointment.[End])

                If app.Subject = "Availability" Then

                    If app.Start > e.Appointment.Start OrElse app.[End] <= e.Appointment.[End] Then

                        e.Cancel = True

                    End If

                End If

 

            Next

        End If

 

    End Sub

    Protected Sub RadScheduler2_AppointmentUpdate(sender As Object, e As AppointmentUpdateEventArgs)

        Dim scheduler As RadScheduler = DirectCast(sender, RadScheduler)

        If e.ModifiedAppointment.Subject = "Prefered Availability" Then

            For Each app As Appointment In scheduler.Appointments.GetAppointmentsInRange(e.ModifiedAppointment.Start, e.ModifiedAppointment.[End])

 

                If app.Subject = "Availability" Then

                    If app.Start > e.ModifiedAppointment.Start OrElse app.[End] < e.ModifiedAppointment.[End] Then

                        e.Cancel = True

                    End If

                End If

 

            Next

        End If

 

        If e.ModifiedAppointment.Subject = "Availability" Then

            For Each app As Appointment In scheduler.Appointments.GetAppointmentsInRange(e.ModifiedAppointment.Start, e.ModifiedAppointment.[End])

 

                If app.Subject = "Prefered Availability" Then

                    If app.Start < e.ModifiedAppointment.Start OrElse app.[End] > e.ModifiedAppointment.[End] Then

                        e.Cancel = True

                    End If

                End If

            Next

        End If

 

    End Sub

 

End Class

 

 

 

 

 

 

0
Plamen
Telerik team
answered on 05 Jun 2012, 02:16 PM
Hello Allen,

 
I have reviewed the code that you posted. It seems that there is some kind of misunderstanding. Please excuse me for that. The AppointmentInsert and AppointmentUpdate methods are thrown when appointments are inserted or updated by the client. It is not possible to use the AppointmentDataBound for such validation so I will recommend you just to check the availability before you start the project.

Any further forbidden change should be caught and canceled by the server code.

Hope this will be helpful.

Greetings,

Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Venkateswara
Top achievements
Rank 1
Answers by
Peter
Telerik team
Allen
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or