/// <summary> /// Method edits password and checks the role of user for it. /// </summary> /// <param name="newPassword"></param> public void edit(string newPassword) { int index = 0; foreach (KeyValuePair <string, string> pair in data.getLoginPassword()) { index = user_ListBox.Items.IndexOf(pair.Key); if (user_ListBox.SelectedIndex == index) { if (admin) { editPassword = pair; } else { if (authForm.getCurLoginPassword().Key.Equals(pair.Key)) { editPassword = pair; } else { MessageBox.Show("You can change password only for your own account."); } } } } if (editPassword.Key != null) { data.getLoginPassword()[editPassword.Key] = newPassword.Trim(Symbols.SYMBOLS); data.rewriteLoginPassword(); } }
/// <summary> /// Method fill's the ListBox with active users. /// </summary> public void setListBox() { int index = 0; user_ListBox.Items.Clear(); foreach (KeyValuePair <string, string> pair in data.getLoginPassword()) { user_ListBox.Items.Add(pair.Key); if (authForm.getCurLoginPassword().Key.Equals(pair.Key)) { index = user_ListBox.Items.IndexOf(pair.Key); user_ListBox.SetSelected(index, true); } } }