private void SaveBtn_Click(object sender, EventArgs e) { CathedraManager cathedraManager = new CathedraManager(ctx); try { cathedraManager.Save(NametextBox, comboBox1.Text); } catch (Exception exc) { MessageBox.Show(exc.Message); return; } MainForm mainForm = new MainForm(); dataGrid.DataSource = mainForm.GetCathedraDGVBindingSource(); this.Close(); }
private void delCathedraBtn_Click(object sender, EventArgs e) { string value_cath = dataGridView3[0, dataGridView3.CurrentCell.RowIndex].Value.ToString(); string value_dep = dataGridView3[1, dataGridView3.CurrentCell.RowIndex].Value.ToString(); try { if (MessageBox.Show("Ви впевнені?", "Увага!", MessageBoxButtons.YesNo) == DialogResult.Yes) { CathedraManager cathedraManager = new CathedraManager(ctx); cathedraManager.Delete(value_cath, value_dep); } else { return; } } catch (Exception exc) { MessageBox.Show(exc.Message); return; } dataGridView3.DataSource = GetCathedraDGVBindingSource(); }