private void AddAbsencePreferenceOnScheduler(Person pers)
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);
            List <AbsencePreference> scheduleAbsPreferencesSlotsWeek = bdModel.AbsencePreferences.Where(ws => ws.idPerson == pers.idPerson).ToList();

            //Get all the current week's scheduleSlots

            scheduleAbsPreferencesSlotsWeek = PlanningGeneratorTools.GetAbsPreferenceSlots(slotGenerationScheduler.SelectedDate, bdModel);
            scheduleAbsPreferencesSlotsWeek = scheduleAbsPreferencesSlotsWeek.Where(a => a.idPerson == pers.idPerson).ToList();

            //Add the week's slot in the scheduler
            foreach (AbsencePreference ss in scheduleAbsPreferencesSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = ss.idPerson.ToString() + " " + ss.Person.firstName + " " + ss.Person.name + Environment.NewLine + Environment.NewLine +
                              "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDate.ToString("MM/dd/yyyy"),
                    Start     = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End       = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek = ss.dayOfWeek,
                    Color     = new SolidColorBrush(Colors.Aqua),
                    FirstDay  = ss.firstDay,
                    LastDay   = ss.lastDate,
                    IdShift   = ss.idTimeSlot
                });
            }
        }
        public void LoadScheduleSlotFromDatabase()
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            List <AbsencePreference> scheduleAbsPreferencesSlotsWeek;

            //Get all the current week's scheduleSlots
            scheduleAbsPreferencesSlotsWeek = PlanningGeneratorTools.GetAbsPreferenceSlots(d, bdModel);

            //Add the week's slot in the scheduler
            foreach (AbsencePreference ss in scheduleAbsPreferencesSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = ss.idPerson.ToString() + " " + ss.Person.firstName + " " + ss.Person.name + Environment.NewLine + Environment.NewLine +
                              "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDate.ToString("MM/dd/yyyy"),
                    Start     = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End       = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek = ss.dayOfWeek,
                    Color     = new SolidColorBrush(Colors.Aqua),
                    FirstDay  = ss.firstDay,
                    LastDay   = ss.lastDate,
                    IdShift   = ss.idTimeSlot,
                });
            }
            cbxPeople.SelectedIndex = -1;
            btnSlotScheduleGeneration.Visibility = Visibility.Hidden;
        }
Пример #3
0
        public void LoadScheduleSlotFromDatabase()
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            //Get all the current week's scheduleSlots
            List <ScheduleSlot> scheduleSlotsWeek = PlanningGeneratorTools.GetWeekScheduleSlots(d, bdModel);

            //Add the week's slot in the scheduler
            foreach (ScheduleSlot ss in scheduleSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Mininum : " + ss.minAttendency.ToString(),
                    Start         = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End           = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek     = ss.dayOfWeek,
                    Color         = new SolidColorBrush(Colors.Aqua),
                    FirstDay      = ss.firstDay,
                    LastDay       = ss.lastDay,
                    IdShift       = ss.idTimeSlot,
                    MinAttendency = ss.minAttendency
                });
                this.btnNext.Visibility = Visibility.Visible;
                this.btnPrev.Visibility = Visibility.Visible;
            }
        }
Пример #4
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     dpFirstDay.SelectedDate = PlanningGeneratorTools.GetMondayBefore(DateTime.Today);
     dpLastDay.SelectedDate  = PlanningGeneratorTools.GetSundayAfter(DateTime.Today);
 }