private void ModifyUser(object parameter) { log.Debug("Modify user button"); PasswordBox pwBox = (PasswordBox)parameter; string OldPassword = pwBox.Password; if (string.IsNullOrWhiteSpace(_oldUserID) || string.IsNullOrWhiteSpace(OldPassword) || string.IsNullOrWhiteSpace(UserID) || string.IsNullOrWhiteSpace(Password) || string.IsNullOrWhiteSpace(Confirm)) { NotificationProvider.Error("Edit user error", "Please fill the Username and Password fieleds."); } else { try { if (UserLogin.ModifyUser(_oldUserID, OldPassword, UserID, Password, Confirm)) { NotificationProvider.Info(String.Format("User modified: {0}", _oldUserID), String.Format("New username: {0}", UserID)); EditWindow?.Close(); } else { NotificationProvider.Error("Edit user error", "Database error"); } } catch (ArgumentException e) { switch (e.ParamName) { case "oldUserID": NotificationProvider.Error("Edit user error", "The original username is missing from the database."); break; case "oldPassword": NotificationProvider.Error("Edit user error", "The old password is wrong."); break; case "newUserId": NotificationProvider.Error("Edit user error", "The new username already exist."); break; case "password": NotificationProvider.Error("Edit user error", "Please fill the password field."); break; case "confirm": NotificationProvider.Error("Edit user error", "Password does not match the confirm password."); break; default: NotificationProvider.Error("Edit user error", "UserLogin error"); break; } } } }
private void btnEditSubmit_Click(object sender, RoutedEventArgs e) { txtBxEditDestName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtBxEditDestDept.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtBxSEditSenderName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtEditBxSenderDept.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtBxEditNotes.GetBindingExpression(TextBox.TextProperty).UpdateSource(); EditWindow.Close(); }