private bool IsConflictingWithExistingShift(ScheduleShift scheduleShift)
        {
            bool res = false;

            foreach (Shift s in Shifts)
            {
                ScheduleShift currShift = (ScheduleShift)s;
                if (scheduleShift.Employee != currShift.Employee)
                {
                    if (scheduleShift.StartTime < currShift.StartTime &&
                        (scheduleShift.StartTime.AddHours(scheduleShift.Hours) > currShift.StartTime))
                    {
                        res = true;
                    }
                    else if (scheduleShift.StartTime > currShift.StartTime &&
                             (currShift.StartTime.AddHours(currShift.Hours) > scheduleShift.StartTime))
                    {
                        res = true;
                    }
                    else if (scheduleShift.StartTime == currShift.StartTime)
                    {
                        res = true;
                    }
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public Schedule GetScheduleByCurrentDate(DateTime currentDate)
        {
            Employee employee = new Employee()
            {
                Name = "Arne"
            };
            ScheduleShift scheduleShift1 = new ScheduleShift()
            {
                StartTime = new DateTime(2017, 11, 13, 9, 0, 0), Hours = 5, Employee = employee
            };
            ScheduleShift scheduleShift2 = new ScheduleShift()
            {
                StartTime = new DateTime(2017, 11, 14, 11, 0, 0), Hours = 7, Employee = employee
            };
            ScheduleShift scheduleShift3 = new ScheduleShift()
            {
                StartTime = new DateTime(2017, 11, 17, 10, 0, 0), Hours = 3, Employee = employee
            };

            Schedule schedule = new Schedule()
            {
                Shifts = new List <ScheduleShift>()
            };

            schedule.Shifts.Add(scheduleShift1);
            schedule.Shifts.Add(scheduleShift2);
            schedule.Shifts.Add(scheduleShift3);

            return(schedule);
        }
Exemplo n.º 3
0
        public void FillCell(Shift shift, bool isFirstElement, bool isLastElement)
        {
            Color color = Colors.RoyalBlue;

            if (shift.GetType() == typeof(ScheduleShift))
            {
                ScheduleShift scheduleShift = (ScheduleShift)shift;
                color = scheduleShift.IsForSale ? Colors.Red : Colors.RoyalBlue;
            }


            ShiftElement shiftElement = null;

            if (isFirstElement)
            {
                shiftElement = new ShiftElement(shift, color);
                Grid.SetRowSpan(this, 2);

                // Border.BorderThickness = new Thickness(0.1, 0.1, 0.1, 0);
            }
            else if (isLastElement)
            {
                shiftElement = new ShiftElement(shift, color, true);
                //Border.BorderThickness = new Thickness(0.1, 0, 0.1, 0.1);
            }
            else // Middle Element
            {
                shiftElement = new ShiftElement(shift, color, false);
                // Border.BorderThickness = new Thickness(0.1, 0, 0.1, 0);
            }
            TimeCellGrid.ColumnDefinitions.Add(new ColumnDefinition());
            TimeCellGrid.Children.Add(shiftElement);
            Grid.SetColumn(shiftElement, ShiftsInCell.Count);
            ShiftsInCell.Add(shift);
        }
Exemplo n.º 4
0
        public void InsertScheduleServiceTest()
        {
            DbSetUp.SetUpDb();

            ScheduleShift shift1 = new ScheduleShift()
            {
                Employee = new EmployeeRepository().GetEmployeeByUsername("MikkelP"), Hours = 8, StartTime = new DateTime(2017, 11, 28, 8, 0, 0)
            };
            Department department = new DepartmentRepository().GetDepartmentById(4);
            Schedule   schedule   = new Schedule()
            {
                Department = department, StartDate = new DateTime(2017, 11, 27, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2017, 12, 15)
            };

            schedule.Shifts.Add(shift1);

            _scheduleServiceClient.InsertScheduleToDb(schedule);

            schedule = _scheduleServiceClient.GetScheduleByDepartmentIdAndDate(4, new DateTime(2017, 11, 28, 0, 0, 0));

            Assert.IsNotNull(schedule);
            Assert.AreEqual(1, schedule.Shifts.Count);
            Assert.AreEqual("Mikkel Paulsen", schedule.Shifts[0].Employee.Name);
            Assert.AreEqual("Elektronik", schedule.Department.Name);

            DbSetUp.SetUpDb();
        }
        public IEnumerable <ScheduleShift> GetAllAvailableShiftsByDepartmentId(int departmentId)
        {
            List <ScheduleShift> scheduleShifts = new List <ScheduleShift>();

            using (SqlConnection connection = new DbConnection().GetConnection())
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM ScheduleShift WHERE isForSale = 1;";

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ScheduleShift scheduleShift = BuildShiftObject(reader);
                            if (scheduleShift.Employee.DepartmentId == departmentId)
                            {
                                scheduleShifts.Add(scheduleShift);
                            }
                        }
                    }
                }
            }
            return(scheduleShifts);;
        }
