Пример #1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (context.Users.Any(u => u.UserName == cmbUsername.Text) && context.Roles.Any(r => r.Name == cmbRole.Text))
     {
         if (userIdentity.IsInRole(UserIdentity.SessionUser, "Admin"))
         {
             if (userIdentity.ChangeRole(cmbUsername.Text, cmbRole.Text))
             {
                 XtraMessageBox.Show("Change user Role successfully", "OK");
                 this.DialogResult = DialogResult.OK;
                 context.Dispose();
                 userIdentity.Dispose();
                 this.Close();
             }
             ;
         }
         else
         {
             XtraMessageBox.Show("You do not have permission to perform this action");
             btnCancel_Click(this, null);
         }
     }
     else
     {
         XtraMessageBox.Show("Username or Role not found", "Error");
         return;
     }
 }