static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nEnter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); }catch (Exception e) { Console.WriteLine("Try again"); Console.WriteLine(e.Message); year = 0; } } while (month == 0) { Console.Write("\nEnter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if ((month < 1) || (month > 12)) { Console.WriteLine("try again"); month = 0; } }catch (Exception e) { Console.WriteLine("Try again"); Console.WriteLine(e.Message); month = 0; } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("Enter Hours Worked for {0}", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePayslip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff; FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Error: Invalid year. Please enter a valid year."); } } while (month == 0) { Console.Write("\nPlease enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Error: Inavid month. Please enter a valid month."); month = 0; } } catch (FormatException) { Console.WriteLine("Error: Invalid month. Please enter a valid month."); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("Enter hours worked for {0}:", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message + "Please try again."); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); myStaff = fr.ReadFile(); int month = 0; int year = 0; while (year == 0) { Console.Write("Please enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch { Console.Write("An error number was entered"); } } while (month == 0) { Console.Write("Please enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); } catch { Console.Write("An error number was entered"); } } for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("Enter number of hours worked for " + myStaff[i].NameofStaff + ": "); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); } catch (Exception e) { Console.WriteLine(e); --i; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); }
static void Main(string[] args) { List <Staff> myStaff; FileReader fr = new FileReader(); int year = 0; int month = 0; while (year == 0) { Console.Write("\nPlease enter the year:"); try { string input = Console.ReadLine(); year = Int32.Parse(input); } catch (FormatException) { Console.WriteLine("Please enter valid integers."); } } while (month == 0) { Console.Write("\nPlease enter the month:"); try { string input = Console.ReadLine(); month = Int32.Parse(input); } catch (FormatException) { Console.WriteLine("Please enter valid integers."); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("\nPlease enter the hours worked for {0}", myStaff[i].NameOfStaff); string input = Console.ReadLine(); myStaff[i].HoursWorked = Int32.Parse(input); myStaff[i].CalculatePay(); myStaff[i].ToString(); } catch (Exception e) { Console.WriteLine(e.Message); } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> staffList = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine(e.Message + " Please try again."); } } while (month == 0) { Console.Write("\nPlease enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Month must be from 1 to 12. Please try again."); month = 0; } } catch (Exception e) { Console.WriteLine(e.Message + " Please try again."); } } staffList = fr.ReadFile(); //continue here page 150. for (int i = 0; i < staffList.Count; i++) { try { Console.WriteLine("\nEnter hours worked for {0}", staffList[i].NameOfStaff); staffList[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); staffList[i].CalculatePay(); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip payslip = new PaySlip(month, year); payslip.GeneratePaySlip(staffList); payslip.GenerateSummary(staffList); Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fileReader = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.WriteLine("Please Enter the Year"); try { year = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine(e.Message + "Invalid entry, try again."); } } while (month == 0) { Console.WriteLine("Please Enter the Month"); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Month must be between 1 and 12, try again."); month = 0; } } catch (Exception e) { Console.WriteLine(e.Message + "Invalid entry, try again."); } } myStaff = fileReader.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("Enter Hours worked for {0} {1}: ", myStaff[i].FirstName, myStaff[i].LastName); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip paySlip = new PaySlip(month, year); paySlip.GeneratePaySlip(myStaff); paySlip.GenerateSummery(myStaff); Console.WriteLine("Operation Complete"); Console.Read(); }
public static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; // Input Year and test if it is valid while (year == 0) { Console.Write("\nPlease enter a year: "); try { //Code to convert the input to an integer year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("This is not a valid year. Try again."); } catch (OverflowException) { Console.WriteLine("This a litle bit far in the future! Try again."); } } // Input MOUNTH and test if it is valid while (month == 0) { Console.Write("\nPlease enter a month: "); try { //Code to convert the input to an integer month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { month = 0; Console.WriteLine("Only 12 month in a year. Please enter a number between 1 and 12."); } } catch (FormatException) { Console.WriteLine("This is not a valid month number. Try again."); } catch (OverflowException) { Console.WriteLine("There are not so much month in a year! Try again."); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("Enter hours worked for {0}:", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { i--; Console.WriteLine(e.Message + "A number please!"); } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); // To maintain the Console Open. Not needed here. //Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff; FileReader fr = new FileReader(); int month = 0; int year = 0; //Get the year to process while (year == 0) { Write("\nPlease enter the year: "); try { year = ToInt32(ReadLine()); if (year < 2000 || year > 2100) { year = 0; WriteLine("Year is out of range."); } } catch (FormatException e) { WriteLine("Error entering year: {0}", e.Message); } } //Get the month to process while (month == 0) { Write("\nPlease enter the month: "); try { month = ToInt32(ReadLine()); if (month < 1 || month > 12) { month = 0; WriteLine("Please enter a value between 1 and 12."); } } catch (FormatException e) { WriteLine("Error entering month: {0}", e.Message); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { //Retrieve the hours worked for the current staff Write("\nEnter hours worked for {0}: ", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = ToInt32(ReadLine()); //Calculate the pay and write it to the screen myStaff[i].CalculatePay(); WriteLine(myStaff[i].ToString()); } catch (Exception e) { WriteLine("Error entering hours: {0}", e.Message); //Decrement the counter so we process the same staff again i--; } } //Create a pay slip object to output the pay slips and summary PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); WriteLine("Payroll complete. Press any key to continue."); ReadKey(); }
static void Main(string[] args) { int month = 0; int year = 0; List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); while (year == 0) { Console.Write("Please enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Please input a valid Year"); year = 0; } } while (month == 0) { Console.Write("Please enter the month:"); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Please enter a valid month"); month = 0; } } catch (Exception) { Console.WriteLine("Please input a valid Month"); month = 0; } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("Enter hours worked for {0}", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine("Enter a correct number for hours"); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
/// <summary> /// Main program /// </summary> /// <param name="args"></param> static void Main(string[] args) { #region Initialize local variables List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; #endregion #region Get user input for year/month while (year == 0) { Console.Write("Please enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Wrong format."); } } while (month == 0) { Console.Write("Please enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Month must be between 1 and 12."); month = 0; } } catch (FormatException) { Console.WriteLine("Wrong format."); } } #endregion #region User inputs hours worked for each staff member // Reads the file of staff into a list of Staff objects myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("\nEnter hours worked for {0}: ", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); // To repeat asking about the same staff members hours: i--; } } #endregion #region Write payslips to files PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); #endregion #region Generate summary file ps.GenerateSummary(myStaff); #endregion #region End credits Console.WriteLine("Thank you for using PaySoft..."); Console.Read(); #endregion }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fileReader = new FileReader(); int month = 0; int year = 0; Console.WriteLine("\nSimple Payroll Application"); Console.WriteLine("=========================="); while (year == 0) { Console.Write("\nPlease enter a year: "); try { string input = Console.ReadLine(); if (input.Length == 4) { Int32.TryParse(input, out year); if (year < 2019) { year = 0; Console.WriteLine("\nYour year value is too small."); } } else { Console.WriteLine("\nYour input does not have enough digits or is in the wrong format."); } } catch (FormatException e) { Console.WriteLine("\nAn error occured. " + e.Message); Console.WriteLine("Please provide a valid year number greater than 2019.\n"); } } while (month == 0) { Console.Write("\nPlease enter a month between 1 and 12: "); try { Int32.TryParse(Console.ReadLine(), out month); if (month < 1 || month > 12) { month = 0; Console.WriteLine("\nPlease provide a valid month number between 1 and 12.\n"); } } catch (FormatException e) { Console.WriteLine("An error occured. " + e.Message); Console.WriteLine("\nPlease provide a valid month number between 1 and 12. Error: " + e.Message + "\n"); } } myStaff = fileReader.ReadFile(); for (int i = 0; i < myStaff.Count(); i++) { try { int hoursWorked = -1; while (hoursWorked < 0) { Console.Write("\nEnter hours worked by " + myStaff[i].NameOfStaff + ": "); bool success = Int32.TryParse(Console.ReadLine(), out hoursWorked); if (success) { myStaff[i].HoursWorked = hoursWorked; } Console.WriteLine(""); } } catch (FormatException e) { Console.WriteLine("\nProvide a valid number greater or equal to 0. Error: " + e.Message); i--; } myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.WriteLine("\nEnd of Application"); // Prevent Auto Closing Console.Read(); }
static void Main(string[] args) { FileReader fr = new FileReader(); List <Staff> myStaff = new List <Staff>(); PaySlip ps; int month = 0, year = 0; while (year == 0) { Console.WriteLine("\nPlease enter the year(yyyy): "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("\nInvalid year. Enter an integer that is greater than 0"); } } while (month == 0) { Console.WriteLine("\nPlease enter the month(1-12): "); try { month = Convert.ToInt32(Console.ReadLine()); if (month > 12 || month < 1) { Console.WriteLine("\nInvalid month. Enter an integer 1-12"); month = 0; } } catch (FormatException) { Console.WriteLine("\nInvalid month. Enter an integer 1-12"); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("Enter hours worked for {0}", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine("Invalid entry try again"); i--; } } ps = new PaySlip(month, year); Console.WriteLine(ps.ToString()); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); int month = 0, year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); string sene = Console.ReadLine(); try { year = Convert.ToInt32(sene); } catch (FormatException) { Console.WriteLine("You have entered non-numeric characters"); year = 0; } } while (month == 0) { Console.Write("\nPlease enter the month: "); string ay = Console.ReadLine(); try { month = Convert.ToInt32(ay); if (month < 1 || month > 12) { Console.WriteLine("You have entered an invalid value"); month = 0; } } catch (FormatException) { Console.WriteLine("You have entered non-numeric characters"); month = 0; } } FileReader fr = new FileReader(); myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { Console.WriteLine("Enter hours worked for {0}:", myStaff[i].NameOfStaff); string hours = Console.ReadLine(); try { myStaff[i].HoursWorked = Convert.ToInt32(hours); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0, year = 0; while (year == 0) { Write("\nPlease enter the year: "); string userInput = ReadLine(); try { year = Int32.Parse(userInput); } catch (FormatException) { WriteLine("Invalid input! Please enter the year!"); } } while (month == 0) { Write("\nPlease enter the month as an integer: "); string userInput = ReadLine(); try { month = Int32.Parse(userInput); if (month < 1 || month > 12) { WriteLine("Invalid input! Please enter the month!"); month = 0; } } catch (FormatException) { WriteLine("Invalid input! Please enter the month as an integer!"); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { WriteLine("\nEnter the hours worked by: {0}", myStaff[i].NameOfStaff + " as an integer."); string input = ReadLine(); myStaff[i].HoursWorked = Int32.Parse(input); myStaff[i].CalculatePay(); Write(myStaff[i].ToString()); } catch (Exception e) { WriteLine(e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); WriteLine("\n\nPaySlips for each employee have been generated as a .txt file in the " + "\"CSProject\\CSProject\\bin\\Debug\" folder " + "along with a summary for those who worked under 10 hours this month. \n\nPress any key to close this console."); ReadKey(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; // gets year from user while (year == 0) { Console.WriteLine("Please enter year: "); try { // Code to convert the input to an interger year = Convert.ToInt32(Console.ReadLine()); } // end try catch (FormatException e) { // Code to handle the exception Console.WriteLine("Unfortunately, there was an error converting the year to an interger: " + e.Message); } // end catch } // end year while // gets month from user while (month == 0) { Console.WriteLine("Please enter month: "); try { month = Convert.ToInt32(Console.ReadLine()); if ((month > 0) && (month < 13)) { continue; } else { Console.WriteLine("Month needs to be between 1 and 12. Please try again."); month = 0; } } // end try catch (FormatException e) { Console.WriteLine("Unfortunately, there was an error converting the month to an interger: " + e.Message); } // end catch } // end month while // reads file and assigns to myStaff myStaff = fr.ReadFile(); // iterate over objects in staff for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("\nEnter hours worked for " + myStaff[i].NameOfStaff + ":"); // user enters hours worked myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); // read hours worked entered by user // calculate pay myStaff[i].CalculatePay(); // display staff info Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { i--; Console.WriteLine("There has been a problem calculating the hours worked. Error message: " + e + " Recalculating..."); } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { //Code to convert the input to an integer year = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { //Code to handle the exception Console.Write(e.Message + "Incorrect Input"); } } while (month == 0) { Console.Write("\nPlease enter a month: "); try { //Code to convert the input to an integer month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.Write("Month is invalid. Try again"); month = 0; } } catch (Exception e) { Console.WriteLine(e.Message + "Error, try again"); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("Enter hours worked for " + myStaff[i].NameOfStaff + ":"); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff.ToString()); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
public static void Main() { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException e) { Console.WriteLine(e.Message); } } while (month == 0) { Console.Write("\nPlease enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Invalid input, please choose between 1 & 12"); month = 0; } } catch (FormatException e) { Console.WriteLine("Error: {0}", e.Message); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("Enter hours worked for {0}: ", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
static void Main(string[] args) { List <Staff> staff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { string temp = Console.ReadLine(); year = Convert.ToInt32(temp); } catch (FormatException) { Console.WriteLine("Error"); } } while (month == 0 || month > 12) { Console.Write("\nPlease enter the year: "); try { string temp = Console.ReadLine(); month = Convert.ToInt32(temp); } catch (FormatException) { Console.WriteLine("Error"); } } var myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count(); i++) { try { Console.Write("Enter hours worked for " + myStaff[i].NameOfStaff + ":"); string hours = Console.ReadLine(); myStaff[i].HoursWorked = Convert.ToInt32(hours); myStaff[i].CalculatePay(); var wri = myStaff[i].ToString(); Console.WriteLine(wri); } catch (Exception e) { Console.WriteLine("Error"); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.ReadKey(); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.Write("\nPlease enter the year: "); try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Sorry, that number sucks..."); } } while (month == 0) { Console.Write("\nPlease enter the month: "); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { throw new FormatException(); } } catch (FormatException) { Console.WriteLine("Sorry, that number sucks..."); month = 0; } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.Write("\nPlease enter the number of Hours Worked by {0}: ", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine("EXCEPTION: {0}", e); i--; } } PaySlip ps = new PaySlip(month, year); Console.WriteLine("Generating Summary..."); ps.GenerateSummary(myStaff); Console.WriteLine("======DONE======"); Console.Read(); }
public static void SetCustomerPaySlip(PaySlip paySlip) { customPaySlip = paySlip; }