Exemple #1
0
 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();
         }
     }
 }
Exemple #2
0
        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();
                    }
                }
            }
        }