public ActionResult Create([Bind(Include = "IdEmploye,IdEntite,date")] employehasentite employehasentite)
        {
            if (ModelState.IsValid)
            {
                int     id  = employehasentite.IdEmploye;
                var     id1 = employehasentite.IdEntite;
                entite  e1  = db.entite.Find(id1);
                employe e   = db.employe.Find(id);
                // Session["des"] = e1.Designation;
                e.affectation = e1.Designation;
                db.employehasentite.Add(employehasentite);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdEmploye = new SelectList(db.employe, "idEmploye", "matricule", employehasentite.IdEmploye);
            ViewBag.IdEntite  = new SelectList(db.entite, "idEntite", "Designation", employehasentite.IdEntite);
            return(View(employehasentite));

            /*
             * employehasentite.date = Convert.ToDateTime(Request["date"]);
             * employehasentite.IdEmploye = 1;
             * employehasentite.IdEntite = 3;
             * db.employehasentite.Add(employehasentite);
             * db.SaveChanges();
             * return RedirectToAction("Index");
             */
        }
        public ActionResult Validation()
        {
            int          uid    = int.Parse(Session["uid"].ToString());
            demandeconge e      = db.demandeconge.Find(uid);
            string       button = Request["button"];



            switch (button)
            {
            case "Accepté":
                e.ValidationN2     = "accepte";
                e.DateValidationN2 = DateTime.Now;

                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Refusé":
                e.ValidationN2    = "refuse";
                e.ValdationRH     = "*******";
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Annulé":

                return(RedirectToAction("historique"));

            default:
                return(View());
            }
        }
        public ActionResult changePassword(ChangePasswordModel obj)
        {
            if (ModelState.IsValid)
            {
                //int uid = int.Parse(Session["matricule"].ToString());
                int uid = int.Parse(Session["idEmploye"].ToString());

                employe e = db.employe.Find(uid);

                if (e.password == obj.OldPassword)
                {
                    e.password        = obj.NewPassword;
                    db.Entry(e).State = EntityState.Modified;
                    db.SaveChanges();
                    obj.Message = "Your Password is updated successfully";
                    //ViewBag.Success = true;
                    // ViewBag.Message = $"password updated succefully";
                    // return RedirectToAction("Index", "Default");
                }
                else
                {
                    // ViewBag.Message = $"an error occurred while updation password !";
                    obj.Message = "Invalid currrent  Password";
                    // return RedirectToAction("Index", "Default");
                }
            }

            return(View(obj));
        }
        public ActionResult Create(employe data)
        {

            data.NomComplet = Request["NomComplet"];
            data.matricule= Request["matricule"];
            data.nbjours =Convert.ToInt32( Request["nbjours"]);
            data.nbjoursA = Request["nbjoursA"];
            data.nbHeureR = Request["nbHeureR"];
            data.affectation = Request["affectation"];
            data.role = Request["role"];
            data.password = Request["password"];
            data.sexe = Request["sexe"];
            data.Status = Request["Status"];
            data.nbEnfants = Convert.ToInt32(Request["nbEnfants"]);
            data.Classe = Request["Classe"];
            data.DateDebut =Convert.ToDateTime( Request["DateDebut"]);
            
          //  data.DateFin = Convert.ToDateTime(Request["DateFin"]);

            db.employe.Add(data);
             db.SaveChanges();
            return RedirectToAction("Index", "Employe");


        }
        public ActionResult Create(entite entite)
        {
            entite.Designation = Request["Designation"];

            db.entite.Add(entite);
            db.SaveChanges();
            return(RedirectToAction("Index", "entites"));
        }
Exemplo n.º 6
0
        public int Create(employe newEmploye)
        {
            var employeName       = newEmploye.NomComplet.ToLower();
            var employeNameExists = db.employe.Where(c => c.NomComplet.ToLower() == employeName).Any();

            if (employeNameExists)
            {
                return(-2);
            }


            db.employe.Add(newEmploye);
            return(db.SaveChanges());
        }
        public ActionResult changePassword(ChangePasswordModel obj)
        {
            if (ModelState.IsValid)
            {
                int uid = int.Parse(Session["idEmploye"].ToString());

                employe e = db.employe.Find(uid);


                if (e.password == obj.OldPassword)
                {
                    e.password        = obj.NewPassword;
                    db.Entry(e).State = EntityState.Modified;
                    db.SaveChanges();
                    Session["Messag"] = "Your Password is updated successfully";
                    return(RedirectToAction("Index", "Default"));
                }
                else
                {
                    Session["Messag"] = "Invalid currrent  Password";
                    return(RedirectToAction("Index", "Default"));
                }
            }

            return(View(obj));
        }
 public int Update(demandeconge updatedDemande)
 {
     //prend les ancien data remplace par nv
     db.demandeconge.Attach(updatedDemande);
     db.Entry(updatedDemande).State = System.Data.Entity.EntityState.Modified;
     return(db.SaveChanges());
 }
Exemplo n.º 9
0
        public ActionResult Delete()
        {
            int      uid = int.Parse(Session["idE"].ToString());
            employe  e   = db.employe.Find(uid);
            DateTime dc  = DateTime.Now;


            string button = Request["button"];

            switch (button)
            {
            case "Supprimer":
                e.DateFin         = dc;
                e.password        = "******";
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));

            case "Annuler":

                return(RedirectToAction("Index"));

            default:
                return(View());
            }
        }
