private async void editbtn_Click(object sender, EventArgs e) { Events obj = eventsBindingSource.Current as Events; if (obj != null) { using (eventsaddform evadd = new eventsaddform(obj)) { if (evadd.ShowDialog() == DialogResult.OK) { try { eventsBindingSource.EndEdit(); await test.SaveChangesAsync(); MessageBox.Show("Успешно изменено"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private async void addbtn_Click(object sender, EventArgs e) { using (eventsaddform evadd = new eventsaddform(new Events())) { if (evadd.ShowDialog() == DialogResult.OK) { try { eventsBindingSource.Add(evadd.EventInfo); test.Events.Add(evadd.EventInfo); await test.SaveChangesAsync(); MessageBox.Show("Успешно добавлено"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }