private void metroButton1_Click(object sender, EventArgs e) { using (frmEnrollmentInProgressV2 frm = new frmEnrollmentInProgressV2()) { frm.CurrentEmployeeLoggedIn = CurrentEmployeeLoggedIn; frm.CurrentEnrollmentID = 5045; frm.ShowDialog(); } }
private void dgvInProgressCurriculumEnquiries_CellContentClick(object sender, DataGridViewCellEventArgs e) { Data.Models.Enquiry CurrentEnquiry = (Data.Models.Enquiry)enquiryInprogressBindingSource.Current; CurriculumEnquiry CE = (CurriculumEnquiry)dgvInProgressCurriculumEnquiries.Rows[e.RowIndex].DataBoundItem; switch (e.ColumnIndex) { case 1: if (CE.EnquiryStatusID != (int)EnumEnquiryStatuses.Enquiry_Closed) { DialogResult Rtn = MessageBox.Show("Are you sure that you wish to Close this Enquiry Item?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Rtn == DialogResult.Yes) { using (var Dbconnection = new MCDEntities()) { Dbconnection.CurriculumEnquiries.Attach(CE); CE.EnquiryStatusID = (int)EnumEnquiryStatuses.Enquiry_Closed; CE.LastUpdated = DateTime.Now; Dbconnection.Entry<CurriculumEnquiry>(CE).State = System.Data.Entity.EntityState.Modified; Dbconnection.SaveChanges(); EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Curriculum_Enquiry_Item_Closed, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Curriculum Enquiry Line Item Closed, Item Removed - " + CE.Curriculum.CurriculumName + "- For Enquiry Ref: " + CurrentEnquiry.EnquiryID }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); refreshInProgressEnquiry(CurrentSelectedEnquiryID); }; } } else { DialogResult Rtn = MessageBox.Show("Are you sure that you wish to Close this Enquiry Item?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Rtn == DialogResult.Yes) { using (var Dbconnection = new MCDEntities()) { Dbconnection.CurriculumEnquiries.Attach(CE); CE.EnquiryStatusID = (int)EnumEnquiryStatuses.Enrollment_In_Progress; CE.LastUpdated = DateTime.Now; Dbconnection.Entry<CurriculumEnquiry>(CE).State = System.Data.Entity.EntityState.Modified; Dbconnection.SaveChanges(); EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Curriculum_Enquiry_Item_Reinstated, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Curriculum Enquiry Line Item Reinstated, Item Reinstated - " + CE.Curriculum.CurriculumName + "- For Enquiry Ref: " + CurrentEnquiry.EnquiryID }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); refreshInProgressEnquiry(CurrentSelectedEnquiryID); }; } } break; case 6: //if (CE.Curriculum.DepartmentID == (int)EnumDepartments.Apprenticeship) //{ if (((Data.Models.Enquiry)enquiryInprogressBindingSource.Current).InitialConsultationComplete) { //gbInProgressEnquiryEnrrolmentQueries.Enabled = true; DialogResult Rtn = MessageBox.Show("Do you have a copy of the individuals ID document or relevant details, These details are rquired to process initial enrollment! Else Select No and send an email Notification to the contact requesting these details.", "ID Document Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Rtn == DialogResult.Yes) { using (var Dbconnection = new MCDEntities()) { Dbconnection.CurriculumEnquiries.Attach(CE); if (!(Dbconnection.Entry(CE).Collection(a => a.Enrollments).IsLoaded)) { Dbconnection.Entry(CE).Collection(a => a.Enrollments).Load(); } }; if (CE.EnrollmentQuanity > CE.Enrollments.Count) { using (frmApprenticeshipEnrollmentFormV2 frm = new frmApprenticeshipEnrollmentFormV2()) { frm.CurrentCurriculumEnquiry = CE; frm.ShowDialog(); curriculumEnquiryInprogressBindingSource.ResetCurrentItem(); //this.refreshInProgressEnquiry(CurrentSelectedEnquiryID); if (frm.IsSuccessfullySaved) { DialogResult Rtn1 = MessageBox.Show("Do you wish to process this new enrollment now?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Rtn1 == DialogResult.Yes) { using (frmEnrollmentInProgressV2 innerFrm = new frmEnrollmentInProgressV2()) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; innerFrm.CurrentEquiryID = this.CurrentSelectedEnquiryID; innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; innerFrm.CurrentEnrollmentID = frm.CurrentEnrollments.EnrollmentID; innerFrm.ShowDialog(); } //using (frmEnrolmmentInprogress frmInner = new frmEnrolmmentInprogress()) //{ // frmInner.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; // frmInner.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; // // frmStudentCourseEnrollmentV2 frm7 = new frmStudentCourseEnrollmentV2(); // frmInner.ShowDialog(); //} } } } } } } else { MessageBox.Show("Initial Consultation Is Not Yet Completed, Please complete before proceeding with the enrollment!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); //gbInProgressEnquiryEnrrolmentQueries.Enabled = false; } //} break; case 7: //ensure that the Enrollments are refershed using (var Dbconnection = new MCDEntities()) { Dbconnection.CurriculumEnquiries.Attach(CE); if (!(Dbconnection.Entry(CE).Collection(a => a.Enrollments).IsLoaded)) { Dbconnection.Entry(CE).Collection(a => a.Enrollments).Load(); } }; //IF any enrollments exists then open Selection list else Do Nothing. if (CE.Enrollments.Count > 0) { //Open thje list of linked Enrollments that are in progress using (frmEnrollmentSelectionForEquiry frm = new frmEnrollmentSelectionForEquiry()) { frm.SelectedCurriculumEnquiryID = CE.CurriculumEnquiryID; frm.ShowDialog(); if (frm.SelectedEnrollmentID != 0) { using (frmEnrollmentInProgressV2 innerFrm = new frmEnrollmentInProgressV2()) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; innerFrm.CurrentEquiryID = this.CurrentSelectedEnquiryID; innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; innerFrm.CurrentEnrollmentID = frm.SelectedEnrollmentID; innerFrm.ShowDialog(); } } } } else { MessageBox.Show("There are currently no enrollments for this enquiry.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } }