private async void tbAdd_Click(object sender, EventArgs e) { using (frmTagInfo frm = new frmTagInfo(new Tag())) { if (frm.ShowDialog() == DialogResult.OK) { try { tagBindingSource.Add(frm.TagInfo); db.Tags.Add(frm.TagInfo); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private async void tbEdit_Click(object sender, EventArgs e) { Tag obj = tagBindingSource.Current as Tag; if (obj != null) { using (frmTagInfo frm = new frmTagInfo(obj)) { if (frm.ShowDialog() == DialogResult.OK) { try { tagBindingSource.EndEdit(); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }