private void userEditBtn_Click(object sender, EventArgs e) { UserSecurity.User user = (UserSecurity.User)usersBinding.Current; if (user.Login == UserSecurity.CurrentUser.Login) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("You cannot edit yourself!"); return; } if (user.Roles.Contains(m_adminRole)) { if (!CanSuperAdmin("edit administrators")) { return; } } UserEditForm dlg = new UserEditForm(user); dlg.ShowDialog(this); }
private void userDelBtn_Click(object sender, EventArgs e) { UserSecurity.User user = (UserSecurity.User)usersBinding.Current; InfoBox ib = new InfoBox(); if (user.Login == UserSecurity.CurrentUser.Login) { ib.Icon = MessageBoxIcon.Error; ib.Show("You cannot delete yourself!"); return; } DialogResult ans; ib.Type = InfoBoxType.SuperConfirmBox; ib.Icon = MessageBoxIcon.Warning; ib.Buttons = MessageBoxButtons.YesNo; ans = ib.Show("You are about to delete the user \"{0}\".\r" + "This operation cannot be undone.\r\r" + "Continue anyway?", user.Login); if (ans == DialogResult.Yes) { try { UserSecurity.Users.Remove(user); UserSecurity.Users.Save(); } catch (Exception ex) { ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("Save Error:\r{0}", ex.Message); } } }