Esempio n. 1
0
        public ActionResult Setting(DateTime dateNotification, DateTime dateAttribution)
        {
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db = new EtudiantContext();
                ViewBag.Delai        = db.settings.FirstOrDefault().Delai;
                ViewBag.DatedeRappel = db.settings.FirstOrDefault().DatedeRappel;

                if (dateNotification != null)
                {
                    db.settings.FirstOrDefault().DatedeRappel = dateNotification;
                }
                if (dateAttribution != null)
                {
                    db.settings.FirstOrDefault().Delai = dateAttribution;
                }

                db.SaveChanges();
                ViewBag.Current = "Setting";
                return(View("Setting"));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
Esempio n. 2
0
        //suppression des etudiants importes mais pas les redoublants
        public ActionResult DeleteImportedStudents()
        {
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db = new EtudiantContext();
                for (int i = 0; i < db.etudiants.ToList().Count; i++)
                {
                    if (db.etudiants.ToList()[i].Redoubler == false)
                    {
                        db.etudiants.Remove(db.etudiants.ToList()[i]);
                    }
                }

                db.settings.First().Attributted    = false;
                db.settings.First().importEtudiant = false;
                db.settings.First().importNote     = false;

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
 public ActionResult Authentification()
 {
     if (UserValide.IsValid())
     {
         return(RedirectToAction("Index", "Departement"));
     }
     else
     {
         return(View());
     }
 }
        public ActionResult Index()
        {
            ViewBag.Current = "Home";

            if (UserValide.IsValid() && UserValide.IsStudent())
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("Authentification1", "User"));
            }
        }