Exemplo n.º 6
0
        public ActionResult AcceptShift(ScheduleShift scheduleShift)
        {
            Employee employee = (Employee)Session["employee"];

            _scheduleShiftProxy.AcceptAvailableShift(scheduleShift, employee);
            return(null);
        }
        public ActionResult AcceptShift(ScheduleShift scheduleShift)
        {
            Employee employee = (Employee)Session["employee"];

            _scheduleShiftProxy.AcceptAvailableShift(scheduleShift, employee);

            return(RedirectToAction("Index", "AvailableShifts"));
        }
Exemplo n.º 8
0
        public void SetScheduleShiftForSale(ScheduleShift scheduleShift)
        {
            _scheduleShiftRepository.SetScheduleShiftForSale(scheduleShift);
            MailSender mailSender = new MailSender();
            string     subject    = "A new shift has been set for sale";
            string     text       = scheduleShift.Employee.Name + " has set a shift starting " + scheduleShift.StartTime + " and has a length of " + scheduleShift.Hours + " hours for sale.";

            mailSender.SendMailToEmployeesInDepartmentByDepartmentId(subject, text, scheduleShift.Employee.DepartmentId);
        }
Exemplo n.º 9
0
        public int OverlapsWithShiftsInList(Shift shift, List <Shift> shifts)
        {
            int res = 0;

            if (shift.GetType() == typeof(TemplateShift))
            {
                TemplateShift templateShift = (TemplateShift)shift;
                foreach (Shift s in shifts)
                {
                    TemplateShift currShift = (TemplateShift)s;
                    if (templateShift.Employee != currShift.Employee)
                    {
                        if (templateShift.StartTime < currShift.StartTime &&
                            (templateShift.StartTime.Add(new TimeSpan((int)templateShift.Hours, 0, 0))) > currShift.StartTime)
                        {
                            res++;
                        }
                        else if (templateShift.StartTime > currShift.StartTime &&
                                 (currShift.StartTime.Add(new TimeSpan((int)currShift.Hours, 0, 0))) > templateShift.StartTime)
                        {
                            res++;
                        }
                        else if (templateShift.StartTime == currShift.StartTime)
                        {
                            res++;
                        }
                    }
                }
            }
            else if (shift.GetType() == typeof(ScheduleShift))
            {
                ScheduleShift scheduleShift = (ScheduleShift)shift;
                foreach (Shift s in shifts)
                {
                    ScheduleShift currShift = (ScheduleShift)s;
                    if (scheduleShift.Employee != currShift.Employee)
                    {
                        if (scheduleShift.StartTime < currShift.StartTime &&
                            (scheduleShift.StartTime.AddHours(scheduleShift.Hours) > currShift.StartTime))
                        {
                            res++;
                        }
                        else if (scheduleShift.StartTime > currShift.StartTime &&
                                 (currShift.StartTime.AddHours(currShift.Hours) > scheduleShift.StartTime))
                        {
                            res++;
                        }
                        else if (scheduleShift.StartTime == currShift.StartTime)
                        {
                            res++;
                        }
                    }
                }
            }
            return(res);
        }
