private void SaveSimpleButton_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; var fullName = fullNameTextEdit.Text; var gender = (bool)genderRadioGroup.EditValue; var birthday = birthdayDateEdit.DateTime.Date; var email = emailTextEdit.Text; var phone = phoneTextEdit.Text; var address = addressMemoEdit.Text; if (!Regex.IsMatch(fullName, RegexPattern.FULL_NAME) || !Regex.IsMatch(email, RegexPattern.EMAIL) || !Regex.IsMatch(phone, RegexPattern.PHONE) || !Regex.IsMatch(address, RegexPattern.ADDRESS)) { Cursor = Cursors.Default; Alert.Warning("Invalid information"); return; } var account = (User)usersBindingSource.Current; account.Information.FullName = fullName; account.Information.Gender = gender; account.Information.Birthday = birthday; account.Information.Email = email; account.Information.Phone = phone; account.Information.Address = address; _entities.SaveChanges(); Cursor = Cursors.Default; Alert.Information("Successful change information"); }
private void SaveSimpleButton_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; var oldPassword = oldPasswordTextEdit.Text; var newPassword = newPasswordTextEdit.Text; var rePassword = rePasswordTextEdit.Text; if (!Regex.IsMatch(oldPassword, RegexPattern.PASSWORD) || !Regex.IsMatch(newPassword, RegexPattern.PASSWORD)) { Cursor = Cursors.Default; Alert.Warning("Invalid password"); return; } if (newPassword != rePassword) { Cursor = Cursors.Default; Alert.Warning("Re-entered password not match"); return; } var account = _entities.Admins.Find(Server.Instance.Id); if (!BCrypt.Net.BCrypt.Verify(oldPassword, account.Password)) { Cursor = Cursors.Default; Alert.Warning("Incorrect password"); return; } account.Password = BCrypt.Net.BCrypt.HashPassword(newPassword); _entities.SaveChanges(); Cursor = Cursors.Default; Alert.Information("Successful change information"); Close(); }