private void btnAdd_Click(object sender, RoutedEventArgs e) { if (IsFormInputValid()) { try { string generatedSalt = new CryptographyHelper().GetGeneratedSalt(); string password = new CryptographyHelper().GetHashedString(pwbPassword.Password + generatedSalt); Model.User user = new Model.User() { Username = tbxUsername.Text, Firstname = tbxFirstname.Text, Lastname = tbxLastname.Text, Password = password, Salt = generatedSalt }; new UsersLogic().AddUser(user); MessageBox.Show("การเพิ่มข้อมูลสำเร็จเรียบร้อย", "สำเร็จ", MessageBoxButton.OK, MessageBoxImage.Information); ClearForm(); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void UpdateUserData(Model.User user) { UpdateUser updateWindow = new UpdateUser(user); if (updateWindow.ShowDialog() == true) { dgUsers.ItemsSource = new UsersLogic().GetUsers(); } }
public UpdateUser(Model.User user) { InitializeComponent(); _selectedUser = user; PopulateUserData(); }
public ChangePassword(Model.User user) { InitializeComponent(); _selectedUser = user; tbxUsername.Text = _selectedUser.Username; }