private void btnSave_Click(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { Dbconnection.Enquiries.Attach(CurrentSelectedEnquiry); //foreach (CurriculumEnquiry CE in CurrentSelectedEnquiry.CurriculumEnquiries) //{ // CE.EnquiryStatusID = (int)EnumEnquiryStatuses.Enquiry_Closed; //} CurrentSelectedEnquiry.EnquiryStatusID = (int)EnumEnquiryStatuses.Enquiry_Closed; Dbconnection.SaveChanges(); string EnquiryClosedText = "None Reason Was Specified."; if (txtNotes.Text.Length > 0) { EnquiryClosedText = txtNotes.Text; } EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentSelectedEnquiry.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Equiry_Responded_And_Closed, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = EnquiryClosedText }; Dbconnection.EquiryHistories.Add(hist); Dbconnection.SaveChanges(); IsSuccessfullyClosedOff = true; } this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { string InitialConsultationText = "None or No Notes where documented."; if (txtNotes.Text.Length > 0) { InitialConsultationText = txtNotes.Text; } EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = this.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Initial_Consultation_Completed, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = InitialConsultationText }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); if (IsSaved > 0) { Dbconnection.Enquiries.Attach(CurrentEnquiry); CurrentEnquiry.InitialConsultationComplete = true; Dbconnection.Entry <Data.Models.Enquiry>(CurrentEnquiry).State = System.Data.Entity.EntityState.Modified; Dbconnection.SaveChanges(); } }; this.Close(); }
private void btnPropcessException_Click(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { try { Dbconnection.Enrollments.Attach(SelectedEnrollment); SelectedEnrollment.LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.Excempt; Dbconnection.Entry(SelectedEnrollment).State = System.Data.Entity.EntityState.Modified; Dbconnection.SaveChanges(); EquiryHistory hist = new EquiryHistory { EnquiryID = EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enrollment_Course_PreRequisite_Was_Except, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "For Enrollment : " + EnquiryID.ToString() + "\n\nThe following Curriculum: " + SelectedEnrollment.Curriculum.CurriculumName.ToString() + " Has Been Excempt.\n\nEnrollment Ref:\n" + SelectedEnrollment.EnrollmentID + "\n\nNotes:" + txtExceptionNotes.Text.ToString() }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); //SelectedEnrollment.LookupEnrollmentProgressState = null; Dbconnection.Entry(SelectedEnrollment).Reference("LookupEnrollmentProgressState").Load(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Close(); } }; }
private void btnEmailClient_Click(object sender, EventArgs e) { Enrollment EnrollmentObj = ((Enrollment)enrollmentBindingSource.Current); CurriculumEnquiry CurriculumEnquiryObj; Data.Models.Enquiry CurrentEnquiryObj; using (var Dbconnection = new MCDEntities()) { CurriculumEnquiryObj = (from a in Dbconnection.CurriculumEnquiries from b in a.Enrollments where b.EnrollmentID == EnrollmentObj.EnrollmentID && a.CurriculumID == EnrollmentObj.CurriculumID select a).FirstOrDefault <CurriculumEnquiry>(); CurrentEnquiryObj = (from a in Dbconnection.Enquiries where a.EnquiryID == CurriculumEnquiryObj.EnquiryID select a) .Include("Individuals") .Include("Individuals.ContactDetails") .FirstOrDefault <Data.Models.Enquiry>(); }; frmSendEmail frm = new frmSendEmail(); List <ContactDetail> CustomEmailPerson = (from a in CurrentEnquiryObj.Individuals from b in a.ContactDetails where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address select b).ToList <ContactDetail>(); //Sets the Email Address For the Currently Selected Contact For this Enquiry foreach (ContactDetail ConDetObj in CustomEmailPerson) { if (frm.txtTestingToAddress.Text.Length > 0) { frm.txtTestingToAddress.Text += ";"; } frm.txtTestingToAddress.Text += ConDetObj.ContactDetailValue; } frm.txtTestSubject.Text = "Enquiry No: ( " + CurrentEnquiryObj.EnquiryID + "-" + CurriculumEnquiryObj.CurriculumEnquiryID + " ) Enquiry Feed Back"; frm.txtTestMessage.Text = "Good Day \nThis is regarding the processing of your Enrollemnt - Ref: " + EnrollmentObj.EnrollmentID + "\n"; frm.ShowDialog(); if (frm.IsSent) { using (var Dbconnection = new MCDEntities()) { EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentEnquiryObj.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Custom_Email_Message_Sent, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Custom Message Sent To Client Via Email\nSubject of the Message was:\n\n{" + frm.txtTestSubject.Text + "}\n\nBody Of the Message read:\n" + frm.txtTestMessage.Text }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); }; } }
private void SaveEnquiry() { using (var Dbconnection = new MCDEntities()) { Dbconnection.Enquiries.Attach(CurrentEnquiry); Dbconnection.Entry(CurrentEnquiry).State = EntityState.Added; Dbconnection.SaveChanges(); foreach (CheckBox chk in flowLayoutPanelEquiryOrigion.Controls) { if (chk.Checked) { LookupEquiryOrigion LEO = new LookupEquiryOrigion(); LEO.EquiryOriginID = (int)chk.Tag; Dbconnection.LookupEquiryOrigions.Attach(LEO); CurrentEnquiry.LookupEquiryOrigions.Add(LEO); } } Dbconnection.SaveChanges(); /*Adds Each of the Curriculum Selected for this equiry*/ //foreach (CurriculumEnquiry CE in SelectedEnquiryCurriculum) //{ // CE.Curriculum = null; // CE.LookupEnquiryStatus = null; // CE.Enquiry = null; // CE.EnquiryID = CurrentEnquiry.EnquiryID; // CE.InitialCurriculumEnquiryDocumentationSent = false; // CE.LastUpdated = DateTime.Now; // CE.EnquiryStatusID = CE.EnquiryStatusID; // //CurrentEnquiry.CurriculumEnquiries.Add(CE); //} EquiryHistory AddingContactDetailsHistory = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Company_Contact_Selection, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = txtSelectedContactNotes.Text.ToString() }; EquiryHistory AddingSelectedCurriculumHistory = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Curriculum_Selection, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = txtSelectedCurriculumNotes.Text.ToString() }; CurrentEnquiry.EquiryHistories.Add(AddingContactDetailsHistory); CurrentEnquiry.EquiryHistories.Add(AddingSelectedCurriculumHistory); Dbconnection.SaveChanges(); //Dbconnection.Entry(CurrentEnquiry).Collection("CurriculumEnquiries").Load(); //foreach (CurriculumEnquiry CE in CurrentEnquiry.CurriculumEnquiries) //{ // Dbconnection.CurriculumEnquiries.Attach(CE); // Dbconnection.Entry(CE).Reference("Curriculum").Load(); // Dbconnection.Entry(CE).Reference("Curriculum.LookupDepartment").Load(); // //foreach (Curriculum in CE.Curriculum.LookupDepartment) // //Dbconnection.Entry(CE).Collection("Curriculum.LookupDepartment").Load(); //} //Dbconnection.Entry(CurrentEnquiry).Reference("CurriculumEnquiries.Curriculum.LookupDepartment").Load(); }; sendEmailNotifications(); }
private void dgvNewEnquiryTab_CurriculumEnquiry_CellContentClick(object sender, DataGridViewCellEventArgs e) { //colNewEnquiry_Curriculum.Name //dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].Cells[e.ColumnIndex]. //row.Cells[colNewEnquiry_Curriculum.Index].Value // MessageBox.Show("Col Index : " + dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()); CurriculumEnquiry CE = (CurriculumEnquiry)dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].DataBoundItem; Data.Models.Enquiry CurrentEnquiryObj = (Data.Models.Enquiry)NewEnquiryTab_NewEnquiryBindingSource.Current; switch (e.ColumnIndex) { case 1: //Close the enquiry DialogResult Rtn = MessageBox.Show("Are you Sure that you wish to Close this Enquiry?", "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(); Dbconnection.CurriculumEnquiries.Remove(CE); }; } if (curriculumEnquiriesBindingSource.Count == 0) { refreshNewEnquiry(); } break; //Accept the Enquiry case 2: using (frmSendEmail frm = new frmSendEmail()) { List <ContactDetail> CustomEmailPerson = (from a in CurrentEnquiryObj.Individuals from b in a.ContactDetails where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address select b).ToList <ContactDetail>(); //Sets the Email Address For the Currently Selected Contact For this Enquiry foreach (ContactDetail ConDetObj in CustomEmailPerson) { if (frm.txtTestingToAddress.Text.Length > 0) { frm.txtTestingToAddress.Text += ";"; } frm.txtTestingToAddress.Text += ConDetObj.ContactDetailValue; } frm.txtTestSubject.Text = "Enquiry No: ( " + CE.EnquiryID + "-" + CE.CurriculumEnquiryID + " ) Enquiry Feed Back"; frm.ShowDialog(); using (var Dbconnection = new MCDEntities()) { EquiryHistory hist = new EquiryHistory { EnquiryID = CE.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Custom_Email_Message_Sent, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Custom Message Sent To Client Via Email\nSubject of the Message was:\n\n{" + frm.txtTestSubject.Text + "}\n\nBody Of the Message read:\n" + frm.txtTestMessage.Text }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); if (IsSaved > 0) { Dbconnection.CurriculumEnquiries.Attach(CE); CE.LastUpdated = DateTime.Now; Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified; Dbconnection.SaveChanges(); } dgvNewEnquiryTab_CurriculumEnquiry.Refresh(); }; } break; //Close the Equiry case 3: frmEnquiryViewHistory frm5 = new frmEnquiryViewHistory(); frm5.CurrentEnquiryID = CurrentEnquiryObj.EnquiryID; frm5.ShowDialog(); break; case 8: if (CurrentEnquiryObj.InitialConsultationComplete) { if (!CE.InitialCurriculumEnquiryDocumentationSent) { frmInitailDocumentation frm3 = new frmInitailDocumentation(); frm3.ShowDialog(); if (!frm3.IsCanceled) { if (frm3.UseEmail) { frmSendEmail frm1 = new frmSendEmail(); List <ContactDetail> you = (from a in CurrentEnquiryObj.Individuals from b in a.ContactDetails where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address select b).ToList <ContactDetail>(); //Sets the Email Address For the Currently Selected Contact For this Enquiry foreach (ContactDetail ConDetObj in you) { if (frm1.txtTestingToAddress.Text.Length > 0) { frm1.txtTestingToAddress.Text += ";"; } frm1.txtTestingToAddress.Text += ConDetObj.ContactDetailValue; } frm1.txtTestSubject.Text = "Enquiry No: ( " + CurrentEnquiryObj.EnquiryID + "-" + CE.CurriculumEnquiryID + " ) Enquiry Feed Back"; using (var Dbconnection = new MCDEntities()) { List <MessageTemplate> MT = (from a in Dbconnection.MessageTemplates from b in a.Files where a.ProcessStepID == (int)EnumProcessSteps.Enquiry__Apprenticeship__Step_1__Documentation_To_Send select a).ToList <MessageTemplate>(); MessageTemplate CurrentMessageTemplate = MT.FirstOrDefault <MessageTemplate>(); string Mess = "Good Day " + txtNewEnquiryTab_ContactPersonTitle.Text + " " + txtNewEnquiryTab_ContactPersonFirstName.Text + " " + txtNewEnquiryTab_ContactPersonLastName.Text + "\n \n"; frm1.txtTestMessage.Text = "Please Reference the Following Line Equiry Number when returning any documentation: \n" + "Enquiry No " + CE.EnquiryID + "-" + CE.CurriculumEnquiryID + "\n" + Mess + CurrentMessageTemplate.Message; foreach (MessageTemplate MTObj in MT) { foreach (Data.Models.File FileObj in MTObj.Files) { frm1.AttachmentsUsingDbImageFileID.Add(FileObj.FileID); } } }; frm1.ShowDialog(); using (var Dbconnection = new MCDEntities()) { EquiryHistory hist = new EquiryHistory { EnquiryID = CE.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Initial_Documentation_Sent, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Documentation Sent To Client Via Email" }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); if (IsSaved > 0) { Dbconnection.CurriculumEnquiries.Attach(CE); CE.InitialCurriculumEnquiryDocumentationSent = true; CE.LastUpdated = DateTime.Now; Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified; Dbconnection.SaveChanges(); } dgvNewEnquiryTab_CurriculumEnquiry.Refresh(); }; } else { using (var Dbconnection = new MCDEntities()) { EquiryHistory hist = new EquiryHistory { EnquiryID = CE.EnquiryID, EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Initial_Documentation_Sent, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Documentation Manually Given To Client" }; Dbconnection.EquiryHistories.Add(hist); int IsSaved = Dbconnection.SaveChanges(); if (IsSaved > 0) { Dbconnection.CurriculumEnquiries.Attach(CE); CE.InitialCurriculumEnquiryDocumentationSent = true; CE.LastUpdated = DateTime.Now; Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified; Dbconnection.SaveChanges(); dgvNewEnquiryTab_CurriculumEnquiry.Refresh(); } }; } } } else { MessageBox.Show("Documentation Already Sent,\nUse Send Mail Option to send additional Mail.\nSee History For Details.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Initial Contsultation Not Completed!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case 10: if (CE.Curriculum.DepartmentID == (int)EnumDepartments.Apprenticeship) { if (CE.EnrollmentQuanity >= CE.Enrollments.Count) { frmApprenticeshipEnrollmentFormV2 frm6 = new frmApprenticeshipEnrollmentFormV2(); frm6.CurrentCurriculumEnquiry = CE; curriculumEnquiriesBindingSource.ResetItem(e.RowIndex); frm6.ShowDialog(); //Check to see if the amoount required to be enrolled equal the amount that have been enrolled. //if (CE.EnrollmentQuanity <= CE.Enrollments.Count) //{ // 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(); // Dbconnection.CurriculumEnquiries.Remove(CE); // int currentIndex = NewEnquiryTab_NewEnquiryBindingSource.Position; // refreshNewEnquiry(); // NewEnquiryTab_NewEnquiryBindingSource.Position = currentIndex; // dgvNewEnquiryTab_CurriculumEnquiry.Refresh(); // }; //} DialogResult Rtn1 = MessageBox.Show("Do you wish to View the Enrollment,and course selection?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Rtn1 == DialogResult.Yes) { using (frmEnrolmmentInprogress frm = new frmEnrolmmentInprogress()) { frm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; frm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; // frmStudentCourseEnrollmentV2 frm7 = new frmStudentCourseEnrollmentV2(); frm.ShowDialog(); } } } } //frm6.CurrentEnrollments.ApprienticeshipEnrollment.(CE); break; case 11: using (frmEnrollmentSelectionForEquiry frm = new frmEnrollmentSelectionForEquiry()) { frm.SelectedCurriculumEnquiryID = CE.CurriculumEnquiryID; frm.ShowDialog(); if (frm.SelectedEnrollmentID != 0) { using (frmEnrolmmentInprogress innerFrm = new frmEnrolmmentInprogress()) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; innerFrm.CurrentEnrollmentID = frm.SelectedEnrollmentID; innerFrm.ShowDialog(); } } } break; } }
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 (true) //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 Re-Instate 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 (true) //CE.EnrollmentQuanity > CE.Enrollments.Where(a => a.EnrolmentParentID == 0).Count()) { using (frmApprenticeshipEnrollmentFormV2 frm = new frmApprenticeshipEnrollmentFormV2(null, false)) { //frm.CurrentCurriculumEnquiry = CE; frm.ShowDialog(); //CE.Enrollments.Add(frm.CurrentEnrollment); 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 (frmEnrollmentProgress innerFrm = new frmEnrollmentProgress(frm.CurrentEnrollment.EnrollmentID)) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; innerFrm.CurrentEquiryID = this.CurrentSelectedEnquiryID; //innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; innerFrm.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 (true) //CE.Enrollments.Count > 0) { //Open thje list of linked Enrollments that are in progress using (frmEnrollmentSelectionForEquiry frm = new frmEnrollmentSelectionForEquiry(new Data.Models.Enquiry())) { frm.ShowDialog(); if (frm.SelectedEnrollmentID != 0) { using (frmEnrollmentProgress innerFrm = new frmEnrollmentProgress(frm.SelectedEnrollmentID)) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; innerFrm.CurrentEquiryID = this.CurrentSelectedEnquiryID; //innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; innerFrm.ShowDialog(); } } } } else { MessageBox.Show("There are currently no enrollments for this enquiry.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } }
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; }; } }
private void frmApprenticeshipEnrollmentFormV2_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.New_Enrollment; CurrentEnrollments.CurriculumID = CurrentCurriculumEnquiry.CurriculumID; CurrentEnrollments.IndividualID = CurrentSelectedStudent.StudentID; CurrentEnrollments.DateIntitiated = DateTime.Now; CurrentEnrollments.ApprienticeshipEnrollment = new ApprienticeshipEnrollment() { LookupSectionalEnrollmentTypeID = (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>(); //Get All The Possible Cuuriculum that for partof the Pre-Requisites List <int> PreRequisiteCurriculumID = (from a in CPC select a.CurriculumCourse.CurriculumID) .Distinct <int>() .ToList <int>(); //Create Enrollment for each possible Curriculum that that forms part of the list pre-requisite Courses. foreach (int CurriculumIDForPreRquisiteCourseEnrollment in PreRequisiteCurriculumID) { //Creates a Enrollment Enrty for the Curriculum Enrollment PreRequisisteCourseEnrollment = new Enrollment { EnrolmentParentID = CurrentEnrollments.EnrollmentID, LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.In_Progress, CurriculumID = CurriculumIDForPreRquisiteCourseEnrollment, IndividualID = CurrentSelectedStudent.StudentID, DateIntitiated = DateTime.Now }; Dbconnection.Enrollments.Add(PreRequisisteCourseEnrollment); Dbconnection.SaveChanges(); //links each pre-Requisite Course to the Curriculum Linked. foreach (CurriculumCourse CurriculumCourseToLink in (from a in CPC where a.CurriculumCourse.CurriculumID == CurriculumIDForPreRquisiteCourseEnrollment select a.CurriculumCourse) .Distinct <CurriculumCourse>(). ToList <CurriculumCourse>()) { Dbconnection.CurriculumCourseEnrollments.Add(new CurriculumCourseEnrollment { CurriculumCourseID = CurriculumCourseToLink.CurriculumCourseID, EnrollmentID = PreRequisisteCourseEnrollment.EnrollmentID, CourseCost = CurriculumCourseToLink.Cost // Set the linked course to the default Cost for the course }); } //Saves the sub set of Pre-Requisite Curriculum and linked courses. Dbconnection.SaveChanges(); } ///* End Step 3*/ foreach (File f in CurrentEnrollmentFormDocument) { CurrentEnrollments.EnrollmentDocuments.Add(new EnrollmentDocument() { FileID = f.FileID, EnrollmentID = CurrentEnrollments.EnrollmentID, LookupEnrollmentDocumentTypeID = (int)EnumEnrollentDocumentTypes.Enrollment_Documents }); } foreach (File f in CurrentIDDocument) { CurrentEnrollments.EnrollmentDocuments.Add(new EnrollmentDocument() { FileID = f.FileID, EnrollmentID = CurrentEnrollments.EnrollmentID, LookupEnrollmentDocumentTypeID = (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 = "Initial 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; }; } }
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) { 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 (frmApprenticeshipEnrollmentForm frm = new frmApprenticeshipEnrollmentForm()) { 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 (frmEnrolmmentInprogress frmInner = new frmEnrolmmentInprogress()) { frmInner.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; frmInner.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID; // frmStudentCourseEnrollmentV2 frm7 = new frmStudentCourseEnrollmentV2(); frmInner.ShowDialog(); } } } } } } 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 (frmEnrolmmentInprogress innerFrm = new frmEnrolmmentInprogress()) { innerFrm.CurrentEmployeeLoggedIn = this.CurrentEmployeeLoggedIn; 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; } }
private void frmApprenticeshipEnrollmentFormV2_FormClosing(object sender, FormClosingEventArgs e) { if (MustSaveItems) { using (var Dbconnection = new MCDEntities()) { using (System.Data.Entity.DbContextTransaction dbTran = Dbconnection.Database.BeginTransaction()) { try { //CRUD Operations ///Step 1 Begin - Saves Main Enrollment Dbconnection.Students.Attach(CurrentEnrollment.StudentEnrollment.Student); Dbconnection.Entry(CurrentEnrollment.ApprienticeshipEnrollment).State = EntityState.Added; Dbconnection.Entry(CurrentEnrollment).State = EntityState.Added; Dbconnection.Entry(CurrentEnrollment.StudentEnrollment).State = EntityState.Added; Dbconnection.Entry(CurrentEnrollment.StudentEnrollment.Student).State = EntityState.Unchanged; foreach (EnrollmentDocument ED in CurrentEnrollment.EnrollmentDocuments) { Dbconnection.Entry(ED).State = EntityState.Added; Dbconnection.Entry(ED.File).State = EntityState.Added; // ED.LookupEnrollentDocumentType = null; Dbconnection.LookupEnrollentDocumentTypes.Attach(ED.LookupEnrollentDocumentType); Dbconnection.Entry(ED.LookupEnrollentDocumentType).State = EntityState.Unchanged; } CurrentEnrollment.ProgressFileID = Impendulo.Common.Verifiction.OfProgressFiles.VerifyStudentProgressFile(CurrentEnrollment.StudentEnrollment.StudentID); Dbconnection.Enrollments.Add(CurrentEnrollment); Dbconnection.SaveChanges(); if (IsCompanyEnrollment) { Common.Verifiction.OfProgressFiles.VerifyCompanyStudentProgressFile(CurrentEnrollment.StudentEnrollment.StudentID, this.CompanyProgressFileID); } //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 == CurrentEnquiry.CurriculumID select a) .Include("CurriculumCourse") .ToList <CurriculumPrequisiteCourse>(); //Get All The Possible Cuuriculum that for partof the Pre-Requisites List <int> PreRequisiteCurriculumID = (from a in CPC select a.CurriculumCourse.CurriculumID) .Distinct <int>() .ToList <int>(); //Create Enrollment for each possible Curriculum that that forms part of the list pre-requisite Courses. foreach (int CurriculumIDForPreRquisiteCourseEnrollment in PreRequisiteCurriculumID) { //Creates a Enrollment Enrty for the Curriculum Data.Models.Enrollment PreRequisisteCourseEnrollment = new Data.Models.Enrollment { EnrolmentParentID = CurrentEnrollment.EnrollmentID, EnquiryID = this.CurrentEnquiry.EnquiryID, ProgressFileID = CurrentEnrollment.ProgressFileID, LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.New_Enrollment, CurriculumID = CurriculumIDForPreRquisiteCourseEnrollment, StudentEnrollment = new StudentEnrollment() { StudentID = CurrentEnrollment.StudentEnrollment.StudentID, DateUpdated = DateTime.Now }, DateIntitiated = DateTime.Now, EnrollmentExcempt = false }; Dbconnection.Enrollments.Add(PreRequisisteCourseEnrollment); Dbconnection.SaveChanges(); //links each pre-Requisite Course to the Curriculum Linked. foreach (CurriculumCourse CurriculumCourseToLink in (from a in CPC where a.CurriculumCourse.CurriculumID == CurriculumIDForPreRquisiteCourseEnrollment select a.CurriculumCourse) .Distinct <CurriculumCourse>(). ToList <CurriculumCourse>()) { Dbconnection.CurriculumCourseEnrollments.Add(new CurriculumCourseEnrollment { LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.New_Enrollment, CurriculumCourseID = CurriculumCourseToLink.CurriculumCourseID, EnrollmentID = PreRequisisteCourseEnrollment.EnrollmentID, CourseCost = CurriculumCourseToLink.Cost // Set the linked course to the default Cost for the course }); } //Saves the sub set of Pre-Requisite Curriculum and linked courses. Dbconnection.SaveChanges(); } EquiryHistory hist = new EquiryHistory { EnquiryID = CurrentEnquiry.EnquiryID, EmployeeID = CurrentEmployeeLoggedIn.EmployeeID, LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enrollment_Student_Successfully_Enrolled, DateEnquiryUpdated = DateTime.Now, EnquiryNotes = "Initial Enrollment Completed Successfully for the the Following Individual - " + CurrentEnrollment.StudentEnrollment.Student.Individual.FullName.ToString() + "\n Enquiry Ref# - " + CurrentEnquiry.EnquiryID }; Dbconnection.EquiryHistories.Add(hist); ////saves all above operations within one transaction Dbconnection.SaveChanges(); //commit transaction dbTran.Commit(); IsSuccessfullySaved = true; } 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); MetroMessageBox.Show(this, error.ErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { //MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); MetroMessageBox.Show(this, ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Rollback transaction if exception occurs dbTran.Rollback(); } } }; } }