Exemplo n.º 10
0
        public ActionResult Validation()
        {
            int          uid    = int.Parse(Session["uid"].ToString());
            demandeconge e      = db.demandeconge.Find(uid);
            string       button = Request["button"];

            DateTime dateDebut = e.DateDebut.Value;
            DateTime dateFin   = e.DateFin.Value;
            var      dure      = (dateFin - dateDebut).Days;
            var      dureM     = (dateFin - dateDebut).TotalMinutes;

            double du   = Convert.ToDouble(dure) + 1;
            double duM  = Convert.ToDouble(dureM) + 1440;
            double nb   = Convert.ToDouble(e.employe.nbjoursR);
            double nbM  = Convert.ToDouble(e.employe.nbjoursR) * 24 * 60;
            double res  = nb - du;
            double resM = nbM - duM;
            double resJ = resM / 1440;

            //  Session["dur1"] = duM;
            switch (button)
            {
            case "Accepté":
                e.ValidationRH     = "Accepte";
                e.employe.nbjoursR = Convert.ToInt32(res);
                db.Entry(e).State  = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Refusé":
                e.ValidationRH    = "refuse";
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Annulé":

                return(RedirectToAction("historique"));

            default:
                return(View());
            }
        }
        public ActionResult Index(List <typeconge> list)
        {
            if (ModelState.IsValid)
            {
                foreach (var i in list)
                {
                    var c = db.typeconge.Where(a => a.idtypeConge.Equals(i.idtypeConge)).FirstOrDefault();
                    if (c != null)
                    {
                        c.designation = i.designation;
                        c.dureeJ      = i.dureeJ;
                    }
                }
                db.SaveChanges();

                ViewBag.Message = "succes";
                return(View(list));
            }
            else
            {
                ViewBag.Message = "faaaiiiils";
                return(View(list));
            }
        }
        public ActionResult Modifier()
        {
            typeconge a1 = db.typeconge.Find(1);

            a1.dureeJ          = Request["x1"];
            db.Entry(a1).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a2 = db.typeconge.Find(2);

            a2.dureeJ          = Request["x2"];
            db.Entry(a2).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a3 = db.typeconge.Find(3);

            a3.dureeJ          = Request["x3"];
            db.Entry(a3).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a4 = db.typeconge.Find(4);

            a4.dureeJ          = Request["x4"];
            db.Entry(a4).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a5 = db.typeconge.Find(5);

            a5.dureeJ          = Request["x5"];
            db.Entry(a5).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a6 = db.typeconge.Find(6);

            a6.dureeJ          = Request["x6"];
            db.Entry(a6).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a7 = db.typeconge.Find(7);

            a7.dureeJ          = Request["x6"];
            db.Entry(a7).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a8 = db.typeconge.Find(8);

            a8.dureeJ          = Request["x6"];
            db.Entry(a8).State = EntityState.Modified;
            db.SaveChanges();
            //

            typeconge a9 = db.typeconge.Find(9);

            a9.dureeJ          = Request["x9"];
            db.Entry(a9).State = EntityState.Modified;
            db.SaveChanges();
            //

            typeconge a10 = db.typeconge.Find(10);

            a10.dureeJ          = Request["x9"];
            db.Entry(a10).State = EntityState.Modified;
            db.SaveChanges();

            typeconge a11 = db.typeconge.Find(11);

            a11.dureeJ          = Request["x11"];
            db.Entry(a11).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a12 = db.typeconge.Find(12);

            a12.dureeJ          = Request["x12"];
            db.Entry(a12).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a13 = db.typeconge.Find(13);

            a13.dureeJ          = Request["x13"];
            db.Entry(a13).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a14 = db.typeconge.Find(14);

            a14.dureeJ          = Request["x14"];
            db.Entry(a14).State = EntityState.Modified;
            db.SaveChanges();
            //
            typeconge a15 = db.typeconge.Find(15);

            a15.dureeJ          = Request["x15"];
            db.Entry(a15).State = EntityState.Modified;
            db.SaveChanges();

            /*
             * typeconge a16 = db.typeconge.Find(16);
             * a16.dureeJ = Request["x16"];
             * db.Entry(a16).State = EntityState.Modified;
             * db.SaveChanges();
             * //
             * typeconge a17 = db.typeconge.Find(17);
             * a17.dureeJ = Request["x17"];
             * db.Entry(a17).State = EntityState.Modified;
             * db.SaveChanges();
             * //
             * typeconge a18 = db.typeconge.Find(18);
             * a18.dureeJ = Request["x18"];
             * db.Entry(a18).State = EntityState.Modified;
             * db.SaveChanges();
             * //
             * typeconge a19 = db.typeconge.Find(19);
             * a19.dureeJ = Request["x19"];
             * db.Entry(a19).State = EntityState.Modified;
             * db.SaveChanges();
             *
             * //
             */
            typeconge a21 = db.typeconge.Find(21);

            a21.dureeJ          = Request["x20"];
            db.Entry(a21).State = EntityState.Modified;
            db.SaveChanges();

            typeconge a20 = db.typeconge.Find(20);

            a20.dureeJ = Request["x20"];

            db.Entry(a20).State = EntityState.Modified;
            db.SaveChanges();
            //

            typeconge a22 = db.typeconge.Find(22);

            a22.dureeJ          = Request["x22"];
            db.Entry(a22).State = EntityState.Modified;
            db.SaveChanges();
            //



            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
        public ActionResult Annulation()
        {
            int          uid    = int.Parse(Session["uid"].ToString());
            demandeconge e      = db.demandeconge.Find(uid);
            string       button = Request["button"];

            DateTime dateDebut = e.DateDebut.Value;
            DateTime dateFin   = e.DateFin.Value;


            /*   var dure = (dateFin - dateDebut).Days;
             *
             *
             * double du = Convert.ToDouble(dure) + 1;
             * double d = du * 24;
             * double nb = Convert.ToDouble(e.employe.nbHeureR);
             *
             * double res = nb + d;
             */

            var recup = db.CumulRecup.Include(d => d.employe).Where(p => p.employe.idEmploye == e.IdEmploye).Select(u => new {
                hs = u.CumulHr,
                jf = u.CumulJrF,
                jr = u.CumulJrR,
                id = u.IDCumulRecup
            }).Single();

            CumulRecup cr = db.CumulRecup.Find(recup.id);

            double hsA = Convert.ToDouble(cr.CumulHr);

            //en heure
            double jf = Convert.ToDouble(recup.jf);


            double jR = Convert.ToDouble(recup.jr);



            var    dureM = (dateFin - dateDebut).TotalHours + 1;
            var    dureD = (dateFin - dateDebut).Days + 1;
            double duM   = Convert.ToDouble(dureM);
            double nbM   = Convert.ToDouble(e.employe.nbHeureR);
            double resM  = nbM + duM;



            switch (button)
            {
            case "Retour":

                return(RedirectToAction("Index"));

            case "annule":
                if (e.IdtypeConge == 23)
                {
                    double dhs = hsA + dureM;
                    cr.CumulHr = Convert.ToString(dhs);
                }
                else
                if (e.IdtypeConge == 25)
                {
                    double dhs = jf + dureD;
                    string dh  = Convert.ToString(dhs);
                    cr.CumulJrF = float.Parse(dh);
                }
                else
                if (e.IdtypeConge == 24)
                {
                    double dhs = jR + dureD;
                    string dh  = Convert.ToString(dhs);
                    cr.CumulJrR = float.Parse(dh);
                }
                else
                {
                    e.employe.nbHeureR = resM.ToString();
                }



                e.ValdationRH     = "En cours";
                e.ValidationN1    = "En cours";
                e.ValidationN2    = "En cours";
                e.annulation      = "oui";
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));

            default:
                return(View());
            }
        }
