or







Private Sub radSchedulerDemo_CellFormatting(sender As System.Object, e As SchedulerCellEventArgs) Handles radSchedulerDemo.CellFormatting 'Check Date Block Dim dbDateBlocked As Boolean = isDateBlocked(e.CellElement.Date) If dbDateBlocked Then e.CellElement.Enabled = False End If If isTimeBlocked(e.CellElement.Date) Then e.CellElement.Enabled = False End If End Sub
Function isDateBlocked(ByVal eDate As Date) As Boolean Dim blReturn As Boolean = False 'Test that the date is not in the range of blocked dates 'Specific dates Dim dtBlock As Date = New Date(2012, 9, 5) 'No Appointments in the Past If dtBlock < DateTime.Today Then blReturn = True End If If eDate.Equals(dtBlock) Then blReturn = True End If 'Weekends If eDate.DayOfWeek = DayOfWeek.Saturday Then blReturn = True End If If eDate.DayOfWeek = DayOfWeek.Sunday Then blReturn = True End If Return blReturn End Function
Function isTimeBlocked(ByVal eDate As DateTime) As Boolean Dim blReturn As Boolean = False Dim dtBlock As Date = New Date(2012, 9, 5) 'Check if Day Blocked If eDate.Equals(dtBlock) Then 'Block all slots for this day as a override for any other open slots by default Return True Exit Function End If 'Working hours Mon - Friday 'Block Slots ' 0:00 - 8:00 Dim tsDayStart As New TimeSpan(0, 0, 0) Dim tsWorkStart As New TimeSpan(8, 0, 0) Dim tsWorkStartLate As New TimeSpan(10, 0, 0) ' 12:00-13:00 Dim tsLunchStart As New TimeSpan(12, 0, 0) Dim tsLunchEnd As New TimeSpan(13, 0, 0) ' 17:00-24:00 Dim tsWorkEndEarly As New TimeSpan(15, 0, 0) Dim tsWorkEnd As New TimeSpan(17, 0, 0) Dim tsWorkEndLate As New TimeSpan(19, 0, 0) Dim tsDayEnd As New TimeSpan(23, 59, 59) Select Case eDate.DayOfWeek Case DayOfWeek.Monday If eDate.TimeOfDay >= tsDayStart AndAlso eDate.TimeOfDay < tsWorkStart Then blReturn = True End If If eDate.TimeOfDay >= tsLunchStart AndAlso eDate.TimeOfDay < tsLunchEnd Then blReturn = True End If If eDate.TimeOfDay >= tsWorkEnd AndAlso eDate.TimeOfDay <= tsDayEnd Then blReturn = True End If Case DayOfWeek.Tuesday If eDate.TimeOfDay >= tsDayStart AndAlso eDate.TimeOfDay < tsWorkStart Then blReturn = True End If If eDate.TimeOfDay >= tsLunchStart AndAlso eDate.TimeOfDay <= tsLunchEnd Then blReturn = True End If If eDate.TimeOfDay >= tsWorkEnd AndAlso eDate.TimeOfDay <= tsDayEnd Then blReturn = True End If Case DayOfWeek.Wednesday 'Late working day If eDate.TimeOfDay >= tsDayStart AndAlso eDate.TimeOfDay < tsWorkStart Then blReturn = True End If If eDate.TimeOfDay >= tsLunchStart AndAlso eDate.TimeOfDay < tsLunchEnd Then blReturn = True End If If eDate.TimeOfDay >= tsWorkEndLate AndAlso eDate.TimeOfDay <= tsDayEnd Then blReturn = True End If Case DayOfWeek.Thursday 'Late Start of Day If eDate.TimeOfDay >= tsDayStart AndAlso eDate.TimeOfDay < tsWorkStartLate Then blReturn = True End If If eDate.TimeOfDay >= tsLunchStart AndAlso eDate.TimeOfDay < tsLunchEnd Then blReturn = True End If If eDate.TimeOfDay >= tsWorkEnd AndAlso eDate.TimeOfDay <= tsDayEnd Then blReturn = True End If Case DayOfWeek.Friday 'Early Working end If eDate.TimeOfDay >= tsDayStart AndAlso eDate.TimeOfDay < tsWorkStart Then blReturn = True End If If eDate.TimeOfDay >= tsLunchStart AndAlso eDate.TimeOfDay < tsLunchEnd Then blReturn = True End If If eDate.TimeOfDay >= tsWorkEndEarly AndAlso eDate.TimeOfDay <= tsDayEnd Then blReturn = True End If Case DayOfWeek.Saturday blReturn = True Case DayOfWeek.Saturday blReturn = True End Select Return blReturn End Function