private void btnRoleAdd_Click(object sender, EventArgs e) { using (RoleEditForm frm = new RoleEditForm() { r = new Role() }) { if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { db.InsertRole(frm.r); roleBindingSource.DataSource = db.GetRoles(); roleBindingSource.MoveLast(); } } }
private void btnRoleEdit_Click(object sender, EventArgs e) { Role obj = roleBindingSource.Current as Role; if (obj != null) { using (RoleEditForm frm = new RoleEditForm() { r = obj }) { if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { roleBindingSource.EndEdit(); db.UpdateRole(obj); roleBindingSource.ResetBindings(false); btnEdit.Focus(); } } } }