예제 #1
0
        /// <summary>
        /// Open a new window for the workingshifts generation.
        /// When it is finished, all workinshifts are in database.
        /// </summary>
        private void mnWeeksGeneration(object sender, RoutedEventArgs e)
        {
            WeekGenerationWindow weekGenerate = new WeekGenerationWindow(bdModel);

            weekGenerate.ShowDialog();
            PlanningGeneratorTools.ClearWorkingShiftScheduler(mainScheduler);
            updateEvents();
        }
예제 #2
0
        private void btnAbsence_Click(object sender, RoutedEventArgs e)
        {
            addAbsenceWindow absWin = new addAbsenceWindow((Person)cbxPeople.SelectedItem);

            absWin.ShowDialog();
            PlanningGeneratorTools.ClearWorkingShiftScheduler(mainScheduler);
            cbxPeople.SelectedIndex = -1;
            updateEvents();
        }
예제 #3
0
 /// <summary>
 /// Showing selected person workingShifts in the scheduler
 /// </summary>
 private void cbxPeople_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     btnAbsence.Visibility = Visibility.Hidden;
     if (cbxPeople.SelectedIndex != -1)
     {
         PlanningGeneratorTools.ClearWorkingShiftScheduler(mainScheduler);
         List <WorkingShift> personnalWorkingShifts = bdModel.WorkingShifts.Where(ws => ws.idPerson == (int)cbxPeople.SelectedValue).ToList();
         PlanningGeneratorTools.AddWorkingShiftScheduler(personnalWorkingShifts, mainScheduler);
         btnAbsence.Visibility = Visibility.Visible;
     }
 }
        /// <summary>
        /// Remove from schelduler the workingshifts for a specific week in the paramater.
        /// (if the workingShif id is in the list then it is removed)
        /// </summary>
        /// <param name="d">date in the removal week</param>
        /// <param name="bd">database</param>
        public static void RemoveWeekWorkingShiftScheduler(DateTime d, Scheduler scheduler)
        {
            DateTime lastMonday = PlanningGeneratorTools.GetMondayBefore(d);
            DateTime nextMonday = lastMonday.AddDays(7);

            List <Event> eventsToRemove = scheduler.Events.Where(ev => ev.Start >= lastMonday && ev.Start <= nextMonday).ToList();

            foreach (Event ev in eventsToRemove)
            {
                scheduler.DeleteEvent(ev.Id);
            }
        }
예제 #5
0
        /// <summary>
        /// Remove all workingshifts from database and scheduler
        /// </summary>
        private void mnWorkingShiftsRemove(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Confirmez-vous la suppression de toutes les tranches horaires des employés?", "Suppression tranches horaires", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                List <WorkingShift> allWorkingShifts = bdModel.WorkingShifts.ToList();
                PlanningGeneratorTools.RemoveWorkingShiftDataBase(allWorkingShifts, bdModel);
                PlanningGeneratorTools.ClearWorkingShiftScheduler(mainScheduler);
                MessageBox.Show("Traitement terminé", "Plages horaires supprimées dans la BD");
            }
        }
예제 #6
0
        /// <summary>
        /// Save the generated shiftsWorking to the database.
        /// </summary>
        private void btnSaveInDB_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Le traitement peux prendre du temps merci de patienter jusqu'au message indicant la fin du traitement.", "Sauvgarde dans la base de données");

            if (totalWorkingShifts != null)
            {
                PlanningGeneratorTools.PersistWorkingShiftDataBase(totalWorkingShifts, bdModel);
                MessageBox.Show("Traitement terminé", "Plages horaires sauvegardées dans la BD");
                btnSaveInDB.IsEnabled = true;
            }

            btnSaveInDB.IsEnabled = false;
            this.Close();
        }
        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
                });
            }
        }
