private void btnSearchForCompany_Click(object sender, EventArgs e) { using (frmCompanySearch frm = new frmCompanySearch()) { frm.ShowDialog(); if (frm.CurrentCompany != null) { //this.CurrentScheduleConfiguration.Clear(); CurrentlySelectedCompany = frm.CurrentCompany; using (var Dbconnection = new MCDEntities()) { Dbconnection.Companies.Attach(CurrentlySelectedCompany); Dbconnection.Entry(CurrentlySelectedCompany).Collection(a => a.Addresses).Load(); }; companyBindingSource.DataSource = CurrentlySelectedCompany; addressBindingSource.DataSource = (from a in CurrentlySelectedCompany.Addresses select a).ToList <Data.Models.Address>(); } else { companyBindingSource.DataSource = null; addressBindingSource.DataSource = null; //this.CurrentScheduleConfiguration.Companies.Clear(); } }; this.refreshCompanyInfo(); }
private void btnCompanySearch_Click(object sender, EventArgs e) { //Select Company from Search Form frmCompanySearch frm = new frmCompanySearch(); frm.ShowDialog(); //check if Current Company is nit null means that a company was selected. if (frm.CurrentCompany != null) { using (var Dbconnection = new MCDEntities()) { //Select-Get Current Student. Student CurrentStudent = (from a in Dbconnection.Students where a.StudentID == this.StudentID select a).FirstOrDefault <Student>(); if (CurrentStudent != null) { Boolean PreviouslyAssociatedWithCompany = false; //Determines if the company selected has bee associated with the student in the past if (CurrentStudent.StudentAssociatedCompanies.Count > 0) { foreach (StudentAssociatedCompany CompanyStatusToUpdate in CurrentStudent.StudentAssociatedCompanies) { CompanyStatusToUpdate.IsCurrentCompany = false; if (CompanyStatusToUpdate.StudentID == this.StudentID && CompanyStatusToUpdate.CompanyID == frm.CurrentCompany.CompanyID) { PreviouslyAssociatedWithCompany = true; CompanyStatusToUpdate.IsCurrentCompany = true; } } } DialogResult Rtn = MetroMessageBox.Show(this, MetroMessageBox.Show(this, "Are You Sure you wish to link " + CurrentStudent.Individual.FullName + " To - " + frm.CurrentCompany.CompanyName, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2).ToString()); if (Rtn == DialogResult.Yes) { if (PreviouslyAssociatedWithCompany) { Dbconnection.SaveChanges(); } else { CurrentStudent.StudentAssociatedCompanies.Add(new StudentAssociatedCompany { CompanyID = frm.CurrentCompany.CompanyID, StudentID = CurrentStudent.StudentID, IsCurrentCompany = true }); Dbconnection.SaveChanges(); } } //this.refreshStudentCompany(); } }; } }
private void btnpicFileSearch_Click(object sender, EventArgs e) { using (frmCompanySearch frm = new frmCompanySearch()) { frm.ShowDialog(); if (frm.CurrentCompany != null) { OfProgressFiles.VerifyCompanyProgressFile(frm.CurrentCompany.CompanyID); this.CurrentlySelectedCompany = frm.CurrentCompany; this.refreshCompanyFile(); } } }
private void btnPicSearchForCompany_Click(object sender, EventArgs e) { using (frmCompanySearch frm = new frmCompanySearch()) { frm.ShowDialog(); if (frm.CurrentCompany != null) { this.CompanyID = frm.CurrentCompany.CompanyID; this.refreshCompanyDetails(); //this.refreshCompanyContacts(); //refreshCompanyContactsDetails(); refreshCompanyContactDetails(); } } }
private void btnSearchForCompany_Click(object sender, EventArgs e) { using (frmCompanySearch frm = new frmCompanySearch()) { frm.ShowDialog(); if (frm.CurrentCompany != null) { //this.CurrentScheduleConfiguration..Clear(); //this.CurrentScheduleConfiguration.Companies.Add(frm.CurrentCompany); } else { //this.CurrentScheduleConfiguration.Companies.Clear(); } }; this.refreshCompanyInfo(); }
private void btnSelectCompany_Click(object sender, EventArgs e) { frmCompanySearch frm = new frmCompanySearch(); frm.ShowDialog(); CurrentCompany = frm.CurrentCompany; if (CurrentCompany != null) { this.setDisplayControlsToEnabled(); } else { this.setDisplayControlsToDisabled(); this.individualBindingSource.Clear(); } this.refreshCompanyContacts(); this.refreshCompanyContactDetails(); }