private void button2_Click(object sender, EventArgs e) { Form2 frm = new Form2(); supp sr = (supp)suppBindingSource.Current; frm.db = db; frm.sr = sr; DialogResult dr = frm.ShowDialog(); if (dr == DialogResult.OK) { suppBindingSource.DataSource = db.supps.ToList(); } }
private void button1_Click(object sender, EventArgs e) { if (sr == null) { sr = (supp)suppBindingSource.List[0]; db.SaveChanges(); } try { db.SaveChanges(); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Ошибка", ex.Message); } }
private void button3_Click(object sender, EventArgs e) { supp sr = (supp)suppBindingSource.Current; DialogResult dr = MessageBox.Show("Удалить учетную запись " + sr.ID + "?", "Удаление учетной записи", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { db.supps.Remove(sr); try { db.SaveChanges(); suppBindingSource.DataSource = db.supps.ToList(); } catch (Exception ex) { MessageBox.Show(ex.InnerException.InnerException.Message); } } }