예제 #8
0
        private void btnGenerationAbs_Click(object sender, RoutedEventArgs e)
        {
            if (isDateChecked() && areDatesCorrect())
            {
                MessageBox.Show("Le traitement peux prendre du temps merci de patienter jusqu'au message indicant la fin du traitement.", "Génération des plages horaires");
                // Disabled simulation's components
                dpFirstDay.IsEnabled    = false;
                dpLastDay.IsEnabled     = false;
                btnGeneration.IsEnabled = false;
                PlanningGeneratorTools.ClearWorkingShiftScheduler(weekGenerationScheduler);

                //gets first and last day
                DateTime firstDay = (DateTime)dpFirstDay.SelectedDate;
                DateTime lastDay  = (DateTime)dpLastDay.SelectedDate;

                List <DateTime>     generationDates = new List <DateTime>();
                List <WorkingShift> shifts          = null;
                while (firstDay < lastDay)
                {
                    Tuple <List <WorkingShift>, List <string> > resultat = new FlowGraph(bdModel.People.ToList(), PlanningGeneratorTools.GetWeekScheduleSlots(firstDay, bdModel), firstDay, bdModel.AbsenceDemands.ToList()).GetShifts();
                    shifts = resultat.Item1;
                    string message = "";
                    int    count   = 0;
                    foreach (string problem in resultat.Item2)
                    {
                        count++;
                        message += (count + ". " + problem + "\n");
                    }
                    if (count > 0)
                    {
                        MessageBox.Show(message);
                    }
                    PlanningGeneratorTools.AddWorkingShiftScheduler(shifts, weekGenerationScheduler);
                    totalWorkingShifts.AddRange(shifts);
                    firstDay = firstDay.AddDays(7); //go to the next week
                }
                MessageBox.Show("Traitement terminé", "Génération des plages horaires");
                btnSaveInDB.IsEnabled = true; //Enable the database recording button
            }
            else
            {
                MessageBox.Show("Veuillez remplir les champs \"Premier jour\" et \"Dernier Jour\"" +
                                "\n" + " et vérifier que le premier jour soit avant ou égal au dernier jour");
            }
        }
        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;
        }
예제 #10
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;
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (isDateChecked() && areDatesCorrect())
            {
                DateTime debut = (DateTime)dpFirstDay.SelectedDate;
                debut = debut.Add(new TimeSpan(Int32.Parse(cbxStartHourHour.Text), Int32.Parse(cbxStartHourMinute.Text), 0));

                DateTime fin = (DateTime)dpLastDay.SelectedDate;
                fin = fin.Add(new TimeSpan(Int32.Parse(cbxEndHourHour.Text), Int32.Parse(cbxEndHourMinute.Text), 0));

                List <WorkingShift> holidayWorkingShifts = bdModel.WorkingShifts.Where(ws => ws.idPerson == persSelected.idPerson && ws.start >= debut && ws.end <= fin).ToList();
                PlanningGeneratorTools.RemoveWorkingShiftDataBase(holidayWorkingShifts, bdModel);

                this.Close();
            }
            else
            {
                MessageBox.Show("Veuillez remplir les champs \"Premier jour\" et \"Dernier Jour\"" +
                                "\n" + " et vérifier que le premier jour soit avant ou égal au dernier jour");
            }
        }
 private void btnShowAllWorkingShifts_Click(object sender, RoutedEventArgs e)
 {
     cbxPeople.SelectedIndex = -1; //set to null
     PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);
     LoadScheduleSlotFromDatabase();
 }
예제 #13
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     dpFirstDay.SelectedDate = PlanningGeneratorTools.GetMondayBefore(DateTime.Today);
     dpLastDay.SelectedDate  = PlanningGeneratorTools.GetSundayAfter(DateTime.Today);
 }
예제 #14
0
 /// <summary>
 /// Showing all people workingShifts in the scheduler
 /// </summary>
 private void btnShowAllWorkingShifts_Click(object sender, RoutedEventArgs e)
 {
     cbxPeople.SelectedIndex = -1; //set to null
     PlanningGeneratorTools.ClearWorkingShiftScheduler(mainScheduler);
     PlanningGeneratorTools.AddWorkingShiftScheduler(bdModel.WorkingShifts.ToList(), mainScheduler);
 }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     sllist = PlanningGeneratorTools.GetScheduleSlot(bd);
 }