//Ensures Authorization Code only contains Numbers, then tests Auth Code to see if it matches correct code public bool TestAuthCode() { string UsersEnteredCodeString = getCodeInput(); string input = JeffToolBox.RemoveLetters(UsersEnteredCodeString); input = JeffToolBox.RemoveSpecialCharacters(input); //MEssed up /// if (JeffToolBox.hasLetters(input)) // { // loginWindow_textBox_VerificationCode.Text = ""; // return false; // } //Logic to see if code is correct and matches saved code decimal UsersEnteredCode = Decimal.Parse(input); if (UsersEnteredCode == RandomGeneratedNumber) { return(true); } else { return(false); } }
//Get Users phone number from txtbox, verify that it is indeed a proper phone number public string grabPhoneNumber() { try { string input = loginWindow_textBox_EnterPhone.Text; input = JeffToolBox.RemoveSpecialCharacters(input); input = JeffToolBox.RemoveLetters(input); if (input.Length > 10 || input.Length < 10) { MessageBox.Show("You number had: " + input.Length + "digits. You did not enter the correct number of digits (10) for an American Phone Number. Please try again."); return(null); } input = "+1" + input; return(input); } catch (Exception) { MessageBox.Show("You have entered in an invalid number, please retry. \n Enter in phonenumber in this format: 1234567890"); return(null); } }
//Get Code Input from user public string getCodeInput() { string input = loginWindow_textBox_VerificationCode.Text; input = JeffToolBox.RemoveSpecialCharacters(input); input = JeffToolBox.RemoveLetters(input); return(input); }
public static decimal ReadInterestRate(string message, bool positiveNumber = false, bool acceptZero = true) { while (true) { try { Console.WriteLine(message); string input = Console.ReadLine(); input = JeffToolBox.RemoveSpecialCharacters(input); decimal returnValue = decimal.Parse(input); if (positiveNumber == true && returnValue < 0) { Console.WriteLine("Please enter a positive number"); continue; } if (acceptZero == false && returnValue == 0) { Console.WriteLine("Please enter a number other than 0"); continue; } if ((returnValue * 2 > Decimal.MaxValue) || (returnValue * 3 > Decimal.MaxValue)) { Console.WriteLine("---------------- \n \n"); Console.WriteLine("Please enter a smaller number, dont be a hacker..."); continue; } if (returnValue > 100) { Console.WriteLine("---------------- \n \n"); Console.WriteLine("You cant have an interest rate larger than 100%!"); Console.WriteLine("Please enter an Interest Rate between 0 - 100."); continue; } return(returnValue); } catch (ArgumentNullException e) { Console.WriteLine("Please enter a value"); } catch (FormatException e) { Console.WriteLine("Please enter a numerical value"); } catch (OverflowException e) { Console.WriteLine("Please enter a reasonably sized number"); } catch (Exception e) { Console.WriteLine("There was an error reading this decimal"); } } }