private void btnUserAdd_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(txtAddUsername.Text)) { MessageBox.Show("Please enter a valid username!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { User user = new User() { Username = txtAddUsername.Text, Age = UInt32.Parse(txtAddAge.Text), Location = String.Join(",", txtAddCountry.Text, txtAddState.Text, txtAddCity.Text), IsAdmin = chkIsAdmin.IsChecked ?? false }; var addUserResponse = SqlHandler.AddUser(user, txtAddPass.Password); if (addUserResponse.Success) { user.UserID = addUserResponse.Content; MessageBox.Show("Successfully added " + user.Username + " (" + user.UserID + ").", "Success", MessageBoxButton.OK, MessageBoxImage.Information); lbxUser.Items.Add(user); } else { MessageBox.Show("Error adding " + user.Username + ".\n\n" + addUserResponse.ErrorText, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }