Exemple #1
0
        // GET: HomeController1/Edit/5
        public ActionResult Edit(int id)
        {
            Absences abs = _context.Absences.Where(
                x => x.ID == id).SingleOrDefault();

            var at = new List <SelectListItem>();

            foreach (AbsencesType absencesType in Enum.GetValues(typeof(AbsencesType)))
            {
                at.Add(new SelectListItem
                {
                    Text  = Enum.GetName(typeof(AbsencesType), absencesType),
                    Value = absencesType.ToString()
                });
            }

            ViewBag.AbsenceType = at;

            var person = _context.Persons.FirstOrDefault(x => x.ID == abs.PersonID);

            ViewBag.Person = person.Name;


            return(View(abs));
        }
        /// <summary>
        /// affiche les valeurs en vue de leurs modifications
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModifierAbsence_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Voulez-vous modifier une absence ?", "Confirmation de modification", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (dgvAbsence.SelectedRows.Count > 0)
                {
                    DateTimePickerCustomFormat();
                    btnEnregistrerAbsence.Enabled = true;
                    btnAnnulerAbsence.Enabled     = true;
                    grbGestionAbsences.Enabled    = true;
                    btnEnregistrer.Enabled        = true;
                    btnAnnuler.Enabled            = true;
                    dtpDateDebutDate.Enabled      = true;

                    dtpDateFinDate.Enabled  = true;
                    cboMotif.Enabled        = true;
                    enCoursDeModifAbsences  = true;
                    grbGestionAbsences.Text = "modification d'une absence";
                    Absences absences = (Absences)bdgAbsences.List[bdgAbsences.Position];
                    dtpDateDebutDate.Value = absences.Datedebut;
                    dtpDateFinDate.Value   = absences.Datefin;
                    cboMotif.SelectedIndex = cboMotif.FindStringExact(absences.Motif);
                }
                else
                {
                    MessageBox.Show("Une ligne doit être sélectionnée.", "Information");
                }
            }
        }
        private void LoadWorkingAndAbsencesHours()
        {
            long[] ids = PlanningWeekProcessor.ListToEmployeeIds(_storeEmployees);

            List <WorkingTimePlanning> _workingTimes = ClientEnvironment.WorkingTimePlanningService.GetWorkingTimePlanningsByEmployeeIds(ids, StartDate, EndDate);
            List <AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetAbsenceTimePlanningsByEmployeeIds(ids, StartDate, EndDate);

            Absences.FillAbsencePlanningTimes(_absenceTimes);

            PlanningWeekProcessor.AssignTimes(_storeEmployees, _workingTimes, _absenceTimes);
        }
        /// <summary>
        /// suppression d'une absence
        /// </summary>
        /// <param name="absences">objet absence à supprimer</param>
        public static void DelAbsences(Absences absences)
        {
            string req = "delete from absence where idpersonnel = @idpersonnel and datedebut = @datedebut;";
            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "@idpersonnel", absences.Idpersonnel },
                { "@datedebut", absences.Datedebut }
            };
            ConnexionBDD conn = ConnexionBDD.GetInstance(stringConnect);

            conn.ReqUpdate(req, parameters);
        }
        /// <summary>
        /// enregistrement de l'ajout ou de la modification de l'absence
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEnregistrerAbsence_Click(object sender, EventArgs e)
        {
            grbGestionAbsences.Text       = "Enregistrement d'une absence";
            btnEnregistrerAbsence.Enabled = true;
            btnAnnulerAbsence.Enabled     = true;

            string format = "yyyy-MM-dd HH:mm:ss";

            if (dtpDateDebutDate.CustomFormat == format)
            {
                if (TestDateTimePicker(dtpDateDebutDate, dtpDateFinDate))
                {
                    DateTime datedebut = dtpDateDebutDate.Value;
                    DateTime datefin   = dtpDateFinDate.Value;
                    Motif    motif     = (Motif)bdgMotifs.List[bdgMotifs.Position];
                    Service  service   = (Service)bdgServices.List[bdgServices.Position];
                    if (MessageBox.Show("Voulez-vous enregistrer les modifications ? ", "Confirmation d'enregistrement", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        int idpersonnel = 0;

                        if (enCoursDeModifAbsences)
                        {
                            idpersonnel = (int)dgvPersonnel.SelectedRows[0].Cells["idpersonnel"].Value;
                            Absences absences     = new Absences(idpersonnel, datedebut, motif.Idmotif, motif.Libelle, datefin);
                            DateTime Olddatedebut = (DateTime)dgvAbsence.SelectedRows[0].Cells["Datedebut"].Value;

                            controle.UpdateDate(absences, Olddatedebut);
                            enCoursDeModifAbsences = false;
                        }
                        else
                        {
                            string motifNew = cboMotif.Text;
                            idpersonnel = (int)dgvPersonnel.SelectedRows[0].Cells["idpersonnel"].Value;
                            Absences absences = new Absences(idpersonnel, datedebut, motif.Idmotif, motifNew, datefin);
                            controle.AddAbsences(absences);
                        }
                        Personnel personnel = (Personnel)bdgPersonnels.List[bdgPersonnels.Position];
                        RemplirListeAbsence(personnel);
                        dtpDateDebutDate.Value        = DateTime.Now;
                        dtpDateFinDate.Value          = DateTime.Now;
                        btnEnregistrerAbsence.Enabled = false;
                        btnAnnulerAbsence.Enabled     = false;
                    }
                }
                else
                {
                    MessageBox.Show("En dessous d'une seconde d'écart, entre la date de debut et la date de fin, la date de fin ne pourra être validé", "Information");
                }
            }
        }
        /// <summary>
        /// Ajoute une absence
        /// </summary>
        /// <param name="absences"></param>
        public static void AddAbsences(Absences absences)
        {
            string req = "insert into absence(idpersonnel, datedebut, idmotif, datefin) ";

            req += "values (@idpersonnel, @datedebut, @idmotif, @datefin);";
            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "@idpersonnel", absences.Idpersonnel },
                { "@datedebut", absences.Datedebut },
                { "@idmotif", absences.Idmotif },
                { "@datefin", absences.Datefin }
            };
            ConnexionBDD conn = ConnexionBDD.GetInstance(stringConnect);

            conn.ReqUpdate(req, parameters);
        }
        /// <summary>
        /// permet la modification d'une absence
        /// </summary>
        /// <param name="absences"></param>
        /// <param name="Olddatedebut"></param>
        public static void UpdateDate(Absences absences, DateTime Olddatedebut)
        {
            string req = "update absence set datedebut = @datedebut, datefin = @datefin, idmotif = @idmotif ";

            req += "where idpersonnel = @idpersonnel and datedebut = @datedebut2;";
            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "@idpersonnel", absences.Idpersonnel },
                { "@datedebut", absences.Datedebut },
                { "@datedebut2", Olddatedebut },
                { "@datefin", absences.Datefin },
                { "@idmotif", absences.Idmotif }
            };
            ConnexionBDD conn = ConnexionBDD.GetInstance(stringConnect);

            conn.ReqUpdate(req, parameters);
        }
Exemple #8
0
        private void LoadWorkingAndAbsenceTimes()
        {
            long[] ids = PlanningWeekProcessor.ListToEmployeeIds(PlanningEmployees);

            List <WorkingTimePlanning> _workingTimes = ClientEnvironment.WorkingTimePlanningService.GetWorkingTimePlanningsByEmployeeIds(ids, BeginTime, EndTime);
            //List<WorkingTimePlanning> _workingTimes1 = ClientEnvironment.WorkingTimePlanningService.GetEntitiesByStoreRelations(CurrentStoreId, BeginTime, EndTime);

            List <AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetAbsenceTimePlanningsByEmployeeIds(ids, BeginTime, EndTime);

            //List<AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetEntitiesByStoreRelations(CurrentStoreId, BeginTime, EndTime);

            if (Absences != null)
            {
                Absences.FillAbsencePlanningTimes(_absenceTimes);
            }

            PlanningWeekProcessor.AssignTimes(PlanningEmployees, _workingTimes, _absenceTimes);
        }
        /// <summary>
        /// récupère et retourne les absences de la BDD en fonction de l'idpersonnel
        /// La requête classe les absences en fonction de la date de debut d'absence la plus récente à la plus anciennce
        /// </summary>
        /// <returns></returns>
        public static List <Absences> GetLesAbsences(Personnel personnel)
        {
            List <Absences>             LesAbsences = new List <Absences>();
            string                      req         = "select *, m.libelle as motif from absence a join motif m on (a.idmotif = m.idmotif) where idpersonnel = @idpersonnel order by datedebut DESC;";
            ConnexionBDD                curs        = ConnexionBDD.GetInstance(stringConnect);
            Dictionary <string, object> parameters  = new Dictionary <string, object>
            {
                { "@idpersonnel", personnel.Idpersonnel }
            };

            curs.ReqSelect(req, parameters);
            while (curs.Read())
            {
                Absences absences = new Absences((int)curs.Field("idpersonnel"), (DateTime)curs.Field("datedebut"), (int)curs.Field("idmotif"), (string)curs.Field("motif"), (DateTime)curs.Field("datefin"));
                LesAbsences.Add(absences);
            }
            curs.Close();
            return(LesAbsences);
        }
