private async void btnThem_Click(object sender, EventArgs e) { FormThemSuaCB f = new FormThemSuaCB(new CanBo()); { if (f.ShowDialog() == DialogResult.OK) { try { canBoBindingSource.Add(f.canBoInfo); db.CanBo.Add(f.canBoInfo); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Mesage", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private async void btnSua_Click(object sender, EventArgs e) { CanBo canBo = canBoBindingSource.Current as CanBo; if (canBo != null) { FormThemSuaCB f = new FormThemSuaCB(canBo); { if (f.ShowDialog() == DialogResult.OK) { try { canBoBindingSource.EndEdit(); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Mesage", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }