コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
ファイル: User.xaml.cs プロジェクト: spikeza/amsdesktop
        private void UpdateUserData(Model.User user)
        {
            UpdateUser updateWindow = new UpdateUser(user);

            if (updateWindow.ShowDialog() == true)
            {
                dgUsers.ItemsSource = new UsersLogic().GetUsers();
            }
        }
コード例 #3
0
 public UpdateUser(Model.User user)
 {
     InitializeComponent();
     _selectedUser = user;
     PopulateUserData();
 }
コード例 #4
0
 public ChangePassword(Model.User user)
 {
     InitializeComponent();
     _selectedUser    = user;
     tbxUsername.Text = _selectedUser.Username;
 }