Exemplo n.º 10
0
        public void AcceptAvailableShiftTest()
        {
            ScheduleShift shift    = _scheduleShiftRepository.GetShiftById(1);
            Employee      employee = new EmployeeRepository().GetEmployeeById(5);

            Assert.AreNotEqual(shift.Employee, employee);
            _scheduleShiftRepository.AcceptAvailableShift(shift, employee);
            shift = _scheduleShiftRepository.GetShiftById(1);
            Assert.AreEqual(shift.Employee.Name, employee.Name);
            Assert.AreEqual(shift.IsForSale, false);
        }
 public void DeleteScheduleShift(ScheduleShift scheduleShift)
 {
     using (SqlConnection connection = new DbConnection().GetConnection())
     {
         using (SqlCommand deleteScheduleShift = new SqlCommand(
                    "DELETE FROM ScheduleShift WHERE id = @param1", connection))
         {
             deleteScheduleShift.Parameters.AddWithValue(@"param1", scheduleShift.Id);
             deleteScheduleShift.ExecuteNonQuery();
         }
     }
 }
        private ScheduleShift BuildShiftObject(SqlDataReader reader)
        {
            ScheduleShift scheduleShift = new ScheduleShift();

            scheduleShift.Id         = reader.GetInt32(0);
            scheduleShift.Employee   = new EmployeeRepository().GetEmployeeById(Convert.ToInt32(reader["EmployeeId"].ToString()));
            scheduleShift.StartTime  = reader.GetDateTime(1);
            scheduleShift.Hours      = Convert.ToDouble(reader["Hours"].ToString());
            scheduleShift.IsForSale  = Convert.ToBoolean(reader["IsForSale"]);
            scheduleShift.RowVersion = reader.GetFieldValue <byte[]>(6);
            return(scheduleShift);
        }
        public void IllegalIsForSaleAcceptAvailableShiftTest()
        {
            ScheduleShift shift = new ScheduleShift()
            {
                StartTime = DateTime.Now.AddDays(1),
                Hours     = 4,
                Employee  = new Employee(),
                IsForSale = false,
            };
            Employee employee = new Employee();

            _scheduleShiftController.AcceptAvailableShift(shift, employee);
        }
Exemplo n.º 14
0
        public void SetShiftForSaleTest()
        {
            int                  scheduleId    = 1;
            Schedule             schedule      = new ScheduleController().GetSchedulesByDepartmentId(scheduleId)[0];
            List <ScheduleShift> shifts        = schedule.Shifts;
            ScheduleShift        scheduleShift = shifts[1];

            Assert.IsFalse(scheduleShift.IsForSale);
            scheduleShift.IsForSale = true;
            _scheduleShiftRepository.AddShiftsFromSchedule(schedule);
            List <ScheduleShift> shiftsAfterUpdate = _scheduleShiftRepository.GetShiftsByScheduleId(scheduleId);

            Assert.IsTrue(shiftsAfterUpdate[1].IsForSale);
        }
Exemplo n.º 15
0
        public void UpdateScheduleFailTest()
        {
            Schedule schedule = new ScheduleController().GetSchedulesByDepartmentId(1)[0];

            ScheduleShift scheduleShift = schedule.Shifts[0];

            byte[] rowVersion1 = scheduleShift.RowVersion;
            scheduleShift.Hours = 100;

            _scheduleShiftRepository.AddShiftsFromSchedule(schedule);

            //This is where the exception should be thrown
            _scheduleShiftRepository.AddShiftsFromSchedule(schedule);
        }
Exemplo n.º 16
0
        private void OnHandleDrop(object sender, DragEventArgs e)
        {
            object droppedItem = e.Data.GetData("Object");

            if (droppedItem.GetType().IsSubclassOf(typeof(Shift)))
            {
                Shift droppedShift = (Shift)e.Data.GetData("Object");

                bool isLastElement = (bool)e.Data.GetData("IsLastShiftElement");
                if (isLastElement)
                {
                    if (droppedShift.GetType() == typeof(TemplateShift))
                    {
                        TemplateShift ts    = (TemplateShift)droppedShift;
                        double        hours = (Time.Subtract(ts.StartTime).Add(new TimeSpan(0, TemplateScheduleCalendar.INCREMENT, 0)).TotalHours);
                        ts.Hours = hours > 0 ? hours : 1;
                    }
                    else if (droppedShift.GetType() == typeof(ScheduleShift))
                    {
                        ScheduleShift ss    = (ScheduleShift)droppedShift;
                        double        hours = (Time.Hours - (ss.StartTime.Hour)); //+ TemplateScheduleCalendar.INCREMENT);
                        droppedShift.Hours = hours > 0 ? hours : 1;
                    }
                }
                else
                {
                    if (droppedShift.GetType() == typeof(TemplateShift))
                    {
                        TemplateShift ts = (TemplateShift)droppedShift;
                        ts.StartTime = Time;
                        ts.WeekDay   = WeekDay;
                        droppedShift = ts;
                    }
                    else if (droppedShift.GetType() == typeof(ScheduleShift))
                    {
                        ScheduleShift ss = (ScheduleShift)droppedShift;
                        DateTime      dt = new DateTime(ss.StartTime.Year, ss.StartTime.Month, (int)WeekDay, Time.Hours, Time.Minutes, 0);
                        ss.StartTime = dt;
                        droppedShift = ss;
                    }
                }
                Mediator.GetInstance().OnShiftDropped(sender, droppedShift, isLastElement);
            }
            else if (droppedItem.GetType() == typeof(Employee))
            {
                Employee employee = (Employee)droppedItem;
                Mediator.GetInstance().OnEmployeeDropped(employee, Time, WeekDay);
            }
        }
