private void btn_add_Click(object sender, EventArgs e) { var specialityService = new SpecialityService(_unit, _unit); var speciality = specialityService.CreateSpeciality(NameText, TermNumberText, (FormEducation)comboBox1.SelectedItem); _unit.Commit(); _context.Dispose(); this.Close(); }
private void btnAdd_Click(object sender, EventArgs e) { ISpecialityService specialityService = new SpecialityService(); String description = txtSpeciality.Text.ToString().Trim(); speciality objSpeciality = new speciality(); objSpeciality.description = description; if (description.Length == 0) { MessageBox.Show("Type an speciality"); } else if (specialityService.GetSpecialityByDescription(description) != null) { MessageBox.Show("This speciality is already saved. Try another"); } else { specialityService.CreateSpeciality(objSpeciality); MessageBox.Show("Speciality saved"); } this.specialityTableAdapter.Fill(this.finalAppWebDataSet.speciality); }