private void CloseButton(object sender, RoutedEventArgs e) { closeBackground.Visibility = Visibility.Collapsed; closeButton.Visibility = Visibility.Collapsed; patvirtintiBackround.Visibility = Visibility.Collapsed; patvirtintiButton.Visibility = Visibility.Collapsed; KeistiDescription.Visibility = Visibility.Collapsed; KeistiLabel.Visibility = Visibility.Collapsed; greyedOut.Visibility = Visibility.Collapsed; KeistiWindow.Visibility = Visibility.Collapsed; kodoTextBox.Visibility = Visibility.Collapsed; kodoLabel.Visibility = Visibility.Collapsed; passLabel.Visibility = Visibility.Collapsed; PassTextBox.Visibility = Visibility.Collapsed; newPassLabel.Visibility = Visibility.Collapsed; NewPasswordTextBox.Visibility = Visibility.Collapsed; newPassAgainLabel.Visibility = Visibility.Collapsed; NewPasswordAgainTextBox.Visibility = Visibility.Collapsed; passUnderLine.Visibility = Visibility.Collapsed; newPassUnderline.Visibility = Visibility.Collapsed; kodoUnderline.Visibility = Visibility.Collapsed; newPassAgainUnderline.Visibility = Visibility.Collapsed; generalEventText.Visibility = Visibility.Collapsed; kodoTextBox.Clear(); NewPasswordAgainTextBox.Clear(); NewPasswordTextBox.Clear(); PassTextBox.Clear(); generalEventText.Content = ""; }
private void ResetFormControl() { NewPasswordTextBox.Clear(); OldPasswordTextBox.Clear(); ConfirmPasswordTextBox.Clear(); OldPasswordTextBox.Focus(); }
/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChangePasswordQQButton_Click(object sender, EventArgs e) { if (FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), OldPasswordTextBox.Text).Equals(MainWindow.PASSWORD_HASH)) { if (NewPasswordTextBox.Text.Equals(NewPasswordTextBox2.Text)) { try { if (DatabaseConnections.Connector.OnlineUpdateData( "users", new string[] { "password" }, new string[] { FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text) }, MainWindow.ID) > 0) { OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); NewPasswordTextBox2.Clear(); MessageBox.Show("修改密码成功!下次登录时候您将需要使用新密码!", "成功"); //MainWindow.PASSWORD_HASH = FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text); ChangePasswordCheckBox.Checked = false; isChangedPassword = true; } } catch (Exception ee) { MessageBox.Show(ee.Message, "密码修改错误"); //throw; } } else { MessageBox.Show("两次密码不同!", "错误"); NewPasswordTextBox.Clear(); NewPasswordTextBox2.Clear(); } } else { MessageBox.Show("旧密码输入错误!", "错误"); OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); NewPasswordTextBox2.Clear(); } }
private void SaveButton_Click(object sender, EventArgs e) { SuccessLabel.Visible = false; OldPassLabel.Visible = false; NewPassLabel.Visible = false; RepeatNewPassLabel.Visible = false; OldAuthLabel.Visible = false; NewAuthLabel.Visible = false; RepeatNewAuthLabel.Visible = false; if (CurrentPasswordTextBox.Text.Length > 0 || NewPasswordTextBox.Text.Length > 0 || AcceptNewPasswordTextBox.Text.Length > 0) { if (CurrentPasswordTextBox.Text.Length == 0) { OldPassLabel.Text = "Введите старый пароль"; OldPassLabel.Visible = true; return; } if (Security.CheckPass(CurrentPasswordTextBox.Text) == false) { OldPassLabel.Text = "Пароль неверный"; OldPassLabel.Visible = true; return; } if (NewPasswordTextBox.Text.Length == 0) { NewPassLabel.Text = "Введите новый пароль"; NewPassLabel.Visible = true; return; } if (NewPasswordTextBox.Text.Length < 4) { NewPassLabel.Text = "Длина пароля меньше 4 символов"; NewPassLabel.Visible = true; return; } if (AcceptNewPasswordTextBox.Text.Length == 0) { RepeatNewPassLabel.Text = "Повторите новый пароль"; RepeatNewPassLabel.Visible = true; return; } if (AcceptNewPasswordTextBox.Text != NewPasswordTextBox.Text) { RepeatNewPassLabel.Text = "Пароли не совпадают"; RepeatNewPassLabel.Visible = true; return; } Security.ChangePassword(CurrentPasswordTextBox.Text, NewPasswordTextBox.Text); SuccessLabel.Visible = true; CurrentPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); AcceptNewPasswordTextBox.Clear(); } //authorization code if (CurrentAuthTextBox.Text.Length > 0 || NewAuthTextBox.Text.Length > 0 || AcceptNewAuthTextBox.Text.Length > 0) { if (CurrentAuthTextBox.Text.Length == 0) { if (Security.CheckAuth(CurrentAuthTextBox.Text) == false) { if (CurrentAuthTextBox.Text.Length == 0) { OldAuthLabel.Text = "Введите старый авторизационный код"; OldAuthLabel.Visible = true; return; } } } else { if (Security.CheckAuth(CurrentAuthTextBox.Text) == false) { OldAuthLabel.Text = "Авторизационный код неверный"; OldAuthLabel.Visible = true; return; } } if (NewAuthTextBox.Text.Length == 0) { NewAuthLabel.Text = "Введите новый авторизационный код"; NewAuthLabel.Visible = true; return; } if (NewAuthTextBox.Text.Length < 6) { NewAuthLabel.Text = "Длина авторизационного кода меньше 6 символов"; NewAuthLabel.Visible = true; return; } if (AcceptNewAuthTextBox.Text.Length == 0) { RepeatNewAuthLabel.Text = "Повторите новый авторизационный код"; RepeatNewAuthLabel.Visible = true; return; } if (AcceptNewAuthTextBox.Text != NewAuthTextBox.Text) { RepeatNewAuthLabel.Text = "Авторизационные коды не совпадают"; RepeatNewAuthLabel.Visible = true; return; } Security.ChangeAuth(NewAuthTextBox.Text); SuccessLabel.Visible = true; CurrentAuthTextBox.Clear(); NewAuthTextBox.Clear(); AcceptNewAuthTextBox.Clear(); } }
private void SaveButton_Click(object sender, EventArgs e) { if (!UsernameTextBox.Text.Trim().Equals(string.Empty) && !OldPasswordTextBox.Text.Trim().Equals(string.Empty) && !NewPasswordTextBox.Text.Trim().Equals(string.Empty) && !RepeatPasswordTextBox.Text.Trim().Equals(string.Empty)) { userData = XmlDataManager.XmlUserDataReader("userdata.xml"); string unchangeUsername = userData.Username; // old Username string UserAttribut = userData.UserAttribut; userData1 = XmlDataManager.XmlUserDataReader("XMLSystemAdmin.xml"); string UserAttribut1 = userData1.UserAttribut; if (!(UserAttribut.Equals("SuperAdmin"))) { // return the UserId from the database int UserId = databaseManager.ReturnUserID(unchangeUsername, OldPasswordTextBox.Text); string newUsername = UsernameTextBox.Text; // new Username string oldPassword = OldPasswordTextBox.Text; // old Password string newPassword = NewPasswordTextBox.Text; // new Password string repeatPassword = RepeatPasswordTextBox.Text; // new Password //Edit the UserData as simple user. databaseManager.EditAccountUser(UserId, newUsername, oldPassword, newPassword, repeatPassword); UsernameTextBox.Clear(); OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); RepeatPasswordTextBox.Clear(); AdminUI adminUI = new AdminUI(Online_User); this.Close(); adminUI.Show(); } else { string AdminPassword = userData1.Password; if ((OldPasswordTextBox.Text).Equals(AdminPassword)) { if (File.Exists("XMLSystemAdmin.xml")) { userData.Username = UsernameTextBox.Text.Trim(); userData.Password = NewPasswordTextBox.Text.Trim(); userData.UserAttribut = UserAttribut; XmlDataManager.XmlDataWriter(userData, "XMLSystemAdmin.xml"); MessageBox.Show("SuperAdmin Data changed successful"); AdminUI adminUI = new AdminUI(Online_User); this.Close(); adminUI.Show(); } else { MessageBox.Show("XMLSystemAdmin.xml File not found!"); } } else { MessageBox.Show("Wrong Password. Please give a correct password!"); } } } else { MessageBox.Show("Fill all Fields"); } }
private void ForgotPassword4NextButton_Click(object sender, RoutedEventArgs e) { LoginPage LP = new LoginPage(); OldPasswordTextBox.Password = LP.GetSha512FromString(OldPasswordTextBox.Password); NewPasswordTextBox.Password = LP.GetSha512FromString(NewPasswordTextBox.Password); string selected_ForgotPasswordEmail = (App.Current as App).ForgotPasswordEmail; try { ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["connString"]; string connectionString = conSettings.ConnectionString; con = new SqlConnection(connectionString); con.Open(); cmd = new SqlCommand("select * from [dbo].[test] where Password = '******' and Email = '" + selected_ForgotPasswordEmail + "'", con); reader = cmd.ExecuteReader(); int count = 0; while (reader.Read()) { count += 1; } if (count == 1) { try { ConnectionStringSettings conSettings1 = ConfigurationManager.ConnectionStrings["connString"]; string connectionString1 = conSettings1.ConnectionString; con = new SqlConnection(connectionString1); con.Open(); cmd = new SqlCommand("UPDATE [dbo].[test] SET Password = '******' WHERE Email = '" + selected_ForgotPasswordEmail + "'", con); cmd.ExecuteNonQuery(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } finally { con.Close(); } MessageBox.Show("You have changed your password."); OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); this.NavigationService.Navigate(new Uri(@"LoginPage.xaml", UriKind.RelativeOrAbsolute)); } else { MessageBox.Show("Incorrect old password."); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } finally { con.Close(); } OldPasswordTextBox.Clear(); NewPasswordTextBox.Clear(); }