Esempio n. 5
0
        public ActionResult Search(string cne)
        {
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db       = new EtudiantContext();
                List <Etudiant> etudiant = new List <Etudiant>();
                int             count    = 0;

                foreach (var item in db.etudiants.Distinct().ToArray())
                {
                    if (item.cne == cne)
                    {
                        var etudiants = (from s in db.etudiants
                                         where s.cne == cne
                                         select s).SingleOrDefault();
                        count++;
                        etudiant.Add(etudiants);
                    }
                    if (item.nom == cne)
                    {
                        var etudiants = (from s in db.etudiants
                                         where s.nom == cne
                                         select s).ToList();

                        etudiant = etudiants;
                        count++;
                    }
                    else if (item.cin == cne)
                    {
                        var etudiants = (from s in db.etudiants
                                         where s.cin == cne
                                         select s).SingleOrDefault();
                        count++;
                        etudiant.Add(etudiants);
                    }
                }


                if (count == 0)
                {
                    ViewBag.error = true;
                    return(View());
                }
                ViewBag.error = false;
                return(View(etudiant));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
        //****************************************************************************************************************************



        public ActionResult Consulter()
        {
            ViewBag.Current = "Consulter";
            if (UserValide.IsValid() && UserValide.IsStudent())
            {
                Etudiant etudiants = etudiantContext.etudiants.Find(Session["userId"]);

                return(View(etudiants));
            }
            else
            {
                return(RedirectToAction("Authentification1", "User"));
            }
        }
Esempio n. 7
0
        public ActionResult Visualiser()
        {
            ViewBag.Current = "visualiser";
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db = new EtudiantContext();

                return(View(db.etudiants.ToList()));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
        //pour Imprimer le pdf

        public ActionResult PrintConsultation()
        {
            Etudiant etudiants = etudiantContext.etudiants.Find(Session["userId"]);
            var      q         = new ViewAsPdf("RecuEtudiant", etudiants);

            if (UserValide.IsValid() && UserValide.IsStudent())
            {
                return(q);
            }
            else
            {
                return(RedirectToAction("Authentification1", "User"));
            }
        }
Esempio n. 9
0
        //pour Imprimer le pdf

        public ActionResult PrintConsultation()
        {
            EtudiantContext db = new EtudiantContext();

            var q = new ViewAsPdf("ImprimerEtudiant", db.etudiants.ToList());

            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                return(q);
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
        public ActionResult Authentification1()
        {
            EtudiantContext db = new EtudiantContext();

            ViewBag.Delai        = db.settings.FirstOrDefault().Delai;
            ViewBag.Attributted  = db.settings.FirstOrDefault().Attributted;
            ViewBag.DatedeRappel = db.settings.FirstOrDefault().DatedeRappel;
            if (UserValide.IsValid())
            {
                return(RedirectToAction("Index", "Etudiant"));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 11
0
        public ActionResult Index()
        {
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db = new EtudiantContext();


                ViewBag.Current = "index";
                List <Etudiant> list = db.etudiants.ToList();

                return(View(list));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
Esempio n. 12
0
 public ActionResult ImporterNotes()
 {
     ViewBag.Current = "importerNotes";
     if (UserValide.IsValid() && UserValide.IsAdmin())
     {
         EtudiantContext db = new EtudiantContext();
         if (db.settings.FirstOrDefault().importEtudiant)
         {
             return(View());
         }
         ViewBag.err = true;
         return(View());
     }
     else
     {
         return(RedirectToAction("Authentification", "User"));
     }
 }
Esempio n. 13
0
 public void EnvoyerLesFilieres()
 {
     if (UserValide.IsValid() && UserValide.IsAdmin())
     {
         EtudiantContext db = new EtudiantContext();
         for (int i = 0; i < db.etudiants.ToList().Count; i++)
         {
             if (db.etudiants.ToList()[i].email != null)
             {
                 string body = "<div border='2px black solid'><h1 color='red'>Bonjour Mr/Mme " + db.etudiants.ToList()[i].nom + " " + db.etudiants.ToList()[i].prenom + "</h1>" +
                               "<p>Apres avoir faire l'attribution des filieres, on vient de vous informer que votre filiere est : " + db.Filieres.Find(db.etudiants.ToList()[i].idFil).nomFil + "</p><br/>" +
                               "<button color='blue'><a href='localhost:localhost:52252/User/Authentification1'>Cliquer ici!</a></button>" +
                               "</div>";
                 Boolean Result = SendEmail(db.etudiants.ToList()[i].email, "Information a propos la filiere attribuer ", body);
                 if (Result == true)
                 {
                     Json(Result, JsonRequestBehavior.AllowGet);
                 }
             }
         }
     }
 }
Esempio n. 14
0
        //suppression des etudiants (placer les etudiants redoublants dans la corbeille)
        public ActionResult SupprimerEtudiant(string id)
        {
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                if (id != null)
                {
                    EtudiantContext db = new EtudiantContext();
                    db.etudiants.Find(id).Redoubler = true;
                    db.SaveChanges();
                    ViewBag.Current = "Index";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Authentification", "User"));
                }
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
        //--------------------------------------------------------------------------------------------------------------------------
        //Modification
        public ActionResult Modification()
        {
            ViewBag.Current = "Modification";
            ViewBag.check   = "Checked";

            /* if (id == null)
             * {
             *   return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             * }*/



            if (UserValide.IsValid() && UserValide.IsStudent())
            {
                Etudiant etudiants = etudiantContext.etudiants.Find(Session["userId"]);

                return(View(etudiants));
            }
            else
            {
                return(RedirectToAction("Authentification1", "User"));
            }
        }
Esempio n. 16
0
        public ActionResult Statistiques()
        {
            ViewBag.Current = "statistiques";

            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                //essayons de retourner tous les etudiants
                EtudiantContext db   = new EtudiantContext();
                List <Etudiant> list = db.etudiants.ToList();
                //initialisation des compteurs des filieres
                int info = 0, indus = 0, gtr = 0, gpmc = 0;

                //variable pour les nombre totale et le reste qui n'a pas choisi les filieres
                int nbrTotal = list.Count, nbrReste = 0;

                for (int i = 0; i < nbrTotal; i++)
                {
                    if (!list[i].Redoubler)
                    {
                        if (!list[i].Validated)
                        {
                            //un etudiant avec null dans choix alors on va l'es ajouter dans le reste
                            nbrReste++;
                        }
                        //sinon on va traiter les choix comme ca
                        else
                        {
                            char[] chiffr = (list[i].Choix).ToCharArray();

                            if (chiffr[0] == 'F')
                            {
                                info++;
                            }
                            if (chiffr[0] == 'P')
                            {
                                gpmc++;
                            }
                            if (chiffr[0] == 'T')
                            {
                                gtr++;
                            }
                            if (chiffr[0] == 'D')
                            {
                                indus++;
                            }
                        }
                    }
                    else
                    {
                        nbrTotal--;
                    }
                }
                ViewBag.nbrTotal = nbrTotal;
                ViewBag.nbrReste = nbrReste;
                ViewBag.info     = info;
                ViewBag.gtr      = gtr;
                ViewBag.gpmc     = gpmc;
                ViewBag.indus    = indus;
                //les pourcentages
                ViewBag.nbrTotalP = Convert.ToDouble(nbrTotal) / Convert.ToDouble(nbrTotal) * 100;
                ViewBag.nbrResteP = Convert.ToDouble(nbrReste) / Convert.ToDouble(nbrTotal) * 100;
                ViewBag.infoP     = Convert.ToDouble(info) / Convert.ToDouble(nbrTotal) * 100;
                ViewBag.gtrP      = Convert.ToDouble(gtr) / Convert.ToDouble(nbrTotal) * 100;
                ViewBag.gpmcP     = Convert.ToDouble(gpmc) / Convert.ToDouble(nbrTotal) * 100;
                ViewBag.indusP    = Convert.ToDouble(indus) / Convert.ToDouble(nbrTotal) * 100;
                return(View());
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
Esempio n. 17
0
        public ActionResult AttributionFiliere(string infoMax, string indusMax, string gtrMax, string gpmcMax)
        {
            ViewBag.Current = "attributionFiliere";
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db = new EtudiantContext();
                //return a  list sorted in a desendent way
                List <Etudiant> list  = db.etudiants.OrderByDescending(e => (e.noteFstYear + e.noteSndYear) / 2).ToList();
                int             total = 0;
                for (int i = 0; i < db.etudiants.ToList().Count; i++)
                {
                    if (!db.etudiants.ToList()[i].Redoubler)
                    {
                        total++;
                    }
                }
                int maxInfo  = total / 4;
                int maxGtr   = total / 4;
                int maxIndus = total / 4;
                int maxGpmc  = total / 4;

                int     diff = total % 4;
                Boolean symbol1 = false;
                Boolean symbol2 = false;
                Boolean symbol3 = false;
                Boolean symbol4 = false;
                Boolean taken = false;
                int     info = 0, indus = 0, gpmc = 0, gtr = 0;
                for (int i = 0; i < db.etudiants.ToList().Count; i++)
                {
                    if (!db.etudiants.ToList()[i].Redoubler && db.etudiants.ToList()[i].Validated)
                    {
                        char[] chiffr = (list[i].Choix).ToCharArray();

                        if (chiffr[0] == 'F')
                        {
                            info++;
                        }
                        if (chiffr[0] == 'P')
                        {
                            gpmc++;
                        }
                        if (chiffr[0] == 'T')
                        {
                            gtr++;
                        }
                        if (chiffr[0] == 'D')
                        {
                            indus++;
                        }
                    }
                }

                //il faut envoyer les nbr par defaut pour les textboxes
                //il faut classer les filieres par nbr de demande
                ////////partie statistique

                //variable pour les nombre totale et le reste qui n'a pas choisi les filieres
                int nbrTotal = total;


                //initialisation des Maxs

                for (int i = 0; i < diff; i++)
                {
                    if (info >= indus && info >= gtr && info >= gpmc && !symbol1 && !taken)
                    {
                        symbol1  = true;
                        taken    = true;
                        maxInfo += 1;
                    }
                    if (indus >= info && indus >= gtr && indus >= gpmc && !symbol2 && !taken)
                    {
                        symbol2 = true;
                        taken   = true;

                        maxIndus += 1;
                    }
                    if (gpmc >= indus && gpmc >= gtr && gpmc >= indus && !symbol3 && !taken)
                    {
                        symbol3 = true;
                        taken   = true;

                        maxGpmc += 1;
                    }
                    if (gtr >= indus && gtr >= gpmc && gtr >= info && !symbol4 && !taken)
                    {
                        taken = true;

                        symbol4 = true;
                        maxGtr += 1; break;
                    }
                    taken = false;
                }

                //changer les maxs si la departement a saisi des valeurs
                if (infoMax != null && indusMax != null && gpmcMax != null && gtrMax != null)
                {
                    try
                    {
                        maxInfo  = Convert.ToInt32(infoMax);
                        maxIndus = Convert.ToInt32(indusMax);
                        maxGtr   = Convert.ToInt32(gtrMax);
                        maxGpmc  = Convert.ToInt32(gpmcMax);
                        if (maxInfo + maxIndus + maxGtr + maxGpmc != total)
                        {
                            ViewBag.error2 = true;
                            return(View());
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }



                int indexInfo  = 0;
                int indexGtr   = 0;
                int indexIndus = 0;
                int indexGpmc  = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    //verification de l'etudiant si deja a choisi une filiere sinon on va lui attribuer la derniere filiere (gpmc->indus->gtr->info)

                    if (!list[i].Redoubler)
                    {
                        if (list[i].Validated)
                        {
                            //parse to a table of chars
                            char[] choice = list[i].Choix.ToCharArray();
                            //verify the frst case which is if we have F=info
                            Boolean choosen = false;

                            for (int j = 0; j < 3; j++)
                            {
                                if (choice[j] == 'F')
                                {
                                    if (indexInfo < maxInfo)
                                    {
                                        list[i].idFil = 1;
                                        choosen       = true;
                                        indexInfo++; break;
                                    }
                                }
                                if (choice[j] == 'T')
                                {
                                    if (indexGtr < maxGtr)
                                    {
                                        list[i].idFil = 2;
                                        choosen       = true;

                                        indexGtr++; break;
                                    }
                                }
                                if (choice[j] == 'D')
                                {
                                    if (indexIndus < maxIndus)
                                    {
                                        list[i].idFil = 3;
                                        choosen       = true;

                                        indexIndus++; break;
                                    }
                                }
                                if (choice[j] == 'P')
                                {
                                    if (indexGpmc < maxGpmc)
                                    {
                                        list[i].idFil = 4;
                                        choosen       = true;
                                        indexGpmc++; break;
                                    }
                                }
                                if (choosen)
                                {
                                    j = 3;
                                }
                                if (!choosen && j == 2)
                                {
                                    list[i].idFil = 4;
                                    choosen       = true;
                                    indexGpmc++; break;
                                }
                            }
                        }
                        else
                        {
                            taken = false;
                            if (info >= indus && info >= gtr && info >= gpmc && !taken && (indexInfo < maxInfo))
                            {
                                taken         = true;
                                list[i].idFil = 1;
                                indexInfo    += 1;
                            }
                            if (indus >= info && indus >= gtr && indus >= gpmc && !taken && (indexIndus < maxIndus))
                            {
                                taken         = true;
                                list[i].idFil = 3;
                                indexIndus   += 1;
                            }
                            if (gtr >= indus && gtr >= info && gtr >= gpmc && !taken && (indexGtr < maxGtr))
                            {
                                taken         = true;
                                list[i].idFil = 2;
                                indexGtr     += 1;
                            }
                            if (gpmc >= indus && gpmc >= gtr && gpmc >= info && !taken && (indexGpmc < maxGpmc))
                            {
                                taken         = true;
                                list[i].idFil = 4;
                                indexGpmc    += 1;
                            }
                        }
                    }
                }

                //list =list.OrderBy(e => (e.noteFstYear+e.noteSndYear)/2);

                db.settings.First().Attributted = true;
                //envoi d'un msg qui contient la filiere attribuer pour tous chaque etudiants
                db.SaveChanges();
                EnvoyerLesFilieres();

                return(RedirectToAction("AttributionFiliere"));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }
Esempio n. 18
0
        public ActionResult AttributionFiliere()
        {
            ViewBag.Current = "attributionFiliere";
            if (UserValide.IsValid() && UserValide.IsAdmin())
            {
                EtudiantContext db   = new EtudiantContext();
                List <Etudiant> list = db.etudiants.OrderByDescending(e => (e.noteFstYear + e.noteSndYear) / 2).ToList();

                int total = 0;
                for (int i = 0; i < db.etudiants.ToList().Count; i++)
                {
                    if (!db.etudiants.ToList()[i].Redoubler)
                    {
                        total++;
                    }
                }
                ViewBag.total = total;
                int info = 0, indus = 0, gpmc = 0, gtr = 0;
                for (int i = 0; i < db.etudiants.ToList().Count; i++)
                {
                    if (!db.etudiants.ToList()[i].Redoubler && db.etudiants.ToList()[i].Validated)
                    {
                        char[] chiffr = (list[i].Choix).ToCharArray();

                        if (chiffr[0] == 'F')
                        {
                            info++;
                        }
                        if (chiffr[0] == 'P')
                        {
                            gpmc++;
                        }
                        if (chiffr[0] == 'T')
                        {
                            gtr++;
                        }
                        if (chiffr[0] == 'D')
                        {
                            indus++;
                        }
                    }
                }

                //il faut envoyer les nbr par defaut pour les textboxes
                //il faut classer les filieres par nbr de demande
                ////////partie statistique

                //variable pour les nombre totale et le reste qui n'a pas choisi les filieres
                int nbrTotal = total;


                //initialisation des Maxs
                int maxInfo  = total / 4;
                int maxGtr   = total / 4;
                int maxIndus = total / 4;
                int maxGpmc  = total / 4;

                int     diff    = total % 4;
                Boolean symbol1 = false;
                Boolean symbol2 = false;
                Boolean symbol3 = false;
                Boolean symbol4 = false;
                Boolean taken   = false;
                for (int i = 0; i < diff; i++)
                {
                    if (info >= indus && info >= gtr && info >= gpmc && !symbol1 && !taken)
                    {
                        symbol1  = true;
                        taken    = true;
                        maxInfo += 1;
                    }
                    if (indus >= info && indus >= gtr && indus >= gpmc && !symbol2 && !taken)
                    {
                        symbol2 = true;
                        taken   = true;

                        maxIndus += 1;
                    }
                    if (gpmc >= indus && gpmc >= gtr && gpmc >= indus && !symbol3 && !taken)
                    {
                        symbol3 = true;
                        taken   = true;

                        maxGpmc += 1;
                    }
                    if (gtr >= indus && gtr >= gpmc && gtr >= info && !symbol4 && !taken)
                    {
                        taken = true;

                        symbol4 = true;
                        maxGtr += 1; break;
                    }
                    taken = false;
                }

                ViewBag.info  = maxInfo;
                ViewBag.gtr   = maxGtr;
                ViewBag.gpmc  = maxGpmc;
                ViewBag.indus = maxIndus;
                //list =list.OrderBy(e => (e.noteFstYear+e.noteSndYear)/2);
                if (db.settings.FirstOrDefault().importNote)
                {
                    return(View(list));
                }
                ViewBag.err = true;
                list        = list.OrderByDescending(e => e.nom).ToList();
                return(View(list));
            }
            else
            {
                return(RedirectToAction("Authentification", "User"));
            }
        }