Weekend Slots

2 posts, 0 answers
  1. Robi
    Robi avatar
    7 posts
    Member since:
    Mar 2013

    Posted 19 Sep 2013 Link to this post

    Hi,

    i want that i can create appointments  which are 3 or 4 weeks long..
    Is it possible to ignore the Weekends which are between the appointment? Or can they be made readonly or something else.. when i set IsReadOnly = true   i can max use 5 days (mo - fr) for an appointment  because saturday and sunday are blocked.. 

    private void CreateWeekendBlockedDates()
    {
        var weekEnds = new List<DateTime>(); //new list with Weekends
        DateTime startDate;
        if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday) //today = saturday?
        {
            startDate = DateTime.Today;
        }
        else
        {
            var diffDay = DateTime.Today.DayOfWeek - DayOfWeek.Saturday;
            startDate = DateTime.Today.AddDays(-diffDay);
        }
        //takes all weekends in 70 days past and 10 years future
        for (var dt = startDate.AddDays(-70); dt < startDate.AddYears(10); dt = dt.AddDays(7))
        {
            weekEnds.Add(dt);
        }
     
        foreach (var weekEnd in weekEnds)
        {
            SpecialSlots.Add(new DaySlot(weekEnd, weekEnd.AddDays(2))
            {
                Description = "",
                IsReadOnly = true  //other possibilities?
            });
        }
    }

    Regards

  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 24 Sep 2013 Link to this post

    Hi Robi,

    As a solution I can suggest you to use regular Slots instead of ReadOnly, this way you will be able to create longer appointments. As for the weekends you could easily disable the EditAppointmentDialog when user clicks inside them, you will need to handle the the ShowDialog event of the ScheduleView and to show the dialog only when the day is not in the weekend. Please check the code snippet below:

    private void scheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
    {
        var selectedSlot = (sender as RadScheduleView).SelectedSlot;
        if (this.scheduleView.SpecialSlotsSource.Any(slot => (slot.Start<=selectedSlot.Start && slot.End >= selectedSlot.End)))
        {
            e.Cancel = true;
        }           
    }

    Hope this will help you.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top