private void refreshCurrentlyScheduledDates()
        {
            using (var Dbconnection = new MCDEntities())
            {
                //CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseMinimumMaximum.CurriculumCourseMaximum
                //Dbconnection.CurriculumCourseEnrollments.Attach(CurrentSelectedCurriculumCourseEnrollment);
                //Dbconnection.Entry(CurrentSelectedCurriculumCourseEnrollment).Reference("CurriculumCourse.CurriculumCourseMinimumMaximum").Load();
                int MaxPerCourse = 0;
                if (CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseMinimumMaximum.CurriculumCourseMaximum != 0)
                {
                    MaxPerCourse = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseMinimumMaximum.CurriculumCourseMaximum;
                }
                //CurrentlyScheduledCourses
                List <CurrentlyScheduledCourses> CSC = new List <CurrentlyScheduledCourses>();



                switch (CurrentScheduleConfiguration.ScheduleLocationID)
                {
                case (int)Common.Enum.EnumScheduleLocations.Onsite:

                    List <GetAllOnSiteScheduledCourses_Result> AOSSC_Onsite = Dbconnection.GetAllOnSiteScheduledCourses(
                        scheduleLocationID: CurrentScheduleConfiguration.ScheduleLocationID,
                        curriculumCourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseID,
                        startDate: EnsureSchedulableDate(dtScheduleFromCustomStartDateSelector.SelectionStart.Date),// dtScheduleFromCustomStartDateSelector.SelectionStart.Date,
                        endDate: dtScheduleFromCustomStartDateSelector.SelectionStart.Date.AddMonths((int)CurrentPeriodAhead))
                                                                              .ToList <GetAllOnSiteScheduledCourses_Result>();



                    foreach (GetAllOnSiteScheduledCourses_Result item in AOSSC_Onsite.Where(a => a.AmountEnrolled < MaxPerCourse))
                    {
                        CSC.Add(new CurrentlyScheduledCourses()
                        {
                            CourseStartDate = item.ScheduleStartDate.Date,
                            CourseEndDate   = item.ScheduleCompletionDate.Date,
                            CourseName      = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Course.CourseName,
                            CourseID        = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CourseID,
                            FacilitatorID   = item.IndividualID,
                            FacilitatorName = item.FacilitatorName,
                            VenueID         = item.VenueID,
                            VenueName       = item.VenueName,
                            AmountEnrolled  = Convert.ToInt32(item.AmountEnrolled)
                        });
                    }

                    currentlyScheduledCoursesBindingSource.DataSource = CSC.ToList();
                    break;

                case (int)Common.Enum.EnumScheduleLocations.OffSite:

                    List <GetAllOffSiteScheduledCourses_Result> AOSSC_OffSite = Dbconnection.GetAllOffSiteScheduledCourses(
                        scheduleLocationID: CurrentScheduleConfiguration.ScheduleLocationID,
                        curriculumCourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseID,
                        startDate: EnsureSchedulableDate(dtScheduleFromCustomStartDateSelector.SelectionStart.Date),     // dtScheduleFromCustomStartDateSelector.SelectionStart.Date,
                        endDate: dtScheduleFromCustomStartDateSelector.SelectionEnd.Date).ToList <GetAllOffSiteScheduledCourses_Result>();

                    //CurrentlyScheduledCourses
                    // List<CurrentlyScheduledCourses> CSC = new List<CurrentlyScheduledCourses>();
                    foreach (GetAllOffSiteScheduledCourses_Result item in AOSSC_OffSite.Where(a => a.AmountEnrolled < MaxPerCourse))
                    {
                        CSC.Add(new CurrentlyScheduledCourses()
                        {
                            CourseStartDate = item.ScheduleStartDate.Date,
                            CourseEndDate   = item.ScheduleCompletionDate.Date,
                            CourseName      = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Course.CourseName,
                            CourseID        = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CourseID,
                            FacilitatorID   = item.IndividualID,
                            FacilitatorName = item.FacilitatorName,
                            VenueID         = item.VenueID,
                            VenueName       = item.VenueName,
                            AmountEnrolled  = Convert.ToInt32(item.AmountEnrolled)
                        });
                    }
                    currentlyScheduledCoursesBindingSource.DataSource = CSC.ToList();
                    break;
                }

                //CurrentlyScheduledCourses
            };
        }