private void btnRemoveLinkedCourse_Click(object sender, EventArgs e)
        {
            int _CurriculumCourseID = 0;
            int _EnrollmentID       = 0;

            if (CurriculumCoursesbindingSourceLinkedCourses.Count > 0)
            {
                _CurriculumCourseID = ((CurriculumCourse)CurriculumCoursesbindingSourceLinkedCourses.Current).CurriculumCourseID;
                _EnrollmentID       = ((Enrollment)enrollmentBindingSource.Current).EnrollmentID;

                using (var Dbconnection = new MCDEntities())
                {
                    CurriculumCourseEnrollment currentItem = (from a in Dbconnection.CurriculumCourseEnrollments
                                                              where a.CurriculumCourseID == _CurriculumCourseID &&
                                                              a.EnrollmentID == _EnrollmentID
                                                              select a).FirstOrDefault <CurriculumCourseEnrollment>();
                    Dbconnection.CurriculumCourseEnrollments.Remove(currentItem);
                    Dbconnection.SaveChanges();
                };
            }
            ;


            refreshAvailableCurriculumCourses();
            refreshLinkedCurriculumCourses();
        }
        private void dgvEnrollmentPreRequisites_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //Enrollment PreRequisiteEnrollment = ((CurriculumCourseEnrollment)curriculumCourseEnrollmentPreRequisiteCourseBindingSource.Current).Enrollment;
            CurriculumCourseEnrollment CurriculumCourseEnrollmentObj = ((CurriculumCourseEnrollment)curriculumCourseEnrollmentPreRequisiteCourseBindingSource.Current);

            switch (e.ColumnIndex)
            {
            case 3:
                this.CurrentEnrollmentPreRequisiteID     = CurriculumCourseEnrollmentObj.Enrollment.EnrollmentID;
                this.CurrentCurriculumCourseEnrollmentID = CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID;
                this.refreshEnrollment();
                this.hideAddCourseForEnrollment();
                break;

            case 4:
                if (Convert.ToInt32(dgvEnrollmentPreRequisites.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag) == 0)
                {
                    using (frmEnrollmentException frm = new frmEnrollmentException())
                    {
                        frm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn;
                        frm.EnquiryID = CurrentEquiryID;
                        frm.SelectedCurriculumCourseEnrollment = (CurriculumCourseEnrollment)curriculumCourseEnrollmentPreRequisiteCourseBindingSource.Current;
                        frm.ShowDialog();
                    }
                }
                else
                {
                }

                refreshEnrollment();
                break;
            }
        }
        private void btnLinkAvaiableCourse_Click(object sender, EventArgs e)
        {
            int _CurriculumCourseID = 0;
            int _EnrollmentID       = 0;

            if (CurriculumCoursesbindingSourceAvailableCourses.Count > 0)
            {
                _CurriculumCourseID = ((CurriculumCourse)CurriculumCoursesbindingSourceAvailableCourses.Current).CurriculumCourseID;
                _EnrollmentID       = ((Enrollment)enrollmentBindingSource.Current).EnrollmentID;
                using (var Dbconnection = new MCDEntities())
                {
                    CurriculumCourseEnrollment newItem = new CurriculumCourseEnrollment
                    {
                        EnrollmentID       = _EnrollmentID,
                        CurriculumCourseID = _CurriculumCourseID
                    };

                    Dbconnection.CurriculumCourseEnrollments.Add(newItem);
                    Dbconnection.SaveChanges();
                };
            }
            ;



            refreshAvailableCurriculumCourses();
            refreshLinkedCurriculumCourses();
        }
        private void dgvEnrollmentCourseMain_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    CurriculumCourseEnrollment      CurriculumCourseEnrollmentObj = (CurriculumCourseEnrollment)row.DataBoundItem;
                    ObservableListSource <Schedule> Schedules = (ObservableListSource <Schedule>)CurriculumCourseEnrollmentObj.Schedules;

                    row.Cells[colCourseEnrollmentMainCourseName.Index].Value = CurriculumCourseEnrollmentObj.CurriculumCourse.Course.CourseName.ToString();

                    if ((from a in Schedules
                         where a.CurriculumCourseEnrollmentID == CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID
                         select a).ToList <Schedule>().Count > 0)
                    {
                        Schedule ScheduleObj = (from a in Schedules
                                                where a.CurriculumCourseEnrollmentID == CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID
                                                select a).FirstOrDefault <Schedule>();

                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Value = "[ View Schedule ]";
                        row.Cells[colSelectedEnrollemntStartDate.Index].Value          = ScheduleObj.ScheduleStartDate.ToString("D");
                        row.Cells[colSelectedEnrollemntEndDate.Index].Value            = ScheduleObj.ScheduleCompletionDate.ToString("D");
                    }
                    else
                    {
                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Value = "[ Schedule Course ]";
                        row.Cells[colSelectedEnrollemntStartDate.Index].Value          = "Not Yet Scheduled";
                        row.Cells[colSelectedEnrollemntEndDate.Index].Value            = "Not Yet Scheduled";
                    }
                }
            }
        }
        private List <EnumDayOfWeeks> GetDayThatCurriculumCourseCanBeScheduled(CurriculumCourseEnrollment CurrentSelectedCurriculumCourseEnrollment)
        {
            List <EnumDayOfWeeks> DaysCanSchedule = new List <EnumDayOfWeeks>();

            //sets the Date One Day Ahead
            foreach (CurriculumCourseDayCanBeScheduled CCDCBS in CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseDayCanBeScheduleds)
            {
                DaysCanSchedule.Add((EnumDayOfWeeks)CCDCBS.DayOfWeekID);
            }
            ;
            return(DaysCanSchedule);
        }
        private void AddCurriculum()
        {
            int        LookupSectionalEnrollmentTypeID = 0;
            Curriculum CurriculumObj = ((Curriculum)curriculumBindingSource.Current);

            foreach (RadioButton rad in flowLayoutPanelEnrollmentTypes.Controls)
            {
                if (rad.Checked)
                {
                    LookupSectionalEnrollmentTypeID = (int)rad.Tag;
                }
            }
            using (var Dbconnection = new MCDEntities())
            {
                Enrollment x = new Enrollment();

                Enrollment enroll = new Enrollment
                {
                    LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.In_Progress,
                    IndividualID   = this.StudentID,
                    CurriculumID   = CurriculumObj.CurriculumID,
                    DateIntitiated = DateTime.Now
                                     //,ApprienticeshipEnrollment = new   ApprienticeshipEnrollment
                                     //{
                                     //    LookupSectionalEnrollmentTypeID = LookupSectionalEnrollmentTypeID
                                     //}
                };

                Dbconnection.Enrollments.Add(enroll);
                Dbconnection.SaveChanges();


                List <CurriculumCourse> lstCurriculumCourse = (from a in Dbconnection.CurriculumCourses
                                                               where a.CurriculumID == CurriculumObj.CurriculumID
                                                               select a).ToList <CurriculumCourse>();

                foreach (CurriculumCourse CurrCourseObj in lstCurriculumCourse)
                {
                    CurriculumCourseEnrollment CurriculumCourseEnrollmentObj = new CurriculumCourseEnrollment
                    {
                        CurriculumCourseID = CurrCourseObj.CurriculumCourseID,
                        EnrollmentID       = enroll.EnrollmentID
                    };
                    enroll.CurriculumCourseEnrollments.Add(CurriculumCourseEnrollmentObj);
                }
                Dbconnection.SaveChanges();
            };
            this.Close();
        }
 public frmScheduleCurriculumCourseWizard(DateTime InitialStartDate, CurriculumCourseEnrollment CurrentSelectedCurriculumCourseEnrollment)
 {
     CurrentlySelectedItemRowIndex = 0;
     LastGridUsed = enumLastGridUsed.notYetSelectedAnyField;
     this.CurrentSelectedCurriculumCourseEnrollment = CurrentSelectedCurriculumCourseEnrollment;
     //PossibleStartDate = Common.CustomDateTime.getCustomDateTime(
     //                                   CurrentDate: DateTime.Now.Date.AddDays(1),
     //                                   AmountDaysToAdd: 0,
     //                                   DaysCanSchedule: GetDayThatCurriculumCourseCanBeScheduled());
     PossibleStartDate  = InitialStartDate;
     CurrentPeriodAhead = SearchTimeAhead.ThreeMonths;
     InitializeComponent();
     //dtScheduleFromCustomStartDateSelector.Format = DateTimePickerFormat.Custom;
     //dtScheduleFromCustomStartDateSelector.CustomFormat = "MMMM dd, yyyy - dddd";
     dtScheduleFromCustomStartDateSelector.MinDate = PossibleStartDate.Date;
 }
        private void btnUpdateCurriculumCourseEnrollmentCost_Click(object sender, EventArgs e)
        {
            CurriculumCourseEnrollment CCE = (CurriculumCourseEnrollment)curriculumCourseEnrollmentsMainCoursesBindingSource.Current;

            using (var Dbconnection = new MCDEntities())
            {
                using (System.Data.Entity.DbContextTransaction dbTran = Dbconnection.Database.BeginTransaction())
                {
                    try
                    {
                        //CRUD Operations
                        Dbconnection.CurriculumCourseEnrollments.Attach(CCE);
                        CCE.CourseCost = Convert.ToInt32(txtUpdateCurriulumCourseEnrollemntCost.Text);
                        Dbconnection.Entry(CCE).State = EntityState.Modified;

                        ////saves all above operations within one transaction
                        Dbconnection.SaveChanges();

                        //commit transaction
                        dbTran.Commit();
                        Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex is DbEntityValidationException)
                        {
                            foreach (DbEntityValidationResult entityErr in ((DbEntityValidationException)ex).EntityValidationErrors)
                            {
                                foreach (DbValidationError error in entityErr.ValidationErrors)
                                {
                                    MessageBox.Show(error.ErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        //Rollback transaction if exception occurs
                        dbTran.Rollback();
                    }
                }
            };
        }
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            if (curriculumCourseEnrollmentsMainCoursesBindingSource.Count > 0)
            {
                CurriculumCourseEnrollment CurrentSelectedCurriculumCourseEnrollment =
                    (CurriculumCourseEnrollment)curriculumCourseEnrollmentsMainCoursesBindingSource.Current;

                DialogResult Rtn = MetroMessageBox.Show(this, "All Scheduled Coures Will Be Confirmed, Are You Sure you Wish To Proceed?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (Rtn == DialogResult.Yes)
                {
                    if (CurrentSelectedCurriculumCourseEnrollment.Schedules.Count > 0)
                    {
                        using (frmConfirmScheduledCourse frm = new frmConfirmScheduledCourse(CurrentSelectedCurriculumCourseEnrollment.Schedules.FirstOrDefault().ScheduleID, CurrentSelectedCurriculumCourseEnrollment.EnrollmentID, true))
                        {
                            frm.ShowDialog();
                            this.refreshEnrollment();
                        }
                    }
                }
            }
        }
        private void dgvEnrollmentCourseMain_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            CurriculumCourseEnrollment CurrentSelectedCurriculumCourseEnrollment = (CurriculumCourseEnrollment)curriculumCourseEnrollmentsMainCoursesBindingSource.Current;

            switch (e.ColumnIndex)
            {
            case 0:
                //If if selected Course does not have a Parent Course then it can be scheduled any time forward from today
                if (CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseParentID == 0)
                {
                    //TODO: Open Scheduling Form - Pass Currently Selected CurriculumCourseEnrollment Object.

                    DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0);

                    using (frmScheduleCurriculumCourseWizard frm = new frmScheduleCurriculumCourseWizard(Common.CustomDateTime.getCustomDateTime(dt, 1, GetDayThatCurriculumCourseCanBeScheduled(CurrentSelectedCurriculumCourseEnrollment))))
                    {
                        //Sets The Possible Start Date

                        frm.CurrentSelectedCurriculumCourseEnrollment = CurrentSelectedCurriculumCourseEnrollment;

                        frm.ShowDialog();
                    }
                }
                else
                {
                    /*Has PreRequisite Course*/
                    //Step 1
                    //Determine if all PreRequisite Courses have been Scheduled.
                    if (DetermineIfAllPreRequisiteCourseHaveBeenScheduled(
                            _CurriculumCourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseID,
                            _EnrollmentID: CurrentSelectedCurriculumCourseEnrollment.EnrollmentID))
                    {
                        //IF All Course Pre-Requiesties Are Scheduled then:
                        //TODO: Open Scheduling Form - Pass the Selected Currc=iculum CourseEnrollment Object
                    }
                }
                break;
            }
        }
        private void dgvEnrollmentPreRequisites_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    CurriculumCourseEnrollment CurriculumCourseEnrollmentObj = (CurriculumCourseEnrollment)row.DataBoundItem;

                    if (!(CurriculumCourseEnrollmentObj.LookupEnrollmentProgressStateID == (int)EnumEnrollmentProgressStates.Excempt))
                    {
                        row.Cells[colPreRequisiteCourseProcessPreRequisiteCourse.Index].Value = "[ Edit ]";

                        row.Cells[colPreRequisiteCourseExemmptionStatus.Index].Value = "[ Exempt Course ]";
                        row.Cells[colPreRequisiteCourseExemmptionStatus.Index].Tag   = 0;
                    }
                    else
                    {
                        row.Cells[colPreRequisiteCourseProcessPreRequisiteCourse.Index].Value = "";
                        row.Cells[colPreRequisiteCourseExemmptionStatus.Index].Value          = "[ Re-Instate ]";
                        row.Cells[colPreRequisiteCourseExemmptionStatus.Index].Tag            = 1;
                    }
                    row.Cells[colPreRequisiteCourseCurriculumName.Index].Value = CurriculumCourseEnrollmentObj.CurriculumCourse.Curriculum.CurriculumName.ToString();
                    row.Cells[colPreRequisiteCourseName.Index].Value           = CurriculumCourseEnrollmentObj.CurriculumCourse.Course.CourseName.ToString();
                    row.Cells[colPreRequisiteCourseStatus.Index].Value         = CurriculumCourseEnrollmentObj.LookupEnrollmentProgressState.EnrollmentProgressCurrentState.ToString();
                    //
                    //CurriculumCourse CurriculumCourseObj = (from a in EnrollmentObj.CurriculumCourseEnrollments
                    //                                        where a.CurriculumCourse.CurriculumID == EnrollmentObj.CurriculumID
                    //                                        select a.CurriculumCourse)
                    //                                        .FirstOrDefault<CurriculumCourse>();
                    //row.Cells[colApprenticeshipPreRequisiteCourse.Index].Value = CurriculumCourseObj.Course.CourseName.ToString();
                    //row.Cells[colApprenticeshipPrerequisteProcessingStatus.Index].Value = EnrollmentObj.LookupEnrollmentProgressState.EnrollmentProgressCurrentState.ToString();
                }
            }
        }
        //private DateTime EnsureSchedulableDate(DateTime SelectedDate)
        //{
        //    Boolean IsValidDay = false;

        //    while (!IsValidDay)
        //    {
        //        EnumDayOfWeeks d = Common.CustomDateTime.CustomDayOfTheWeek(SelectedDate.DayOfWeek);
        //        if (GetDayThatCurriculumCourseCanBeScheduled().Contains(d))
        //        {
        //            IsValidDay = true;
        //        }
        //        else
        //        {
        //            SelectedDate.AddDays(1);
        //        }
        //    }
        //    return SelectedDate;
        //}
        private void dgvEnrollmentCourseMain_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            CurriculumCourseEnrollment CurrentSelectedCurriculumCourseEnrollment = (CurriculumCourseEnrollment)curriculumCourseEnrollmentsMainCoursesBindingSource.Current;

            switch (e.ColumnIndex)
            {
            case 0:


                if (dgvEnrollmentCourseMain.Rows[e.RowIndex].Cells[0].Tag.Equals("EDIT"))
                {
                    splitContainerUpdateCurriculumCourseDetails.Panel1Collapsed = true;
                    splitContainerUpdateCurriculumCourseDetails.Panel2Collapsed = false;
                    CurriculumCourseEnrollment CCE = (CurriculumCourseEnrollment)curriculumCourseEnrollmentsMainCoursesBindingSource.Current;
                    txtUpdateCurriulumCourseEnrollemntCost.Text = Convert.ToInt32(CCE.CourseCost).ToString();
                }
                else
                {
                    //If if selected Course does not have a Parent Course then it can be scheduled any time forward from today
                    if (CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseParentID == 0)
                    {
                        //TODO: Open Scheduling Form - Pass Currently Selected CurriculumCourseEnrollment Object.

                        DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

                        using (frmScheduleCurriculumCourseWizard frm = new frmScheduleCurriculumCourseWizard(
                                   InitialStartDate: dt.Date.AddDays(1),
                                   CurrentSelectedCurriculumCourseEnrollment: CurrentSelectedCurriculumCourseEnrollment
                                   ))
                        {
                            frm.ShowDialog();
                        }
                    }
                    else
                    {
                        /*Has PreRequisite Course*/
                        //Step 1
                        //Determine if all PreRequisite Courses have been Scheduled.
                        if (DetermineIfAllPreRequisiteCourseHaveBeenScheduled(
                                _CurriculumCourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourseID,
                                _EnrollmentID: CurrentSelectedCurriculumCourseEnrollment.EnrollmentID))
                        {
                            //IF All Course Pre-Requiesties Are Scheduled then:
                            //TODO: Open Scheduling Form - Pass the Selected Curriculum CourseEnrollment Object
                            int PreRequisiteCurriculumCourseID = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CurriculumCourseParentID;

                            Schedule PreRequisiteSchedule = (from a in CurrentEnrollment.CurriculumCourseEnrollments
                                                             from c in a.Schedules
                                                             where a.CurriculumCourseID == PreRequisiteCurriculumCourseID
                                                             select c).FirstOrDefault <Schedule>();


                            using (var Dbconnection = new MCDEntities())
                            {
                                DateTime dt = DateTime.Now;
                                //Boolean hhh = Convert.ToBoolean((Dbconnection.DetermineIfTheFirstCousrseToBeScheduled(
                                //       curriculumID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Curriculum.CurriculumID,
                                //       enrollmentID: CurrentSelectedCurriculumCourseEnrollment.EnrollmentID,
                                //       curriculumCourseID_ToCheck: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourseID).First().Value));

                                if (!Convert.ToBoolean((Dbconnection.DetermineIfTheFirstCousrseToBeScheduled(
                                                            curriculumID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Curriculum.CurriculumID,
                                                            enrollmentID: CurrentSelectedCurriculumCourseEnrollment.EnrollmentID,
                                                            curriculumCourseID_ToCheck: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourseID).First().Value)))
                                {
                                    System.Data.Entity.Core.Objects.ObjectResult <DateTime?> CC = Dbconnection.GetCurriculumCourseEnrollmentPreRequisiteEndDate(
                                        curriculumCourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourseID,
                                        enrollmentID: CurrentSelectedCurriculumCourseEnrollment.EnrollmentID);
                                    dt = CC.FirstOrDefault <DateTime?>().Value;
                                }

                                if (dt <= DateTime.Now.Date)
                                {
                                    dt = DateTime.Now.Date;
                                }
                                using (frmScheduleCurriculumCourseWizard frm = new frmScheduleCurriculumCourseWizard(
                                           InitialStartDate: dt.AddDays(1),
                                           CurrentSelectedCurriculumCourseEnrollment: CurrentSelectedCurriculumCourseEnrollment
                                           ))
                                {
                                    frm.lblWziardHeading.Text = CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Course.CourseName;
                                    frm.ShowDialog();
                                }
                            };
                        }
                    }
                }

                //this.CurrentEnrollmentPreRequisiteID = CurriculumCourseEnrollmentObj.Enrollment.EnrollmentID;
                //this.CurrentCurriculumCourseEnrollmentID = CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID;
                this.refreshEnrollment();
                this.hideAddCourseForEnrollment();
                break;

            case 1:

                switch (dgvEnrollmentCourseMain.Rows[e.RowIndex].Cells[1].Tag.ToString())
                {
                case "CompleteReport":
                    //CurrentSelectedCurriculumCourseEnrollment
                    using (frmAddNewApprenticeshipAssessmentReport frm = new frmAddNewApprenticeshipAssessmentReport(CurrentlySelectedCurriculumCourseEnrollment: CurrentSelectedCurriculumCourseEnrollment))
                    {
                        frm.ShowDialog();
                        this.refreshEnrollment();
                    }
                    break;

                case "ConfirmReservation":
                    using (frmConfirmScheduledCourse frm = new frmConfirmScheduledCourse(CurrentSelectedCurriculumCourseEnrollment.Schedules.FirstOrDefault().ScheduleID, CurrentSelectedCurriculumCourseEnrollment.EnrollmentID))
                    {
                        frm.ShowDialog();
                        this.refreshEnrollment();
                    }
                    break;

                    /* row.Cells[colAddEditCourseReport.Index].Value = "[ Confirm Reservation ]";
                     *          row.Cells[colAddEditCourseReport.Index].Tag = "ConfirmReservation";
                     */
                }

                //            row.Cells[colAddEditCourseReport.Index].Value = "[ Complete Report ]";
                //        row.Cells[colAddEditCourseReport.Index].Tag = "CompleteReport";
                //}else if (CurriculumCourseEnrollmentObj.LookupEnrollmentProgressStateID == (int)Common.Enum.EnumEnrollmentProgressStates.Complete)
                //{
                //    row.Cells[colAddEditCourseReport.Index].Value = "[ Update Report ]";
                //    row.Cells[colAddEditCourseReport.Index].Tag = "UpdateReport";
                break;
            }
        }
        private void dgvEnrollmentCourseMain_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    CurriculumCourseEnrollment      CurriculumCourseEnrollmentObj = (CurriculumCourseEnrollment)row.DataBoundItem;
                    ObservableListSource <Schedule> Schedules = (ObservableListSource <Schedule>)CurriculumCourseEnrollmentObj.Schedules;

                    row.Cells[colCourseEnrollmentMainCourseName.Index].Value = CurriculumCourseEnrollmentObj.CurriculumCourse.Course.CourseName.ToString();
                    row.Cells[colCourseEnrollmentMainStatus.Index].Value     = CurriculumCourseEnrollmentObj.LookupEnrollmentProgressState.EnrollmentProgressCurrentState.ToString();

                    /*Course Has Been Scheduled
                     * **************************/
                    if ((from a in Schedules
                         where a.CurriculumCourseEnrollmentID == CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID
                         select a).ToList <Schedule>().Count > 0)
                    {
                        Schedule ScheduleObj = (from a in Schedules
                                                where a.CurriculumCourseEnrollmentID == CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID
                                                orderby a.ScheduleID
                                                select a).LastOrDefault <Schedule>();

                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Value = "[ Edit ]";
                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Tag   = "EDIT";

                        row.Cells[colSelectedEnrollemntStartDate.Index].Value = ScheduleObj.ScheduleStartDate.ToString("D");
                        row.Cells[colSelectedEnrollemntEndDate.Index].Value   = ScheduleObj.ScheduleCompletionDate.ToString("D");

                        if (CurriculumCourseEnrollmentObj.LookupEnrollmentProgressStateID == (int)Common.Enum.EnumEnrollmentProgressStates.In_Progress)
                        {
                            switch ((EnumScheduleStatuses)CurriculumCourseEnrollmentObj.Schedules.FirstOrDefault().LookupScheduleStatus.ScheduleStatusID)
                            {
                            case EnumScheduleStatuses.Reserved:
                                row.Cells[colAddEditCourseReport.Index].Value = "[ Confirm Reservation ]";
                                row.Cells[colAddEditCourseReport.Index].Tag   = "ConfirmReservation";
                                row.Cells[colScheduleConfirmed.Index].Value   = "N";
                                break;

                            case EnumScheduleStatuses.Confirmed:
                                row.Cells[colAddEditCourseReport.Index].Value = "[ Complete Report ]";
                                row.Cells[colAddEditCourseReport.Index].Tag   = "CompleteReport";
                                row.Cells[colScheduleConfirmed.Index].Value   = "Y";
                                break;
                            }

                            //colAddEditCourseReport
                        }
                        else if (CurriculumCourseEnrollmentObj.LookupEnrollmentProgressStateID == (int)Common.Enum.EnumEnrollmentProgressStates.Complete)
                        {
                            row.Cells[colAddEditCourseReport.Index].Value = "[ Update Report ]";
                            row.Cells[colAddEditCourseReport.Index].Tag   = "UpdateReport";
                        }
                    }
                    else
                    {
                        /*TO-DO
                         * Must Sort out the Squencing for if a course is required to be re scheduled
                         * ****************************************************************************/

                        /*Course  Not Yet Scheduled
                         * **************************/
                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Value = "[ Schedule Course ]";
                        row.Cells[colInProgressSelectedCourseMustSchedule.Index].Tag   = "SCHEDULE";
                        //row.Cells[colInProgressSelectedCourseMustSchedule.Index].Tag = "EDIT";
                        row.Cells[colSelectedEnrollemntStartDate.Index].Value = "Not Yet Scheduled";
                        row.Cells[colSelectedEnrollemntEndDate.Index].Value   = "Not Yet Scheduled";
                        row.Cells[colScheduleConfirmed.Index].Value           = "(NA)";
                    }
                }
            }
        }