Exemplo n.º 17
0
 public void SetShiftDropHandler()
 {
     Mediator.GetInstance().ShiftDropped += (s, e) =>
     {
         Clear();
         if (!e.IsLastElement && IsVisible)
         {
             ScheduleShift ss = (ScheduleShift)e.Shift;
             DateBox       db = DateBoxes[ss.StartTime.Day - 1];
             DateTime      dt = new DateTime(db.Date.Year, db.Date.Month, db.Date.Day, ss.StartTime.Hour, ss.StartTime.Minute, 0);
             ss.StartTime = dt;
         }
         LoadShiftsIntoCalendar();
     };
 }
Exemplo n.º 18
0
 /// <summary>
 /// This method is used when a user wants to accept a shift, that is available for sale.
 /// The method will also call the MailGun api method to send a mail to the employee whom accepted a shift.
 /// </summary>
 /// <param name="shift"></param>
 /// <param name="employee"></param>
 public void AcceptAvailableShift(ScheduleShift shift, Employee employee)
 {
     if (shift.IsForSale)
     {
         _scheduleShiftRepository.AcceptAvailableShift(shift, employee);
         MailSender   mailSender = new MailSender();
         const string subject    = "A shift has been accepted";
         string       text       = "The shift starting " + shift.StartTime + " and has a length of " + shift.Hours + " hours has been accepted by " + employee.Name;
         mailSender.SendMailToEmployeesInDepartmentByDepartmentId(subject, text, employee.DepartmentId);
     }
     else
     {
         throw new ArgumentException("Failure to accept shift. One or more arguments are illegal!");
     }
 }
Exemplo n.º 19
0
        public List <ScheduleShift> GenerateShiftsFromTemplateSchedule(TemplateSchedule templateSchedule, DateTime startTime)
        {
            List <ScheduleShift> scheduleShifts = new List <ScheduleShift>();

            foreach (TemplateShift templateShift in templateSchedule.TemplateShifts)
            {
                ScheduleShift shift = new ScheduleShift();
                shift.Employee  = templateShift.Employee;
                shift.Hours     = templateShift.Hours;
                shift.StartTime = startTime.AddDays(((int)templateShift.WeekDay - 1) + (templateShift.WeekNumber - 1) * 7);
                shift.StartTime = shift.StartTime.AddHours(templateShift.StartTime.Hours);
                shift.StartTime = shift.StartTime.AddMinutes(templateShift.StartTime.Minutes);
                scheduleShifts.Add(shift);
            }
            return(scheduleShifts);
        }
Exemplo n.º 20
0
 public void LoadShiftsIntoCalendar()
 {
     foreach (var shift in Shifts)
     {
         ScheduleShift s = (ScheduleShift)shift;
         foreach (var dbox in DateBoxes)
         {
             if (dbox.Date.Day == s.StartTime.Day && dbox.Date.Month == s.StartTime.Month)
             {
                 DayColumn dayCol = GetDayCoulmByName(s.StartTime.DayOfWeek.ToString());
                 dayCol.Shifts.Add(shift);
             }
         }
     }
     DayColumnList.ForEach(x => x.RenderShifts());
 }
        public void AcceptAvailableShiftTest()
        {
            //TODO

            ScheduleShift shift = new ScheduleShift()
            {
                StartTime = DateTime.Now.AddDays(-1),
                Hours     = 4,
                Employee  = new Employee(),
                IsForSale = true,
            };
            Employee employee = new Employee();

            _scheduleShiftController.AcceptAvailableShift(shift, employee);
            //_scheduleshiftcontroller.sch .assertwascalled(x => x.acceptavailableshift(shift, employee));
        }
        public void InsertOverlappingScheduleTest()
        {
            DbSetUp.SetUpDb();

            _scheduleController = new ScheduleController(new ScheduleRepository());

            Schedule schedule1 = new Schedule()
            {
                Department = new Department()
                {
                    Id = 1
                },
                StartDate = new DateTime(2018, 12, 4),
                EndDate   = new DateTime(2018, 12, 11),
                Shifts    = new List <ScheduleShift>(),
            };

            ScheduleShift shift1 = new ScheduleShift()
            {
                Employee = new EmployeeRepository().GetEmployeeByUsername("MikkelP"), Hours = 8, StartTime = new DateTime(2018, 12, 5, 8, 0, 0)
            };

            schedule1.Shifts.Add(shift1);
            _scheduleController.InsertScheduleToDb(schedule1);

            Schedule schedule2 = new Schedule()
            {
                Department = new Department()
                {
                    Id = 1
                },
                StartDate = new DateTime(2018, 11, 27),
                EndDate   = new DateTime(2018, 12, 5),
                Shifts    = new List <ScheduleShift>(),
            };

            ScheduleShift shift2 = new ScheduleShift()
            {
                Employee = new EmployeeRepository().GetEmployeeByUsername("MikkelP"), Hours = 8, StartTime = new DateTime(2018, 11, 28, 8, 0, 0)
            };

            schedule1.Shifts.Add(shift2);

            _scheduleController.InsertScheduleToDb(schedule2);

            DbSetUp.SetUpDb();
        }
Exemplo n.º 23
0
        public void UpdateScheduleTest()
        {
            Schedule      schedule      = new ScheduleController().GetSchedulesByDepartmentId(1)[0];
            ScheduleShift scheduleShift = schedule.Shifts[0];
            int           shiftId       = 0;

            byte[] rowVersion1 = scheduleShift.RowVersion;
            scheduleShift.Hours = 100;

            _scheduleShiftRepository.AddShiftsFromSchedule(schedule);

            scheduleShift = _scheduleShiftRepository.GetShiftById(shiftId);
            byte[] rowVersion2 = scheduleShift.RowVersion;

            Assert.IsNotNull(scheduleShift);
            Assert.AreNotEqual(rowVersion1, rowVersion2);
        }
Exemplo n.º 24
0
        public bool ValidateScheduleShiftObject(ScheduleShift scheduleShift, Schedule schedule)
        {
            bool isOkToInsert = true;

            if (scheduleShift.Employee == null)
            {
                isOkToInsert = false;
            }
            else if (scheduleShift.Hours < 0)
            {
                isOkToInsert = false;
            }
            else if (scheduleShift.StartTime == null)
            {
                isOkToInsert = false;
            }
            return(isOkToInsert);
        }
Exemplo n.º 25
0
 public void SetEmployeeDroppedHandler()
 {
     Mediator.GetInstance().EmployeeDropped += (e, tod, dow) =>
     {
         if (IsVisible)
         {
             Clear();
             ScheduleShift ss = new ScheduleShift();
             DateBox       db = DateBoxes[(int)dow - 1];
             DateTime      dt = new DateTime(db.Date.Year, db.Date.Month, db.Date.Day, tod.Hours, tod.Minutes, 0);
             ss.StartTime = dt;
             ss.Employee  = e;
             ss.Hours     = DEFAULTSHIFTLENGTH;
             Shifts.Add(ss);
             LoadShiftsIntoCalendar();
         }
     };
 }
        private void UpdateScheduleShift(ScheduleShift shift, int scheduleId, SqlConnection connection)
        {
            try
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "UPDATE ScheduleShift SET startTime = @param1, hours = @param2, " +
                                          "scheduleId = @param3, IsForSale = @param4 WHERE ScheduleShift.id = @param5 AND RV = @param6";

                    SqlParameter p1 = new SqlParameter("@param1", SqlDbType.DateTime, 100);
                    SqlParameter p2 = new SqlParameter("@param2", SqlDbType.Float);
                    SqlParameter p3 = new SqlParameter("@param3", SqlDbType.Int);
                    SqlParameter p4 = new SqlParameter("@param4", SqlDbType.Bit);
                    SqlParameter p5 = new SqlParameter("@param5", SqlDbType.Int);
                    command.Parameters.AddWithValue("@param6", shift.RowVersion);

                    p1.Value = shift.StartTime;
                    p2.Value = shift.Hours;
                    p3.Value = scheduleId;
                    p4.Value = shift.IsForSale;
                    p5.Value = shift.Id;

                    command.Parameters.Add(p1);
                    command.Parameters.Add(p2);
                    command.Parameters.Add(p3);
                    command.Parameters.Add(p4);
                    command.Parameters.Add(p5);

                    int rowsAffected = command.ExecuteNonQuery();
                    if (rowsAffected == 0)
                    {
                        throw new DataInInvalidStateException();
                    }
                }
            }
            catch (DataInInvalidStateException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new Exception("Something went wrong in UpdateShifts!" + e.Message);
            }
        }
