/// <summary> /// Initializes a new instance of the <see cref="CreditCard"/> class. /// </summary> /// <param name="FirstName">The first name.</param> /// <param name="LastName">The last name.</param> /// <param name="PhoneNum">The phone number.</param> /// <param name="Email">The email.</param> /// <param name="CCNum">The cc number.</param> /// <param name="Date">The date.</param> protected internal CreditCard(String FirstName, String LastName, String PhoneNum, String Email, String CCNum, String Date) { Boolean ValidCCNum = false; setFirstName(FirstName); setLastName(LastName); setPhoneNumber(PhoneNum); setEmailAddress(Email); ValidCCNum = ValidInput.CreditCardValidation(CCNum); setCreditCardNumber(CCNum, ValidCCNum); ValidCCNum = ValidInput.ValidDateMonth(Date); setExpirationDate(Date, ValidCCNum); var CCType = ValidInput.CreditCardType(CCNum, ValidCCNum); setCreditCardType(CCType); }
/// <summary> /// Credits the card validation. /// </summary> /// <param name="FileName">Name of the file.</param> public void CreditCardValidation(String FileName) { Boolean ValidEntery = false; InputValidation NameValid = new InputValidation(); String ValidFirstName = String.Empty; String ValidLastName = String.Empty; String ValidPhone = String.Empty; String ValidEmail = String.Empty; String ValidDateValue = String.Empty; String ValidCCNum = String.Empty; Boolean ValidDate = false; Boolean ValidCC = false; StreamReader rdr = null; Boolean AddToTheList = true; try { rdr = new StreamReader(FileName); while (rdr.Peek() != -1) { String[] fields = rdr.ReadLine().Split('|'); ValidFirstName = fields[0]; ValidLastName = fields[1]; ValidCCNum = fields[4]; ValidDateValue = fields[5]; ValidPhone = fields[2]; ValidEmail = fields[3]; ValidEntery = NameValid.NameValidation(ValidFirstName); if (ValidEntery == false) { Console.WriteLine( ValidFirstName + " is not a valid Name\nCould Not Include Credit Card In List"); Console.ReadLine(); ValidFirstName = null; AddToTheList = false; } else { ValidFirstName = fields[0]; } ValidEntery = NameValid.NameValidation(ValidLastName); if (ValidEntery == false) { Console.WriteLine(ValidLastName + " is not a valid name.\nCould not include this record"); ValidLastName = null; AddToTheList = false; } else { ValidLastName = fields[1]; ValidEntery = false; } ValidEntery = NameValid.ValidPhoneNumber(ValidPhone); if (ValidEntery == false) { Console.WriteLine( ValidPhone + " is not a valid Phone Number\nCould not include this record"); ValidPhone = null; AddToTheList = false; } else { ValidPhone = fields[2]; } ValidEntery = NameValid.ValidEmailAddress(ValidEmail); if (ValidEntery == false) { Console.WriteLine(ValidEmail + "is not a valid Email Address\nCould Not Include Credit Card In List"); ValidEmail = null; AddToTheList = false; } else { ValidEmail = fields[3]; } ValidCCNum = Regex.Replace(ValidCCNum, @"[\s]", ""); ValidCC = NameValid.CreditCardValidation(ValidCCNum); String[] MonthYear = ValidDateValue.Split('/'); ValidDate = NameValid.ValidCreditCardDate(MonthYear[0], MonthYear[1]); CreditCard NewCreditCard = new CreditCard(ValidFirstName, ValidLastName, ValidPhone, ValidEmail, ValidCCNum, ValidDateValue); NewCreditCard.setCreditCardType(NameValid.CreditCardType(ValidCCNum, ValidCC)); if (AddToTheList == true) { this.NewCreditCardList.Add(NewCreditCard); } else { Console.WriteLine("Cound Not Add This Record. Some Values were not valid.\n\nPress Enter To Continue"); Console.ReadLine(); } AddToTheList = true; } } catch (Exception) { } finally { if (rdr != null) { rdr.Close(); } } NeedsSaving = true; }