Exemple #10
0
        public void LoadEmployeePlanningAndRecording(StoreToWorld world)
        {
            _currentWorldID = 0;

            if (world != null)
            {
                _currentWorldID = world.WorldID;

                List <EmployeeWeek> planningWeeks = ClientEnvironment.EmployeeService.GetTimePlannignEmployeeByWorld2(StoreId, _currentWorldID, BeginWeekDate, EndWeekDate);
                Absences.FillEmployeeWeek(planningWeeks);
                _planningWorldState = new StoreWorldWeekState(world, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsPlannedWeek(planningWeeks);

                if (planningWeeks != null)
                {
                    _planningWorldState.List.AddRange(planningWeeks);
                    foreach (EmployeeWeek ew in planningWeeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _planningWorldState.Context = this;
                _planningWorldState.Calculate();

                planningWeeks = ClientEnvironment.EmployeeService.GetTimeRecordingEmployeeByWorld(StoreId, _currentWorldID, BeginWeekDate, EndWeekDate);
                Absences.FillEmployeeWeek(planningWeeks);
                _actualWorldState = new StoreWorldWeekState(world, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsRecordingWeek(planningWeeks);
                if (planningWeeks != null)
                {
                    _actualWorldState.List.AddRange(planningWeeks);
                    foreach (EmployeeWeek ew in planningWeeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _actualWorldState.Context = this;
                _actualWorldState.Calculate();
            }
        }
 /// <summary>
 /// permet la suppression d'une abence
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSupprimerAbsence_Click(object sender, EventArgs e)
 {
     grbGestionAbsences.Text = "Suppression d'une absence";
     DateTimePickerCustomFormat();
     btnEnregistrerAbsence.Enabled = false;
     btnAnnulerAbsence.Enabled     = true;
     if (dgvAbsence.SelectedRows.Count > 0)
     {
         Absences  absences  = (Absences)bdgAbsences.List[bdgAbsences.Position];
         Personnel personnel = (Personnel)bdgPersonnels.List[bdgPersonnels.Position];
         if (MessageBox.Show("Voulez-vous vraiment supprimer cette absence  ?", "Confirmation de suppression", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             controle.DelAbsences(absences);
             RemplirListeAbsence(personnel);
         }
     }
     else
     {
         MessageBox.Show("Pour supprimer une absence une ligne doit être sélectionnée", "Information");
     }
 }
Exemple #12
0
        private string GetAbsencesForPeriod(AbsencePeriod period)
        {
            var absencesForPeriod = Absences.Where(a => a.Period == period).ToList();
            var fullAbsencesCount = absencesForPeriod.Count(a => a.Type == AbsenceType.Full);
            var thirdsCount       = absencesForPeriod.Count(a => a.Type == AbsenceType.OneThird);

            var remainingThirds = thirdsCount % 3;
            var fullFromThirds  = thirdsCount / 3;
            var actualFullCount = fullAbsencesCount + fullFromThirds;
            var result          = "";

            if (actualFullCount != 0)
            {
                result += $"{actualFullCount}";
            }

            if (remainingThirds != 0)
            {
                result += $" {remainingThirds}/3";
            }

            return(result);
        }
Exemple #13
0
        public ActionResult Edit(Absences model)
        {
            Absences abs = _context.Absences.Where(
                x => x.ID == model.ID).SingleOrDefault();

            model.PersonID = abs.PersonID;

            CultureInfo cul = CultureInfo.CurrentCulture;

            int weekNum = cul.Calendar.GetWeekOfYear(
                model.Date,
                CalendarWeekRule.FirstDay,
                DayOfWeek.Monday);

            model.week = weekNum;

            if (abs != null)
            {
                _context.Entry(abs).CurrentValues.SetValues(model);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemple #14
0
 /// <summary>
 /// supression d'une absences
 /// </summary>
 /// <param name="absences"></param>
 public void DelAbsences(Absences absences)
 {
     AccesDonnees.DelAbsences(absences);
 }
Exemple #15
0
 /// <summary>
 /// demande de mise à jour d'une absence
 /// </summary>
 /// <param name="absences"></param>
 /// <param name="Olddatedebut"></param>
 public void UpdateDate(Absences absences, DateTime Olddatedebut)
 {
     AccesDonnees.UpdateDate(absences, Olddatedebut);
 }
Exemple #16
0
 /// <summary>
 /// demande d'ajout d'une absence
 /// </summary>
 /// <param name="absences"></param>
 public void AddAbsences(Absences absences)
 {
     AccesDonnees.AddAbsences(absences);
 }
Exemple #17
0
 public List <Lesson> CourseLessons(Course course) =>
 Absences.Where(absence => absence.Course.ID == course.ID).ToList();
Exemple #18
0
        private void LoadEmployeePlanningAndRecording(bool bLoadStoreDays)
        {
            ClearContext();

            if (bLoadStoreDays)
            {
                LoadStoreDayInfo();
            }

            ErrorCode = ErrorCodes.Empty;
            if (m_storedays.IsUndefined())
            {
                ErrorCode |= ErrorCodes.NotExistsOpenTime;
            }
            if (m_storedays.AvgDayInWeek == 0)
            {
                ErrorCode |= ErrorCodes.NotExistsAvgDaysPerWeek;
            }

            if (ErrorCodes.Empty != ErrorCode)
            {
                ProcessError();
                return;
            }

            if (CurrentStoreWorld != null)
            {
                List <EmployeeWeek> planningweeks = _EmployeeService.GetTimePlannignEmployeeByWorld2(StoreId, WorldId, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsPlannedWeek(planningweeks);

                Absences.FillEmployeeWeek(planningweeks);

                _PlanningWorldState = new StoreWorldWeekState(CurrentStoreWorld, BeginWeekDate, EndWeekDate);

                if (planningweeks != null)
                {
                    _PlanningWorldState.List.AddRange(planningweeks);
                    foreach (EmployeeWeek ew in planningweeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _PlanningWorldState.Context = this;
                _PlanningWorldState.Calculate();


                planningweeks = _EmployeeService.GetTimeRecordingEmployeeByWorld(StoreId, WorldId, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsRecordingWeek(planningweeks);
                Absences.FillEmployeeWeek(planningweeks);

                _ActualWorldState = new StoreWorldWeekState(CurrentStoreWorld, BeginWeekDate, EndWeekDate);

                if (planningweeks != null)
                {
                    _ActualWorldState.List.AddRange(planningweeks);
                    foreach (EmployeeWeek ew in planningweeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _ActualWorldState.PlannedWorld = false;
                _ActualWorldState.Context      = this;
                _ActualWorldState.Calculate();


                WorldPlanningInfo infoworld =
                    _StoreService.StoreToWorldService.GetStoreWorldPlanningInfo(false, StoreId, WorldId, BeginWeekDate);



                _ActualWorldState.StoreWorldInfo   = infoworld;
                _PlanningWorldState.StoreWorldInfo = infoworld;

                FillRecordingWorldInfoFromPlanningInfo();

                Modified = false;
                OnChangedContext();
            }
        }
Exemple #19
0
        public ActionResult Create(AbsenceDTO model, string sortType)
        {
            Absences        absence       = new Absences();
            List <Absences> absenceList   = new List <Absences>();
            List <DateTime> selectedDates = new List <DateTime>();

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.StartDate != null && model.EndDate == null)
                    {
                        CultureInfo cul = CultureInfo.CurrentCulture;

                        int weekNum = cul.Calendar.GetWeekOfYear(
                            model.StartDate,
                            CalendarWeekRule.FirstDay,
                            DayOfWeek.Monday);


                        absence.Date        = model.StartDate;
                        absence.Hours       = model.Hours;
                        absence.AbsenceType = sortType;
                        absence.PersonID    = model.PersonID;
                        absence.week        = weekNum;


                        _context.Absences.Add(absence);
                        _context.SaveChanges();
                    }

                    else if (model.StartDate != null && model.EndDate != null)
                    {
                        for (var date = model.StartDate; date <= model.EndDate; date = date.AddDays(1))
                        {
                            selectedDates.Add(date);
                        }

                        foreach (var item in selectedDates)
                        {
                            CultureInfo cul = CultureInfo.CurrentCulture;

                            int weekNum = cul.Calendar.GetWeekOfYear(
                                item,
                                CalendarWeekRule.FirstDay,
                                DayOfWeek.Monday);

                            absenceList.Add(new Absences
                            {
                                Date        = item,
                                AbsenceType = sortType,
                                Hours       = model.Hours,
                                week        = weekNum,
                                PersonID    = model.PersonID
                            });
                        }

                        foreach (var item in absenceList)
                        {
                            _context.Absences.Add(item);
                            _context.SaveChanges();
                        }
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }