Beispiel #1
0
 public void SetWorkableDays()
 {
     do
     {
         Employee employee   = GetEmployee();
         int      employeeid = Reader.GetEmployeeId(employee.FirstName, employee.LastName);
         while (Reader.DoesWorkablebyEIDExist(employeeid))
         {
             Console.WriteLine("Sorry but that employee's workable days have been set, try a different employee.");
             employee   = GetEmployee();
             employeeid = Reader.GetEmployeeId(employee.FirstName, employee.LastName);
         }
         int  mon = 0;
         int  tues = 0;
         int  wed = 0;
         int  thurs = 0;
         int  fri = 0;
         bool monFact = false, tuesFact = false, wedFact = false, thursFact = false, friFact = false;
         for (int i = 0; i < 5; i++)
         {
             string day = GetDay(i + 1);
             if (i == 0)
             {
                 if (Lawyer.GetYesNo("Is the employee " + employee.FirstName + " " + employee.LastName + " able to work " + day))
                 {
                     mon     = 1;
                     monFact = true;
                 }
             }
             else if (i == 1)
             {
                 if (Lawyer.GetYesNo("Is the employee " + employee.FirstName + " " + employee.LastName + " able to work " + day))
                 {
                     tues     = 1;
                     tuesFact = true;
                 }
             }
             else if (i == 2)
             {
                 if (Lawyer.GetYesNo("Is the employee " + employee.FirstName + " " + employee.LastName + " able to work " + day))
                 {
                     wed     = 1;
                     wedFact = true;
                 }
             }
             else if (i == 3)
             {
                 if (Lawyer.GetYesNo("Is the employee " + employee.FirstName + " " + employee.LastName + " able to work " + day))
                 {
                     thurs     = 1;
                     thursFact = true;
                 }
             }
             else if (i == 4)
             {
                 if (Lawyer.GetYesNo("Is the employee " + employee.FirstName + " " + employee.LastName + " able to work " + day))
                 {
                     fri     = 1;
                     friFact = true;
                 }
             }
         }
         if (Lawyer.GetYesNo("Are you sure you want to set the days for " + employee.FirstName + " " + employee.LastName + " and their workable late days to be Monday: " + monFact + " Tuesday:" + tuesFact + " Wednesday: " + wedFact + " Thursday: " + thursFact + " Friday: " + friFact))
         {
             Creator.AddWorkableDays(employeeid, mon, tues, wed, thurs, fri);
             Console.Clear();
         }
         Console.Clear();
     } while (Lawyer.GetYesNo("Do you want to set the workable days for another employee"));
 }
Beispiel #2
0
 public void AddSickDay(Employee employee, int year = 0, int month = 0)
 {
     do
     {
         List <DateTime> dates = GetDates("sick-leave");
         if (year == 0 && month == 0)
         {
             dates = GetDates("sick-leave");
         }
         else if (year > 0 && month == 0)
         {
             dates = GetDates("sick-leave", year);
         }
         else if (month > 0 && year > 0)
         {
             dates = GetDates("sick-leave", year, month);
         }
         DateTime startdate = dates[0];
         DateTime enddate   = dates[1];
         DateTime date      = startdate;
         bool     fact      = true;
         do
         {
             var day = date.DayOfWeek.ToString();
             int notworkingemployees = Reader.GetNumberOfOffEmployees(date) + Reader.GetNumberOfSickEmployees(date) + Reader.GetNumberOfVacaEmployees(date);
             int workableemployees   = Reader.GetNumberOfWorkableEmployees(date);
             if ((day != "Saturday") && (day != "Sunday"))
             {
                 if ((notworkingemployees - workableemployees) > (GetEmployees() / 2) - 3)
                 {
                     Console.WriteLine("Sorry but there is a conflict with this day:" + date.ToString());
                     Console.ReadLine();
                     fact = false;
                 }
             }
             date = date.AddDays(1.0);
         } while ((!(date > enddate)) && fact);
         bool conflictfact = DoesConflictExist(employee.ID, startdate, enddate);
         if (fact && !(conflictfact))
         {
             if (Lawyer.GetYesNo("Are you sure you want to add the sick day/s of " + employee.PrintName() + " from " + startdate.ToLongDateString() + " to " + enddate.ToLongDateString()))
             {
                 Creator.AddSickDay(employee.ID, startdate, enddate);
             }
         }
         else if (conflictfact)
         {
             Console.WriteLine("Sorry but there was a conflict with trying to schedule this employee for the given sick days.");
             Console.ReadLine();
         }
         else if (!fact)
         {
             Console.WriteLine("Not enough workers some how");
             Console.ReadLine();
         }
         Console.Clear();
         if (Lawyer.GetYesNo("Do you want to add sick days for the same employee?"))
         {
             if (Lawyer.GetYesNo("Do you want to add sick days for this employee using the same year?"))
             {
                 if (Lawyer.GetYesNo("Do you want to add sick days for this employee using the same month?"))
                 {
                     AddSickDay(employee, int.Parse(date.Year.ToString()), int.Parse(date.Month.ToString()));
                 }
                 else
                 {
                     AddSickDay(employee, int.Parse(date.Year.ToString()));
                 }
             }
             else
             {
                 AddSickDay(employee);
             }
         }
     } while (Lawyer.GetYesNo("Do you want to add a sick days for another employee?"));
 }