Exemplo n.º 27
0
        public void InsertScheduleTest()
        {
            ScheduleShift shift1 = new ScheduleShift()
            {
                Employee = new EmployeeRepository().GetEmployeeByUsername("MikkelP"), Hours = 8, StartTime = new DateTime(2017, 11, 28, 8, 0, 0)
            };
            Schedule schedule = new Schedule()
            {
                Department = new DepartmentRepository().GetDepartmentById(3), StartDate = new DateTime(2017, 11, 27, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2017, 12, 18, 0, 0, 0, DateTimeKind.Utc)
            };

            schedule.Shifts.Add(shift1);

            int beforeInsert = _scheduleRepository.GetSchedulesByDepartmentId(3).Count;
            int afterInsert  = 0;

            _scheduleRepository.InsertSchedule(schedule);
            afterInsert = _scheduleRepository.GetSchedulesByDepartmentId(3).Count;
            Assert.AreEqual(beforeInsert, afterInsert - 1);
        }
 /// <summary>
 /// This method will set the chosen Shift that an employee has picked, for "sale" in the System.
 /// This means that other employees will be able to take this shifts, and make it theirs.
 /// </summary>
 /// <param name="scheduleShift"></param>
 public void SetScheduleShiftForSale(ScheduleShift scheduleShift)
 {
     try
     {
         using (SqlConnection connection = new DbConnection().GetConnection())
         {
             using (SqlCommand command = connection.CreateCommand())
             {
                 command.CommandText = "UPDATE ScheduleShift SET IsForSale = @param1 WHERE Id = @param2";
                 command.Parameters.AddWithValue("@param1", true);
                 command.Parameters.AddWithValue("@param2", scheduleShift.Id);
                 command.ExecuteNonQuery();
             }
         }
     }
     catch (Exception e)
     {
         throw new Exception("Something went wrong when setting the shift for sale." + e.Message);
     }
 }
Exemplo n.º 29
0
        private void SetTextHeader(Shift shift)
        {
            ScheduleShift scheduleShift = null;
            TemplateShift templateShift = null;

            if (shift.GetType() == typeof(ScheduleShift))
            {
                scheduleShift = (ScheduleShift)shift;
                TextBox1.Text = scheduleShift.Employee.Name;
                TextBox2.Text = scheduleShift.StartTime.ToShortTimeString() + " - " + scheduleShift.StartTime.AddHours(scheduleShift.Hours).ToShortTimeString();
            }
            else
            {
                templateShift = (TemplateShift)shift;
                int      minutes   = (int)(60 * (templateShift.Hours - (int)templateShift.Hours));
                DateTime startTime = new DateTime(2017, 1, 1, templateShift.StartTime.Hours, templateShift.StartTime.Minutes, 0);
                DateTime endTime   = startTime.AddHours(templateShift.Hours);

                TextBox1.Text = templateShift.Employee.Name;
                TextBox2.Text = startTime.ToShortTimeString() + " - " + endTime.ToShortTimeString();
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Adds the work period assignment specified by <see cref="CodeTerm"/> to the schedule.
        /// </summary>
        /// <param name="codeTerm">A <see cref="CodeTerm"/> that references an <see cref="CodeCompoundTerm"/>.</param>
        /// <remarks>
        /// Work periods assignment are compound terms of the form <code>workPeriodAssignment(person,workPeriod(day,shift))</code>.
        /// </remarks>
        private void ProcessWorkPeriodAssignment(CodeTerm codeTerm)
        {
            if (codeTerm == null)
            {
                throw new ArgumentNullException("codeTerm");
            }
            if (!codeTerm.IsCodeCompoundTerm)
            {
                throw new ArgumentException("CodeCompoundTerm not specified.", "codeTerm");
            }

            CodeCompoundTerm codeCompoundTerm = codeTerm.AsCodeCompoundTerm;

            if (codeCompoundTerm.Functor != _workPeriodAssignmentFunctor)
            {
                throw new ArgumentException("Functor workPeriodAssignment not specified.", "codeTerm");
            }

            string        person        = ProcessPerson(codeCompoundTerm.Children[0]);
            ScheduleShift scheduleShift = ProcessWorkPeriod(codeCompoundTerm.Children[1]);

            scheduleShift.Name = person;
        }
Exemplo n.º 31
0
 public ScheduleDay()
 {
     Third = new ScheduleShift();
     Second = new ScheduleShift();
     First = new ScheduleShift();
 }