/** * \brief The GetBaseEmployeeDetails method will get the users input, set it in an employee object and return the employee object * to further process it. * * \details <b>Details</b> * * \param args - n/a * * \throw <EndOfProgramException> - If the user wants the program to end * * \return - <b> Employee emp </b>- returns the employee with information */ private static Employee GetBaseEmployeeDetails() { // Variables int employeeSIN; Employee tempEmp = new Employee(); string empType; string empLName; string empFName; string empSIN; string empDOB; FulltimeEmployee FTemp = new FulltimeEmployee(); ParttimeEmployee PTemp = new ParttimeEmployee(); ContractEmployee CTemp = new ContractEmployee(); SeasonalEmployee SNemp = new SeasonalEmployee(); if (menuOptionFlag == 1) { Console.WriteLine("Employee Creation"); Console.WriteLine("__________________"); Console.WriteLine("Press enter to skip entry."); } else if (menuOptionFlag == 2) { Console.WriteLine("Employee Modification"); Console.WriteLine("______________________"); Console.WriteLine("Press enter to skip entry."); } else if (menuOptionFlag == 3) { Console.WriteLine("Employee Deletion"); Console.WriteLine("__________________"); Console.WriteLine("Press enter to skip entry."); } // Prompt for details bool error = false; do{ if(error) { Console.WriteLine("Invalid data was put in. Acceptable employee types are 'FT' 'PT' 'CT' or 'SN'"); } error = true; Console.WriteLine("Enter the employee type \n 'FT' for FullTime \n 'PT' for PartTime \n 'CT' for Contract \n 'SN' for Seasonal:"); empType = Console.ReadLine(); Console.Clear(); empType = empType.ToUpper(); } while (!tempEmp.SetEmployeeType(empType)); error = false; if (tempEmp.GetEmployeeType() == "FT") { do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's last name:"); empLName = Console.ReadLine(); Console.Clear(); } while (!((Employee)FTemp).SetLastName(empLName)); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's first name:"); empFName = Console.ReadLine(); Console.Clear(); } while (!((Employee)FTemp).SetFirstName(empFName)); error = false; bool valid; do { if (error) { Console.WriteLine("Invalid data was put in. A SIN number should be in the format of ### ### ###"); } error = true; Console.WriteLine("Enter the employee's SIN number:"); empSIN = Console.ReadLine(); Console.Clear(); empSIN = empSIN.Replace(" ", ""); valid = int.TryParse(empSIN, out employeeSIN); } while (!((Employee)FTemp).SetSocialInsuranceNumber(employeeSIN) || (!valid && empSIN != "")); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. The date must be in the format of YYYY-MM-DD"); } error = true; Console.WriteLine("Enter the employee's date of birth in the format: YYYY-MM-DD"); empDOB = Console.ReadLine(); Console.Clear(); } while (!FTemp.SetDateOfBirth(empDOB)); error = false; } else if (tempEmp.GetEmployeeType() == "PT") { do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's last name:"); empLName = Console.ReadLine(); Console.Clear(); } while (!((Employee)PTemp).SetLastName(empLName)); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's first name:"); empFName = Console.ReadLine(); Console.Clear(); } while (!((Employee)PTemp).SetFirstName(empFName)); error = false; bool valid; do { if (error) { Console.WriteLine("Invalid data was put in. A SIN number should be in the format of ### ### ###"); } error = true; Console.WriteLine("Enter the employee's SIN number:"); empSIN = Console.ReadLine(); Console.Clear(); empSIN.Replace(" ", ""); valid = int.TryParse(empSIN, out employeeSIN); } while (!((Employee)PTemp).SetSocialInsuranceNumber(employeeSIN) || (!valid && empSIN != "")); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. The date must be in the format of YYYY-MM-DD"); } error = true; Console.WriteLine("Enter the employee's date of birth in the format: YYYY-MM-DD"); empDOB = Console.ReadLine(); Console.Clear(); } while (!PTemp.SetDateOfBirth(empDOB)); error = false; } else if (tempEmp.GetEmployeeType() == "CT") { do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's coorporation name:"); empLName = Console.ReadLine(); Console.Clear(); } while (!((Employee)CTemp).SetLastName(empLName)); error = false; bool valid; do { if (error) { Console.WriteLine("Invalid data was put in. A Business Number number should be in the format of #### #####"); } error = true; Console.WriteLine("Enter the employee's Business Number number:"); empSIN = Console.ReadLine(); Console.Clear(); empSIN.Replace(" ", ""); valid = int.TryParse(empSIN, out employeeSIN); } while (!((Employee)CTemp).SetSocialInsuranceNumber(employeeSIN) || (!valid && empSIN != "")); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. The date must be in the format of YYYY-MM-DD."); if(CTemp.GetSocialInsuranceNumber() != 0) { Console.WriteLine("The last 2 digits of the year \nshould match the first 2 digits of the Buisness Number: " + CTemp.GetSocialInsuranceNumber().ToString().Substring(0, 2)); } } error = true; Console.WriteLine("Enter the employee's date of incorporation in the format: YYYY-MM-DD"); empDOB = Console.ReadLine(); Console.Clear(); } while (!CTemp.SetDateOfBirth(empDOB)); error = false; } else if (tempEmp.GetEmployeeType() == "SN") { do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's last name:"); empLName = Console.ReadLine(); Console.Clear(); } while (!((Employee)SNemp).SetLastName(empLName)); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. There must only be letters, dashes, and/or apostrophes"); } error = true; Console.WriteLine("Enter the employee's first name:"); empFName = Console.ReadLine(); Console.Clear(); } while (!((Employee)SNemp).SetFirstName(empFName)); error = false; bool valid; do { if (error) { Console.WriteLine("Invalid data was put in. A SIN number should be in the format of ### ### ###"); } error = true; Console.WriteLine("Enter the employee's SIN number:"); empSIN = Console.ReadLine(); Console.Clear(); empSIN.Replace(" ", ""); valid = int.TryParse(empSIN, out employeeSIN); } while (!((Employee)SNemp).SetSocialInsuranceNumber(employeeSIN) || (!valid && empSIN != "")); error = false; do { if (error) { Console.WriteLine("Invalid data was put in. The date must be in the format of YYYY-MM-DD"); } error = true; Console.WriteLine("Enter the employee's date of birth in the format: YYYY-MM-DD"); empDOB = Console.ReadLine(); Console.Clear(); } while (!SNemp.SetDateOfBirth(empDOB)); error = false; } if (tempEmp.GetEmployeeType() == "FT") { return FTemp; } else if (tempEmp.GetEmployeeType() == "PT") { return PTemp; } else if (tempEmp.GetEmployeeType() == "CT") { return CTemp; } else if (tempEmp.GetEmployeeType() == "SN") { return SNemp; } return tempEmp; }