Exemple #14
0
 public frmSchedulingDurationAdjustment(CurriculumCourseEnrollment CurrentCourseEnrollment)
 {
     this.CurrentCourseEnrollment = CurrentCourseEnrollment;
     InitializeComponent();
 }
Exemple #15
0
        private void frmApprenticeshipEnrollmentForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MustSaveItems)
            {
                using (var Dbconnection = new MCDEntities())
                {
                    /*Step 1 Begin - Saves Main Enrollment*/
                    CurrentEnrollments = new Enrollment();
                    Dbconnection.CurriculumEnquiries.Attach(CurrentCurriculumEnquiry);

                    EnumSectionalEnrollmentTypes EnrollmenTypeSelection;
                    if (radSelectSection13.Checked)
                    {
                        EnrollmenTypeSelection = EnumSectionalEnrollmentTypes.Section_13;
                    }
                    else
                    {
                        EnrollmenTypeSelection = EnumSectionalEnrollmentTypes.Section_28;
                    }

                    CurrentEnrollments.EnrolmentParentID = 0;
                    CurrentEnrollments.LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.In_Progress;
                    CurrentEnrollments.CurriculumID   = CurrentCurriculumEnquiry.CurriculumID;
                    CurrentEnrollments.IndividualID   = CurrentSelectedStudent.StudentID;
                    CurrentEnrollments.DateIntitiated = DateTime.Now;
                    CurrentEnrollments.LookupEnrollmentProgressStateID = (int)EnrollmenTypeSelection;

                    CurrentCurriculumEnquiry.Enrollments.Add(CurrentEnrollments);

                    Dbconnection.SaveChanges();
                    /*End Step 1 */

                    /*Step 2 Get PreRequiestes Courses and and load them with the main enrollment*/

                    List <CurriculumPrequisiteCourse> CPC = (from a in Dbconnection.CurriculumPrequisiteCourses
                                                             where a.CurriculumID == CurrentCurriculumEnquiry.CurriculumID
                                                             select a)
                                                            .Include("CurriculumCourse")
                                                            .ToList <CurriculumPrequisiteCourse>();

                    foreach (CurriculumPrequisiteCourse CurrentCPC in CPC)
                    {
                        Enrollment PreRequisisteCourseEnrollment = new Enrollment
                        {
                            EnrolmentParentID = CurrentEnrollments.EnrollmentID,
                            LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.In_Progress,
                            CurriculumID   = CurrentCPC.CurriculumCourse.CurriculumID,
                            IndividualID   = CurrentSelectedStudent.StudentID,
                            DateIntitiated = DateTime.Now
                        };

                        //CurrentCurriculumEnquiry.Enrollments.Add(PreRequisisteCourseEnrollment);
                        Dbconnection.Enrollments.Add(PreRequisisteCourseEnrollment);
                        Dbconnection.SaveChanges();

                        CurriculumCourseEnrollment CCE = new CurriculumCourseEnrollment
                        {
                            EnrollmentID       = PreRequisisteCourseEnrollment.EnrollmentID,
                            CurriculumCourseID = CurrentCPC.CurriculumCourse.CurriculumCourseID
                        };
                        Dbconnection.CurriculumCourseEnrollments.Add(CCE);
                        Dbconnection.SaveChanges();
                    }

                    /* End Step 3*/

                    //foreach (File f in CurrentEnrollmentFormDocument)
                    //{
                    //    CurrentEnrollments.ApprienticeshipEnrollment.ApprenticeshipEnrollmentDocuments.Add(new ApprenticeshipEnrollmentDocument()
                    //    {
                    //        ImageID = f.ImageID,
                    //        EnrollmentID = CurrentEnrollments.EnrollmentID,
                    //        LookupEnrollentDocumentTypeID = (int)EnumEnrollentDocumentTypes.Enrollment_Documents
                    //    });
                    //}
                    //foreach (File f in CurrentIDDocument)
                    //{
                    //    CurrentEnrollments.ApprienticeshipEnrollment.ApprenticeshipEnrollmentDocuments.Add(new ApprenticeshipEnrollmentDocument()
                    //    {
                    //        ImageID = f.ImageID,
                    //        EnrollmentID = CurrentEnrollments.EnrollmentID,
                    //        LookupEnrollentDocumentTypeID = (int)EnumEnrollentDocumentTypes.ID_Documents
                    //    });
                    //}

                    Dbconnection.SaveChanges();
                    EquiryHistory hist = new EquiryHistory
                    {
                        EnquiryID  = CurrentCurriculumEnquiry.EnquiryID,
                        EmployeeID = CurrentEmployeeLoggedIn.EmployeeID,
                        LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enrollment_Student_Successfully_Enrolled,
                        DateEnquiryUpdated       = DateTime.Now,
                        EnquiryNotes             = "Enrollment Completed Successfully for the the Following Individual - " + CurrentSelectedStudent.Individual.FullName.ToString() + "\n Enquiry Ref# - " + CurrentCurriculumEnquiry.EnquiryID
                    };
                    Dbconnection.EquiryHistories.Add(hist);
                    int IsSaved = Dbconnection.SaveChanges();
                    IsSuccessfullySaved = true;
                };
            }
        }
        public frmAddNewApprenticeshipAssessmentReport(CurriculumCourseEnrollment CurrentlySelectedCurriculumCourseEnrollment)
        {
            this.CurrentlySelectedCurriculumCourseEnrollment = CurrentlySelectedCurriculumCourseEnrollment;
            AssessmentReportList = new List <AssessmentReport>();

            iCurrentPosition = 0;
            InitializeComponent();

            /*Loadup the Selected Assesment
             * *****************************/

            using (var Dbconnection = new MCDEntities())
            {
                CurrentlySelectedAssessment = (from a in Dbconnection.Assessments
                                               where a.CurriculumCourseEnrollmentID == this.CurrentlySelectedCurriculumCourseEnrollment.CurriculumCourseEnrollmentID
                                               select a)
                                              .Include(a => a.AssessmentModules)
                                              .Include(a => a.AssessmentModules.Select(b => b.CurriculumCourseModule))
                                              .Include(a => a.AssessmentModules.Select(b => b.CurriculumCourseModule.Module))
                                              .Include(a => a.AssessmentModules.Select(b => b.AssessmentModuleActivities))
                                              //.Include(a => a.AssessmentModules.Select(b => b.LookupPracticalAssessmentStatus.PracticalAssessmentStatus))
                                              .FirstOrDefault <Assessment>();
                if (CurrentlySelectedAssessment == null)
                {
                    CurrentlySelectedAssessment = new Assessment();
                    Schedule CurrentConfiguredSchedule = (from a in Dbconnection.Schedules
                                                          where a.CurriculumCourseEnrollmentID == this.CurrentlySelectedCurriculumCourseEnrollment.CurriculumCourseEnrollmentID
                                                          select a).FirstOrDefault <Schedule>();

                    /*Set the start and end date controls on the first page.
                     * ***************************************************/
                    CurrentlySelectedAssessment.AssessmentDateStarted        = CurrentConfiguredSchedule.ScheduleStartDate.Date;
                    CurrentlySelectedAssessment.AssessmentDateCompleted      = CurrentConfiguredSchedule.ScheduleCompletionDate.Date;
                    CurrentlySelectedAssessment.AssessmentDateSubmitted      = DateTime.Now;
                    CurrentlySelectedAssessment.CurriculumCourseEnrollmentID = this.CurrentlySelectedCurriculumCourseEnrollment.CurriculumCourseEnrollmentID;

                    foreach (CurriculumCourseModule CCM in (from a in Dbconnection.CurriculumCourseModules
                                                            where a.CurriculumCourseID == this.CurrentlySelectedCurriculumCourseEnrollment.CurriculumCourseID
                                                            select a)
                             .Include(a => a.Module)
                             .ToList <CurriculumCourseModule>())
                    {
                        CCM.ObjectState = Data.Models.Enum.EntityObjectState.Unchanged;
                        // CCM.CurriculumCours.Course
                        CurrentlySelectedAssessment.AssessmentModules.Add(new AssessmentModule()
                        {
                            CurriculumCourseModuleID      = CCM.CurriculumCourseModuleID,
                            PracticalAssessmentStatusID   = (int)Common.Enum.EnumPracticalAssessmentStatuses.Not_Yet_Competent,
                            TheoriticalAssessmentStatusID = (int)Common.Enum.EnumTheoriticalAssesmentStatuses.Not_Yet_Competent,
                            Notes                  = "",
                            AssessmentID           = 0,
                            CurriculumCourseModule = CCM
                        });
                    }

                    //foreach (AssessmentModule AM in CurrentlySelectedAssessment.AssessmentModules)
                    //{
                    //    Dbconnection.Entry(AM).Reference(a => a.LookupPracticalAssessmentStatus).Load();
                    //    Dbconnection.Entry(AM).Reference(a => a.LookupTheoriticalAssesmentStatus).Load();
                    //}

                    /***********************************************
                    * Load the Currently Loaded Course Name
                    * *********************************************/
                    lblSelectedCourseName.Text = (from a in Dbconnection.CurriculumCourses
                                                  where a.CurriculumCourseID == this.CurrentlySelectedCurriculumCourseEnrollment.CurriculumCourseID
                                                  select a).FirstOrDefault <CurriculumCourse>().Course.CourseName;
                }
            };

            /*END of Loading Assessment
            * ************************/
        }