private void populateLinkedModuleActivities() { using (var DbConnection = new MCDEntities()) { List<Activity> LinkedModuleActivities = (from a in DbConnection.Activities from b in a.CurriculumCourseModules where b.ModuleID == this.ModuleID && b.CurriculumCourseID == this.CurriculumCourseID select a).ToList<Activity>(); bindingSourceLinkedModuleActivities.DataSource = (from a in LinkedModuleActivities select a).ToList<Activity>(); } }
public frmEnrollmentCourseSelection() { InitializeComponent(); if (CurrentEnrollemnt == null) { using (var Dbconnection = new MCDEntities()) { CurrentEnrollemnt = (from a in Dbconnection.Enrollments .Include("CurriculumCourseEnrollments") .Include("CurriculumCourseEnrollments.CurriculumCourse") orderby a.DateIntitiated descending select a).FirstOrDefault <Enrollment>(); }; } }
private void btnLinkModule_Click(object sender, EventArgs e) { using (var DbConnection = new MCDEntities()) { CurriculumCourseModule TDCETM = new CurriculumCourseModule() { CurriculumCourseID = this.CurriculumCourseID, ModuleID = Convert.ToInt32(lstAvailableModules.SelectedValue) }; DbConnection.CurriculumCourseModules.Add(TDCETM); DbConnection.SaveChanges(); }; this.populateAvailableModules(); this.populateLinkedModules(); }
private void populateLinkedModules() { using (var DbConnection = new MCDEntities()) { List <Module> LinkedModules = (from a in DbConnection.Modules from b in a.CurriculumCourseModules where b.CurriculumCourseID == this.CurriculumCourseID select a).ToList <Module>(); this.bindingSourceLinkedModules.DataSource = (from a in LinkedModules orderby a.ModuleName select a).ToList <Module>(); }; this.setAddAndRemoveButtons(); }
public static Boolean RemoveFile(int FileID) { Boolean Rtn = false; using (var Dbconnection = new MCDEntities()) { Data.Models.File f = (from a in Dbconnection.Files where a.FileID == FileID select a).FirstOrDefault <Data.Models.File>(); Dbconnection.Files.Remove(f); Dbconnection.SaveChanges(); Rtn = true; }; return(Rtn); }
private void populateCurriculumCourses(int _CurriculumID) { using (var Dbconnection = new MCDEntities()) { List <CurriculumCourse> configuredCoures = (from a in Dbconnection.GetCurriculumCourseInOrder(_CurriculumID) where a.CurriculumID == _CurriculumID select a) .ToList <CurriculumCourse>(); curriculumCourseBindingSource.DataSource = (from a in configuredCoures where a.Course.CourseName.ToLower().Contains(txtCurriculumCourseFilterCriteria.Text) select a).ToList <CurriculumCourse>(); }; }
private void populateCourses() { using (var Dbconnection = new MCDEntities()) { if (curriculumBindingSource.Count > 0) { int CurriculumID = Convert.ToInt32(this.cboCuriculum.SelectedValue); courseBindingSource.DataSource = (from a in Dbconnection.Courses from b in a.CurriculumCourses where b.CurriculumID == CurriculumID select a).ToList <Course>(); } }; }
private void btnAddTrainingDepartment_Click(object sender, EventArgs e) { using (var DbConnection = new MCDEntities()) { //TrainingDepartment newTrainDep = new TrainingDepartment() //{ // DepartmentID = this.DepartmentID, // TrainingDepartmentName = this.txtAddDepartment.Text.ToString() //}; //DbConnection.TrainingDepartments.Add(newTrainDep); DbConnection.SaveChanges(); this.Close(); } }
private void Form3_Load(object sender, EventArgs e) { Venue x = new Venue() { VenueID = 0, VenueName = "", VenueMaxCapacity = 0 }; using (var Dbconnection = new MCDEntities()) { Dbconnection.Venues.Add(x); Dbconnection.SaveChanges(); }; }
private void btnDeleteMessageTemplate_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Are You Sure?", "Template Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (res == DialogResult.Yes) { using (var Dbconnection = new MCDEntities()) { Dbconnection.MessageTemplates.Attach(CurrentMessageTemplate); Dbconnection.MessageTemplates.Remove(CurrentMessageTemplate); Dbconnection.SaveChanges(); refreshMessage(); }; } }
private void populateCompanyContacts() { using (var Dbconnection = new MCDEntities()) { companyContactsBindingSource.DataSource = new CustomSortableBindingList <CompanyContacts>( (from a in CurrentlySelectedCompany.Individuals select new CompanyContacts() { IndividualID = a.IndividualID, FulName = a.FullName, Title = a.LookupTitle.Title }).ToList <CompanyContacts>() ); }; }
private void frmAddTrainingDepartment_Load(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { costingModelBindingSource.DataSource = Dbconnection.CostingModels.ToList <CostingModel>(); }; if (IsUpdating) { cboCostingModel.SelectedValue = this.CostingModelID; txtAddCurriculum.Text = this.CurriculumName; chkIsSequencedCourse.Checked = this.IsSquenced; this.btnAddTrainingDepartment.Text = "Update"; } }
private void populateLinkedModuleActivities() { using (var DbConnection = new MCDEntities()) { int ModID = Convert.ToInt32(cboModules.SelectedValue); List <Activity> LinkedModuleActivities = (from a in DbConnection.Activities from b in a.CurriculumCourseModules where b.ModuleID == this.ModuleID && b.CurriculumCourseID == this.CurriculumCourseID select a).ToList <Activity>(); bindingSourceLinkedModuleActivities.DataSource = (from a in LinkedModuleActivities orderby a.ActivityCode select a).ToList <Activity>(); } }
private void Form1_Load(object sender, EventArgs e) { DbConnection = new MCDEntities(); _IsLoading = true; populateTrainingDepartments(); populateTrainingDepartmentCourses(Convert.ToInt32(lstTrainingDepartments.SelectedValue)); populateCourses(Convert.ToInt32(lstTrainingDepartmentCoures.SelectedValue)); int _CourseID = Convert.ToInt32(dgvCoures.SelectedRows[0].Cells[0].Value); populateCourseEnrollmentTypes(_CourseID); populateSetaCourseAccreditations(_CourseID); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { using (var DbConnection = new MCDEntities()) { Module mod = new Module() { ModuleName = txtModuleBindingNavigator.Text.ToString(), DepartmentID = Convert.ToInt32(cboDepartments.SelectedValue) }; DbConnection.Modules.Add(mod); DbConnection.SaveChanges(); } this.txtModuleBindingNavigator.Text = ""; this.populateAvailableModules(); }
private void populateTrainingDepartmentCourses(int _TrainingDepartmentID) { using (var DbConnection = new MCDEntities()) { string SearchString = txtCourseFilterCriteria.Text.ToString(); //List<TrainingDepartmentCourse> trainingDepartmentCourseResults = (from a in DbConnection.TrainingDepartmentCourses // where a.TrainingDepartmentID == _TrainingDepartmentID // orderby a.TrainingDepartmentCourseName ascending // select a).ToList<TrainingDepartmentCourse>(); //trainingDepartmentCourseBindingSource.DataSource = (from a in trainingDepartmentCourseResults // where a.TrainingDepartmentCourseName.ToLower().Contains(SearchString.ToLower()) // select a).ToList<TrainingDepartmentCourse>(); } }
private List <Data.Models.Enquiry> getPrivateEnquiry(DateTime FromDate, DateTime Todate, EnumDepartments aDepartment) { List <Data.Models.Enquiry> Rtn = new List <Data.Models.Enquiry>(); using (var Dbconnection = new MCDEntities()) { //lblPrivateEquiries.Text Rtn = (from a in Dbconnection.Enquiries from b in a.Individuals where a.EnquiryDate >= FromDate && a.EnquiryDate <= Todate && b.Companies.Count == 0 select a).ToList <Data.Models.Enquiry>(); } return(Rtn); }
private void btnLinkModule_Click(object sender, EventArgs e) { using (var DbConnection = new MCDEntities()) { //TrainingDepartmentCourseEnrollmentTypeModule TDCETM = new TrainingDepartmentCourseEnrollmentTypeModule() //{ // TrainingDepartmentCourseEnrollmentTypeMetaDataID = this.TrainingDepartmentCourseEnrollmentTypeMetaDataID, // ModuleID = Convert.ToInt32(lstAvailableModules.SelectedValue) //}; //DbConnection.TrainingDepartmentCourseEnrollmentTypeModules.Add(TDCETM); //DbConnection.SaveChanges(); }; this.populateAvailableModules(); this.populateLinkedModules(); }
private void picSearchStudents_Click(object sender, EventArgs e) { List <Student> StudentExcemptionList = new List <Student>(); using (var Dbconnection = new MCDEntities()) { //Loadds the associated Collections in this case the Enrollment with their associated Students that are enrolled. Dbconnection.CurriculumEnquiries.Attach(CurrentCurriculumEnquiry); //Load all enrollments that linked to the Enquiry Item. Dbconnection.Entry(CurrentCurriculumEnquiry).Collection(a => a.Enrollments).Load(); foreach (Enrollment EnrollmentObj in CurrentCurriculumEnquiry.Enrollments) { //Load the student linked to the enrollment Dbconnection.Entry(EnrollmentObj).Reference(a => a.Student).Load(); StudentExcemptionList.Add(EnrollmentObj.Student); } }; using (frmStudentSearchForStudent frm = new frmStudentSearchForStudent()) { //Set the list of student that are already Enrolled for this Enquiry Item. frm.StudentExpceptionList = StudentExcemptionList; frm.ShowDialog(); if (frm.CurrentSelectedStudent != null) { txtStudentFullName.Text = frm.CurrentSelectedStudent.Individual.FullName; txtStudentIdNumber.Text = frm.CurrentSelectedStudent.StudentIDNumber; txtStudentNember.Text = frm.CurrentSelectedStudent.StudentID.ToString(); CurrentSelectedStudent = frm.CurrentSelectedStudent; //Summary Fields txtSummaryFullName.Text = txtStudentFullName.Text; txtSummaryIDNumber.Text = txtStudentIdNumber.Text; txtSummaryStudentNumber.Text = txtStudentNember.Text; picbtnEditCurrentStudent.Visible = true; } else { picbtnEditCurrentStudent.Visible = false; txtStudentFullName.Clear(); txtStudentIdNumber.Clear(); txtStudentNember.Clear(); //Summary Fields txtSummaryFullName.Clear(); txtSummaryIDNumber.Clear(); txtSummaryStudentNumber.Clear(); CurrentSelectedStudent = null; } }; }
private void btnAddEmployee_Click(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { string ValidatedPassword = null; if (txtPassword.Text.ToString().Equals(txtPasswordConfirmation.Text.ToString())) { ValidatedPassword = txtPassword.Text.ToString(); CurrentEmployee = new Employee { EmployeeNumber = txtEmployeeNumber.Text.ToString(), EmployeeID = 0, Individual = new Individual { TitleID = Convert.ToInt32(cboEmployeeTitle.SelectedValue), IndividualFirstName = txtEmployeeFirstName.Text.ToString(), IndividualSecondName = txtEmployeeSecondName.Text.ToString(), IndividualLastname = txtEmployeeLastName.Text.ToString(), } }; Login LoginDetails = new Login { IndividualID = 0, DateLastChanged = DateTime.Now, UserName = txtEmployeeFirstName.Text, Password = txtPassword.Text.ToString() }; CurrentEmployee.Logins.Add(LoginDetails); Dbconnection.Employees.Add(CurrentEmployee); Dbconnection.SaveChanges(); this.CurrentEmployee = (from a in Dbconnection.Employees where a.EmployeeID == CurrentEmployee.EmployeeID select a).FirstOrDefault <Employee>(); this.Close(); } else { MessageBox.Show("Password Does Not Match.", "Confirmation Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Dbconnection.Entry(NewIndividual).Reference(a => a.LookupTitle).Load(); }; }
private void btnAddContact_Click(object sender, EventArgs e) { if (IsStudent) { Student StudentObj = new Student() { EthnicityID = (int)EnumEthnicities.Other_Unspecified, GenderID = (int)EnumGenders.Male, MartialStatusID = (int)EnumMartialStatuses.Single, QualificationLevelID = (int)EnumQualificationLevels.NQF_1_Grade_9_National_Certificate, StudentlInitialDate = DateTime.Today, StudentIDNumber = txtIDNumber.Text, StudentCurrentPosition = "", Individual = new Individual() { // IndividualID = 0, TitleID = Convert.ToInt32(cboIndividualTitle.SelectedValue), IndividualFirstName = txtFirstName.Text.ToString(), IndividualSecondName = txtSecondName.Text.ToString(), IndividualLastname = txtLastName.Text.ToString() } }; using (MCDEntities DbConnection = new MCDEntities()) { //We are saving a new student into the Student Collection DbConnection.Students.Add(StudentObj); DbConnection.SaveChanges(); } CurrentContact = StudentObj.Individual; } else { using (var Dbconnection = new MCDEntities()) { CurrentContact = new Individual { TitleID = Convert.ToInt32(cboIndividualTitle.SelectedValue), IndividualFirstName = txtFirstName.Text.ToString(), IndividualSecondName = txtSecondName.Text.ToString(), IndividualLastname = txtLastName.Text.ToString() }; Dbconnection.Individuals.Add(CurrentContact); Dbconnection.SaveChanges(); }; } this.Close(); }
private void frmAddresses_Load(object sender, EventArgs e) { this.populateAddressType(); this.populateAddressProvinces(); this.populateAddressCountries(); if (AddressID != 0) { if (CurrentAddress != null) { txtAddressDescription.Text = CurrentAddress.AddressDescription; cboStudentAddressAddressType.SelectedValue = CurrentAddress.AddressTypeID; cboStudentAddressCountry.SelectedValue = CurrentAddress.CountryID; cboStudentAddressProvince.SelectedValue = CurrentAddress.ProvinceID; chkStudnetAddressIsDefault.Checked = CurrentAddress.AddressIsDefault; cboStudentAddressCountry.SelectedValue = CurrentAddress.CountryID; cboStudentAddressProvince.SelectedValue = CurrentAddress.ProvinceID; txtStudentAddressLineTwo.Text = CurrentAddress.AddressLineTwo; txtStudentAddressLineOne.Text = CurrentAddress.AddressLineOne; txtStudentAddressTown.Text = CurrentAddress.AddressTown; txtStudentAddressSuburb.Text = CurrentAddress.AddressSuburb; txtStudentAddressAreaCode.Text = CurrentAddress.AddressAreaCode; } else { using (var Dbconnection = new MCDEntities()) { Address AddressToUpdate = (from a in Dbconnection.Addresses where a.AddressID == this.AddressID select a).FirstOrDefault <Address>(); txtAddressDescription.Text = AddressToUpdate.AddressDescription; cboStudentAddressAddressType.SelectedValue = AddressToUpdate.AddressTypeID; cboStudentAddressCountry.SelectedValue = AddressToUpdate.CountryID; cboStudentAddressProvince.SelectedValue = AddressToUpdate.ProvinceID; chkStudnetAddressIsDefault.Checked = AddressToUpdate.AddressIsDefault; cboStudentAddressCountry.SelectedValue = AddressToUpdate.CountryID; cboStudentAddressProvince.SelectedValue = AddressToUpdate.ProvinceID; txtStudentAddressLineTwo.Text = AddressToUpdate.AddressLineTwo; txtStudentAddressLineOne.Text = AddressToUpdate.AddressLineOne; txtStudentAddressTown.Text = AddressToUpdate.AddressTown; txtStudentAddressSuburb.Text = AddressToUpdate.AddressSuburb; txtStudentAddressAreaCode.Text = AddressToUpdate.AddressAreaCode; }; } } ; this.setAddUpdateButtons(); }
private void picSearchStudents_Click(object sender, EventArgs e) { List <Student> StudentExcemptionList = new List <Student>(); using (var Dbconnection = new MCDEntities()) { //Loadds the associated Collections in this case the Enrollment with their associated Students that are enrolled. //Dbconnection.CurriculumEnquiries.Attach(CurrentEnquiry); ////Load all enrollments that linked to the Enquiry Item. //Dbconnection.Entry(CurrentEnquiry).Collection(a => a.Enrollments).Load(); //foreach (Data.Models.Enrollment EnrollmentObj in CurrentEnquiry.Enrollments) //{ // //Load the student linked to the enrollment // // Dbconnection.Entry(EnrollmentObj).Reference(a => a.StudentEnrollment.Student).Load(); // StudentExcemptionList.Add(EnrollmentObj.StudentEnrollment.Student); //} }; using (frmStudentSearchForStudent frm = new frmStudentSearchForStudent(true)) { //Set the list of student that are already Enrolled for this Enquiry Item. frm.StudentExpceptionList = StudentExcemptionList; frm.ShowDialog(); if (frm.CurrentSelectedStudent != null) { if (CurrentEnrollment.StudentEnrollment == null) { CurrentEnrollment.StudentEnrollment = new StudentEnrollment() { StudentID = frm.CurrentSelectedStudent.StudentID, DateUpdated = DateTime.Now.Date, Student = frm.CurrentSelectedStudent }; } else { CurrentEnrollment.StudentEnrollment.StudentID = frm.CurrentSelectedStudent.StudentID; CurrentEnrollment.StudentEnrollment.Student = frm.CurrentSelectedStudent; } picbtnEditCurrentStudent.Visible = true; } else { CurrentEnrollment.StudentEnrollment = null; picbtnEditCurrentStudent.Visible = false; } refreshStudentSelection(); }; }
private void btnRemoveVenue_Click(object sender, EventArgs e) { DialogResult Rtn = MessageBox.Show("Are you sure as this will remove all information Associated with this Venue?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Rtn == DialogResult.Yes) { using (var Dbconnection = new MCDEntities()) { using (System.Data.Entity.DbContextTransaction dbTran = Dbconnection.Database.BeginTransaction()) { try { //CRUD Operations Venue CurrentVenue = (Venue)venueBindingSource.Current; Dbconnection.Entry(CurrentVenue).State = System.Data.Entity.EntityState.Deleted; ////saves all above operations within one transaction Dbconnection.SaveChanges(); //commit transaction dbTran.Commit(); } 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(); } } }; refreshVenues(); } }
private void populateCurriculumCourse() { using (var Dbconnection = new MCDEntities()) { CurriculumCourse cc = (from a in Dbconnection.CurriculumCourses where a.CurriculumCourseID == this.CurriculumCourseID select a).FirstOrDefault <CurriculumCourse>(); txtCourseCost.Text = Convert.ToInt32(cc.Cost).ToString(); nudCourseDuration.Value = cc.Duration; nudCourseMaximumAllowed.Value = cc.CurriculumCourseMinimumMaximum.CurriculumCourseMaximum; nudCourseMinimumAllowed.Value = cc.CurriculumCourseMinimumMaximum.CurriculumCourseMinimum; txtCourseCourseCode.Text = cc.CurricullumCourseCode.CurricullumCourseCodeValue; txtCurrentCostCode.Text = cc.CostCode; }; }
public StandardEmailMessage() { using (var Dbconnection = new MCDEntities()) { SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings select a).FirstOrDefault <SMTPSetting>(); this.DisplayName = EmailSettings.DisplayName; this.PortNumber = EmailSettings.PortNumber; this.Host = EmailSettings.SMTPHost; this.UserName = EmailSettings.UserName; this.Password = EmailSettings.Password; this.RequireAuthentication = EmailSettings.RequireAuthentication; this.RequireSSL = EmailSettings.RequiresSSL; }; }
private void btnRemoveModule_Click(object sender, EventArgs e) { using (var DbConnection = new MCDEntities()) { int ID = Convert.ToInt32(lstLinkedModules.SelectedValue); CurriculumCourseModule LinkedModuleToRemove = (from a in DbConnection.CurriculumCourseModules where a.CurriculumCourseID == this.CurriculumCourseID && a.ModuleID == ID select a).FirstOrDefault <CurriculumCourseModule>(); DbConnection.Entry(LinkedModuleToRemove).State = System.Data.Entity.EntityState.Deleted; DbConnection.SaveChanges(); }; this.populateAvailableModules(); this.populateLinkedModules(); }
private void frmClientEnquiryV3_Load(object sender, EventArgs e) { if (CurrentEmployeeLoggedIn == null) { using (var Dbconnection = new MCDEntities()) { CurrentEmployeeLoggedIn = (from a in Dbconnection.Employees select a) .Include("LookupDepartments") .FirstOrDefault <Employee>(); }; } //Loads up the Currently Selected Equiry - Is Blank. this.refreshInProgressEnquiry(_CurrentSelectedEnquiryID); this.disableFormControlsIfNoEnquiryLoaded(); }
private void populateApprenticeshipEnrollmentDocuments(int _EnrollentDocumentTypeID) { using (var Dbconnection = new MCDEntities()) { Data.Models.Enrollment Enroll = ((Data.Models.Enrollment)(enrollmentBindingSource.Current)); //fileBindingSource.DataSource = (from a in Dbconnection.ApprenticeshipEnrollmentDocuments // where a.EnrollmentID == Enroll.EnrollmentID // && a.LookupEnrollentDocumentTypeID == _EnrollentDocumentTypeID // select new // { // ImageID = a.File.ImageID, // FileName = a.File.FileName + "." + a.File.FileExtension, // DateCreated = a.File.DateCreated // }).ToList(); }; }
private void setControls() { //create individual with properties set Individual ContactObj; using (var Dbconnection = new MCDEntities()) { ContactObj = (from a in Dbconnection.Individuals where a.IndividualID == IndividualID select a).FirstOrDefault <Individual>(); }; this.cboIndividualTitle.SelectedValue = ContactObj.TitleID; this.txtFirstName.Text = ContactObj.IndividualFirstName; this.txtSecondName.Text = ContactObj.IndividualSecondName; this.txtLastName.Text = ContactObj.IndividualLastname; }