private void MakeUserNow(object sender, RoutedEventArgs e) { bool Robbieisbudgesbestfriend = false; string StringAlpha = UserEnteredName.Text; bool HasSpace = StringAlpha.Contains(" "); string UserNameNow = UserEnteredName.Text.ToString(); bool FirstNameContainsSpace = UserFirstName.Text.Contains(" "); bool LastNameContainsSpace = UserLastName.Text.Contains(" "); bool FirstNameContainsWrong = false; bool LastNameContainsWrong = false; if (UserFirstName.Text.Contains("\u0022")) { LastNameContainsWrong = true; } if (UserLastName.Text.Contains("\u0022")) { LastNameContainsWrong = true; } if (UserFirstName.Text.Contains("\u0027")) { LastNameContainsWrong = true; } if (UserLastName.Text.Contains("\u0027")) { LastNameContainsWrong = true; } if (UserEnteredCode.Text.Contains("\u0022")) { LastNameContainsWrong = true; } if (PasswordBoxConfirm.Password.Contains("\u0022")) { LastNameContainsWrong = true; } if (UserEnteredCode.Text.Contains("\u0027")) { LastNameContainsWrong = true; } if (PasswordBoxMake.Password.Contains("\u0027")) { LastNameContainsWrong = true; } if (PasswordBoxConfirm.Password.Contains("\u0027")) { LastNameContainsWrong = true; } if (PasswordBoxConfirm.Password.Contains("\u0022")) { LastNameContainsWrong = true; } if (UserFirstName.Text.Length < 2 || UserLastName.Text.Length < 2) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "First or Last Name Too Short!"; Robbieisbudgesbestfriend = true; } if (FirstNameContainsSpace || LastNameContainsSpace) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "First or Last Name Contains A Space!"; Robbieisbudgesbestfriend = true; } if (FirstNameContainsWrong || LastNameContainsWrong) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Please Do Not Use \" or \'"; Robbieisbudgesbestfriend = true; } /* * if (PasswordBoxConfirm.Password == PasswordBoxMake.Password && UserEnteredName.Text != "User Name" && HasSpace == false) * { * var NewPassword = PasswordBoxConfirm.Password; * ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush; * ErrorBox.Text = "User Created!"; * //add password to data base * } */ if (UserEnteredName.Text == "User Name" || HasSpace || UserEnteredName.Text.Length < 5 || (UserNameNow.Contains('\u0022')) || (UserNameNow.Contains('\u0027'))) { if (HasSpace) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "User Name Has Spaces!"; } else if (UserEnteredName.Text.Length < 5) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "User Name To Short!"; } else { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "User Name Invalid"; } Robbieisbudgesbestfriend = true; } if (PasswordBoxConfirm.Password != PasswordBoxMake.Password) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Passwords Do Not Match!"; Robbieisbudgesbestfriend = true; } if (UserEnteredName.Text == "User Name" || HasSpace) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "User Name Invalid!"; Robbieisbudgesbestfriend = true; } if (PasswordBoxMake.Password == PasswordBoxConfirm.Password && PasswordBoxMake.Password.Length < 5) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Password To Short!"; Robbieisbudgesbestfriend = true; } if (PasswordBoxMake.Password.Any(char.IsUpper)) { } else { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Password Doesn't Meet Requirements!"; } // Zachary's tests if (GlobalVariables.isEmailInPeople(UserEnteredCode.Text)) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Student Code is already taken!"; Robbieisbudgesbestfriend = true; } if (GlobalVariables.isUsernameInPeople(UserEnteredName.Text)) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush; ErrorBox.Text = "Username is already taken!"; Robbieisbudgesbestfriend = true; } // End of Zac's tests if (Robbieisbudgesbestfriend == false) { ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush; ErrorBox.Text = "User Created!"; PublishUser.Visibility = Visibility.Hidden; Go_Login.Content = "Go To Login"; GlobalVariables.insertIntoPeople(UserFirstName.Text, UserLastName.Text, PasswordBoxConfirm.Password, int.Parse(UserEnteredCode.Text), UserEnteredName.Text); } }