Example #1
0
        private void FillCalendar()
        {
            Miami.Substitute.Bll.Substitute substitute = new Miami.Substitute.Bll.Substitute();
            substitute.LoadByUserId(Micajah.Common.Security.UserContext.Current.UserId);

            ((DropDownList)AvailabilityForm.FindControl("availabilityTimeStart")).SelectedValue = substitute.AvailabilityTimeStart;
            ((DropDownList)AvailabilityForm.FindControl("availabilityTimeEnd")).SelectedValue   = substitute.AvailabilityTimeEnd;

            Miami.Substitute.Bll.SubstituteExceptions subExceptions = new Miami.Substitute.Bll.SubstituteExceptions();
            DataView dv = subExceptions.LoadAllByUserId();

            if (dv != null)
            {
                foreach (DataRowView drv in dv)
                {
                    if (substitute.AvailabilityWeekDays.Contains((((int)(Convert.ToDateTime(drv["DateStart"]).DayOfWeek)) + 1).ToString()))
                    {
                        RadCalendarExceptions.SelectedDates.Add(new Telerik.WebControls.RadDate(Convert.ToDateTime(drv["DateStart"])));
                    }
                }
            }

            DateTime curDate = DateTime.Now.AddDays(-(DateTime.Now.Day - 1));

            Bll.Job job = new Miami.Substitute.Bll.Job();
            acceptedJobs = job.SearchOpenJobs(DateTime.Now, DateTime.Now.AddYears(10), 2);
            while (curDate < DateTime.Now.AddYears(1))
            {
                Telerik.WebControls.RadCalendarDay radCalendarDay = new Telerik.WebControls.RadCalendarDay();
                radCalendarDay.Date = curDate;
                if (IsOverlapDay(curDate))
                {
                    radCalendarDay.ItemStyle.CssClass = "overlap";
                    radCalendarDay.IsSelectable       = false;
                }
                else if (curDate >= DateTime.Now && substitute.AvailabilityWeekDays.Contains((((int)(curDate.DayOfWeek)) + 1).ToString()))
                {
                    radCalendarDay.ItemStyle.ForeColor = System.Drawing.Color.Green;
                    radCalendarDay.IsSelectable        = true;
                    radCalendarDay.IsDisabled          = false;
                }
                else
                {
                    radCalendarDay.IsSelectable = false;
                    radCalendarDay.IsDisabled   = true;
                }

                RadCalendarExceptions.SpecialDays.Add(radCalendarDay);
                curDate = curDate.AddDays(1);
            }
        }
        private void FillCalendar()
        {
            Miami.Substitute.Bll.Substitute substitute = new Miami.Substitute.Bll.Substitute();
            substitute.LoadByUserId(Micajah.Common.Security.UserContext.Current.UserId);

            ((DropDownList)AvailabilityForm.FindControl("availabilityTimeStart")).SelectedValue = substitute.AvailabilityTimeStart;
            ((DropDownList)AvailabilityForm.FindControl("availabilityTimeEnd")).SelectedValue = substitute.AvailabilityTimeEnd;

            Miami.Substitute.Bll.SubstituteExceptions subExceptions = new Miami.Substitute.Bll.SubstituteExceptions();
            DataView dv = subExceptions.LoadAllByUserId();
            if (dv != null)
                foreach (DataRowView drv in dv)
                    if (substitute.AvailabilityWeekDays.Contains((((int)(Convert.ToDateTime(drv["DateStart"]).DayOfWeek)) + 1).ToString()))
                        RadCalendarExceptions.SelectedDates.Add(new Telerik.WebControls.RadDate(Convert.ToDateTime(drv["DateStart"])));

            DateTime curDate = DateTime.Now.AddDays(-(DateTime.Now.Day - 1));
            Bll.Job job = new Miami.Substitute.Bll.Job();
            acceptedJobs = job.SearchOpenJobs(DateTime.Now, DateTime.Now.AddYears(10), 2);
            while (curDate < DateTime.Now.AddYears(1))
            {
                Telerik.WebControls.RadCalendarDay radCalendarDay = new Telerik.WebControls.RadCalendarDay();
                radCalendarDay.Date = curDate;
                if (IsOverlapDay(curDate))
                {
                    radCalendarDay.ItemStyle.CssClass= "overlap";
                    radCalendarDay.IsSelectable = false;
                }
                else if (curDate >= DateTime.Now && substitute.AvailabilityWeekDays.Contains((((int)(curDate.DayOfWeek))+1).ToString()))
                {
                    radCalendarDay.ItemStyle.ForeColor = System.Drawing.Color.Green;
                    radCalendarDay.IsSelectable = true;
                    radCalendarDay.IsDisabled = false;
                }
                else
                {
                    radCalendarDay.IsSelectable = false;
                    radCalendarDay.IsDisabled = true;
                }

                RadCalendarExceptions.SpecialDays.Add(radCalendarDay);
                curDate = curDate.AddDays(1);
            }
        }