private void btnSave_Click(object sender, EventArgs e) { try { DataClassesJobDataContext db = new DataClassesJobDataContext(); #region check if company name exists var queryResults = from c in db.CompanyProfiles where c.name == txtName.Text select c; if (queryResults.Any()) { MessageBox.Show(txtName.Text + " already exists"); return; } #endregion CompanyProfile company = new CompanyProfile(); company.description = txtDescription.Text; company.name = txtName.Text; db.CompanyProfiles.InsertOnSubmit(company); db.SubmitChanges(); MessageBox.Show("record saved!"); clearFields(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
partial void DeleteCompanyProfile(CompanyProfile instance);
partial void UpdateCompanyProfile(CompanyProfile instance);
partial void InsertCompanyProfile(CompanyProfile instance);