Exemplo n.º 14
0
        public ActionResult Dashboard1()
        {
            //donnée from index (view)
            int          uid                  = int.Parse(Session["idEmploye"].ToString());
            employe      e                    = db.employe.Find(uid);
            demandeconge demande              = new demandeconge();
            string       dateDebut            = Request["dateDebut"] + " " + Request["timeDebut"];
            string       dateFin              = Request["dateFin"] + " " + Request["timeFin"];
            string       operation            = Request["operation"].ToString();
            string       marriage             = Request["marriage1"].ToString();
            string       deces                = Request["deces1"].ToString();
            string       typeCongeIdTypeconge = Request.Form["typeCongeIdTypeconge"];
            string       justification        = Request["justification"];
            DateTime     dc                   = DateTime.Now;

            //condition de date

            double   jours  = Convert.ToDouble(Session["nbjours"].ToString()) - 1;
            double   joursR = Convert.ToDouble(Session["nbjoursR"].ToString()) - 1;
            TimeSpan t      = TimeSpan.FromDays(jours);  //jurs: nbjours
            TimeSpan tR     = TimeSpan.FromDays(joursR); //jurs: nbjoursR
            TimeSpan t0     = TimeSpan.FromDays(0);      //0
            TimeSpan t10    = TimeSpan.FromDays(9);      //10
            TimeSpan t7     = TimeSpan.FromDays(6);      //7
            TimeSpan t1     = TimeSpan.FromDays(1);      //1
            TimeSpan t2     = TimeSpan.FromDays(2);      //2
            TimeSpan t12    = TimeSpan.FromHours(12);    //pour la demi journée
            TimeSpan t112   = TimeSpan.FromHours(36);    //pour la jour et demi

            //duree
            var l = db.typeconge;

            if (Request["dateDebut"].Equals("") || typeCongeIdTypeconge.Equals(""))
            {
                Session["demande"] = "Remlpir tout les champs svp !";
                return(RedirectToAction("Index", "Default"));
            }
            //date debut
            DateTime debut = Convert.ToDateTime(Request["dateDebut"]);

            if (typeCongeIdTypeconge.Equals("Opération chirurgicale") || typeCongeIdTypeconge.Equals("Décès") || typeCongeIdTypeconge.Equals("Mariage"))
            {
                if (debut < dc)
                {
                    Session["demande"] = "vérifier les dates svp!";
                    return(RedirectToAction("Index", "Default"));
                }
                else if (typeCongeIdTypeconge.Equals("Mariage") && !(marriage.Equals("")))
                {
                    if (marriage.Equals("1"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 4)
                            {
                                int x4 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x4);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 4;
                            }
                        }
                    }
                    if (marriage.Equals("2"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 5)
                            {
                                int x5 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x5);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 5;
                            }
                        }
                    }
                }

                else if (typeCongeIdTypeconge.Equals("Décès") && !(deces.Equals("")))
                {
                    if (deces.Equals("1"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 6)
                            {
                                int x6 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x6);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 6;
                            }
                        }
                    }
                    if (deces.Equals("2"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 7)
                            {
                                int x7 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x7);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 7;
                            }
                        }
                    }
                    if (deces.Equals("3"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 8)
                            {
                                int x8 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x8);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 8;
                            }
                        }
                    }
                    if (deces.Equals("4"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 9)
                            {
                                int x9 = int.Parse(item.dureeJ);
                                var df = debut.AddDays(x9);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 9;
                            }
                        }
                    }
                    if (deces.Equals("5"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 10)
                            {
                                int x10 = int.Parse(item.dureeJ);
                                var df  = debut.AddDays(x10);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 10;
                            }
                        }
                    }
                }
                else if (typeCongeIdTypeconge.Equals("Opération chirurgicale") && !(operation.Equals("")))
                {
                    if (operation.Equals("1"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 20)
                            {
                                int x20 = int.Parse(item.dureeJ);
                                var df  = debut.AddDays(x20);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 20;
                            }
                        }
                    }
                    if (operation.Equals("2"))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 21)
                            {
                                int x21 = int.Parse(item.dureeJ);
                                var df  = debut.AddDays(x21);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 21;
                            }
                        }
                    }
                }
            }
            else
            {
                if (Request["dateDebut"].Equals("") || Request["dateFin"].Equals("") || typeCongeIdTypeconge.Equals(""))
                {
                    Session["demande"] = "Remlpir tout les champs svp !";
                    return(RedirectToAction("Index", "Default"));
                }
                DateTime fin      = Convert.ToDateTime(Request["dateFin"]);
                TimeSpan dateSpan = fin - debut;

                if ((debut < dc) || (fin < dc) || (fin < debut))
                {
                    Session["demande"] = "vérifier les dates svp!";
                    return(RedirectToAction("Index", "Default"));
                }

                else
                {
                    if (typeCongeIdTypeconge.Equals("reliquat") && dateSpan > t0 && dateSpan <= tR)
                    {
                        demande.IdtypeConge = 3;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("1 ere tranche") && dateSpan >= t10 && dateSpan <= t) //obj <JR ,obj >=10
                    {
                        demande.IdtypeConge = 1;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("2 eme tranche") && dateSpan >= t7 && dateSpan <= tR)//obj <7(t7) , obj <=jR
                    {
                        demande.IdtypeConge = 2;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("1/2 journée") && dateSpan <= t12)
                    {
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                        demande.IdtypeConge = 11;
                    }
                    else if (typeCongeIdTypeconge.Equals("1 journée") && dateSpan == t1)
                    {
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                        demande.IdtypeConge = 12;
                    }
                    else if (typeCongeIdTypeconge.Equals("1.5 journée") && dateSpan <= t112)
                    {
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                        demande.IdtypeConge = 13;
                    }
                    else if (typeCongeIdTypeconge.Equals("2 journée") && dateSpan == t2)
                    {
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                        demande.IdtypeConge = 14;
                    }
                    else if (typeCongeIdTypeconge.Equals("Naissance") && !(justification.Equals("")))
                    {
                        foreach (var item in l)
                        {
                            if (item.idtypeConge == 22)
                            {
                                int x22 = int.Parse(item.dureeJ);
                                var df  = debut.AddDays(x22);
                                demande.DateFin     = Convert.ToDateTime(df);
                                demande.IdtypeConge = 22;
                            }
                        }
                    }



                    else if (typeCongeIdTypeconge.Equals("H.S"))
                    {
                        demande.IdtypeConge = 23;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("J.R"))
                    {
                        demande.IdtypeConge = 24;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("J.F"))
                    {
                        demande.IdtypeConge = 25;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("heures"))
                    {
                        demande.IdtypeConge = 26;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else if (typeCongeIdTypeconge.Equals("jours"))
                    {
                        demande.IdtypeConge = 27;
                        demande.DateFin     = Convert.ToDateTime(dateFin);
                    }
                    else
                    {
                        Session["demande"] = "Vérifier vos données svp !";
                        return(RedirectToAction("Index", "DemandeConge"));
                    }
                }
            }
            demande.ValidationN1  = "******";
            demande.ValidationN2  = "En cours";
            demande.ValidationRH  = "En cours";
            demande.IdEmploye     = uid;
            demande.DateDebut     = Convert.ToDateTime(dateDebut);
            demande.DateDC        = dc;
            demande.justification = justification;
            demande.Annulation    = "non";
            db.demandeconge.Add(demande);
            db.SaveChanges();
            return(RedirectToAction("historique", "DemandeConge"));
        }
        public ActionResult Validation()
        {
            int          uid    = int.Parse(Session["uid"].ToString());
            demandeconge e      = db.demandeconge.Find(uid);
            string       button = Request["button"];
            DCTEMP       dc     = new DCTEMP();

            DateTime dateDebut = e.DateDebut.Value;
            DateTime dateFin   = e.DateFin.Value;

            /*var dure = (dateFin - dateDebut).Days;
             * var dureM = (dateFin - dateDebut).TotalMinutes;
             *
             * double du = Convert.ToDouble(dure) + 1;
             * double duM = Convert.ToDouble(dureM) + 1440;
             * double nb = Convert.ToDouble(e.employe.nbHeureR);
             * double nbM = Convert.ToDouble(e.employe.nbHeureR) * 24 * 60;
             * double res = nb - du;
             * double resM = nbM - duM;
             * double resJ = resM / 1440;
             */

            var recup = db.CumulRecup.Include(d => d.employe).Where(p => p.employe.idEmploye == e.IdEmploye).Select(u => new {
                hs = u.CumulHr,
                jf = u.CumulJrF,
                jr = u.CumulJrR,
                id = u.IDCumulRecup
            }).Single();

            CumulRecup cr = db.CumulRecup.Find(recup.id);

            double hsA = Convert.ToDouble(cr.CumulHr);

            //en heure
            double jf = Convert.ToDouble(recup.jf);


            double jR = Convert.ToDouble(recup.jr);



            var    dureM = (dateFin - dateDebut).TotalHours + 1;
            var    dureD = (dateFin - dateDebut).Days + 1;
            double duM   = Convert.ToDouble(dureM);
            double nbM   = Convert.ToDouble(e.employe.nbHeureR);
            double resM  = nbM - duM;



            switch (button)
            {
            case "Accepté":
                if (e.IdtypeConge == 23)
                {
                    double dhs = hsA - dureM;
                    cr.CumulHr = Convert.ToString(dhs);
                }
                else
                if (e.IdtypeConge == 25)
                {
                    double dhs = jf - dureD;
                    string dh  = Convert.ToString(dhs);
                    cr.CumulJrF = float.Parse(dh);
                }
                else
                if (e.IdtypeConge == 24)
                {
                    double dhs = jR - dureD;
                    string dh  = Convert.ToString(dhs);
                    cr.CumulJrR = float.Parse(dh);
                }
                else
                {
                    e.employe.nbHeureR = resM.ToString();
                }
                e.ValdationRH = "accepte";
                if (e.ValidationN1.Equals("En cours"))
                {
                    e.ValidationN1 = "*******";
                }

                e.DateValidationRH = DateTime.Now;

                //DCTEMP
                dc.matricule   = e.employe.matricule;
                dc.DateDebut   = e.DateDebut;
                dc.DateFin     = e.DateFin;
                dc.typeDeConge = e.typeconge.designation;
                dc.Status      = "En att";


                db.Entry(e).State = EntityState.Modified;

                db.DCTEMP.Add(dc);
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Refusé":
                e.ValdationRH     = "refuse";
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("historique"));

            case "Annulé":

                return(RedirectToAction("historique"));

            default:
                return(View());
            }
        }