Пример #1
0
        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 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;
            }
        }