Пример #1
0
        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();
        }