Esempio n. 1
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 IActionResult Edit(EtudiantViewModel etudiantModel)
        {
            EtudiantContext etudiantContext = new EtudiantContext(connectionString);

            etudiantModel.Promotions = populatesPromotion();
            //Rajouter des contrôles dynamiques

            //if(etudiantModel.IdentifiantPromotion == 2)
            //{
            //    ModelState.AddModelError("IdentifiantPromotion", "Ne peut être égal à 2");
            //}

            IActionResult retour = null;

            if (ModelState.IsValid)
            {
                Etudiant etudiant = new Etudiant();

                etudiant.Identifiant = (int)etudiantModel.Identifiant;
                etudiant.Nom         = etudiantModel.Nom;
                etudiant.Prenom      = etudiantModel.Prenom;
                etudiant.IdPromotion = etudiantModel.IdPromotion;
                etudiant.Age         = etudiantModel.Age;
                etudiant.Genre       = etudiantModel.Genre;

                bool isOK = etudiantContext.Update(etudiant);
                retour = RedirectToAction("Index");
            }
            else
            {
                retour = View(etudiantModel);
            }

            return(retour);
        }
        public ActionResult Authentification(Departement login, string ReturnUrl = "")
        {
            String button  = Request["loginBtn"];
            string message = "";

            if (button == "Login")
            {
                string          userName  = Request["userName"];
                string          mdp       = Request["mdp"];
                EtudiantContext dbset     = new EtudiantContext();
                var             userLogin = (from data in dbset.departements
                                             where data.username == userName && data.password == mdp
                                             select data).FirstOrDefault();
                if (userLogin != null)
                {
                    Session["userName"] = userLogin.username;
                    Session["NomDep"]   = userLogin.nom_departement;
                    Session["EmailDep"] = userLogin.email;
                    Session["userId"]   = userLogin.id_departement;
                    Session["role"]     = "Departement";
                    return(RedirectToAction("Index", "Departement"));
                }
                else if (userLogin == null)
                {
                    message         = "Invalid username or password";
                    ViewBag.Message = message;
                    return(View());
                }
            }
            return(View());
        }
Esempio n. 4
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"));
            }
        }
        public ActionResult Resultat()
        {
            EtudiantContext db = new EtudiantContext();

            if (db.settings.FirstOrDefault().Attributted)
            {
                return(View(db.etudiants.OrderBy(e => e.nom).ToList()));
            }
            return(RedirectToAction("Authentification1"));
        }
        public IActionResult Delete(int id)
        {
            EtudiantContext etudiantContext = new EtudiantContext(connectionString);
            bool            isOK            = etudiantContext.Delete(id);

            DeleteEtudiantViewModel model = new DeleteEtudiantViewModel();

            model.IsDeleted = isOK;

            return(View(model));
        }
        public IActionResult Index()
        {
            EtudiantContext etudiantContext = new EtudiantContext(connectionString);
            List <Etudiant> etudiants       = etudiantContext.GetAll();

            EtudiantsViewModel model = new EtudiantsViewModel();

            model.Etudiants = etudiants;

            return(View(model));
        }
        public IActionResult Index()
        {
            EtudiantContext requetesEtudiants = new EtudiantContext(connectionString);
            List <Etudiant> Etudiants         = requetesEtudiants.GetAll();

            AcceuilViewModel model = new AcceuilViewModel();

            model.Etudiants = Etudiants;

            return(View(model));
        }
        public ActionResult Authentification1(Etudiant login, string ReturnUrl = "")
        {
            String button  = Request["loginBtn"];
            string message = "";

            if (button == "Login")
            {
                string          cne   = Request["cne"];
                string          cin   = Request["cin"];
                string          mdp   = Request["mdp"];
                EtudiantContext dbset = new EtudiantContext();
                ViewBag.Delai        = dbset.settings.FirstOrDefault().Delai;
                ViewBag.Attributted  = dbset.settings.FirstOrDefault().Attributted;
                ViewBag.DatedeRappel = dbset.settings.FirstOrDefault().DatedeRappel;
                var userLogin = (from data in dbset.etudiants
                                 where data.cne == cne && data.password == mdp && data.cin == cin && data.Validated == true
                                 select data).FirstOrDefault();
                if (userLogin != null)
                {
                    Session["cin"]    = userLogin.cin;
                    Session["userId"] = userLogin.cne;
                    Session["nom"]    = userLogin.nom;
                    Session["prenom"] = userLogin.prenom;

                    /* Session["nationalite"] = userLogin.nationalite;
                     * Session["email"] = userLogin.email;
                     * Session["phone"] = userLogin.phone;
                     * Session["gsm"] = userLogin.gsm;
                     * Session["address"] = userLogin.address;
                     * Session["ville"] = userLogin.ville;
                     * Session["typeBac"] = userLogin.prenom;
                     * Session["anneeBac"] = userLogin.anneeBac;
                     * Session["noteBac"] = userLogin.noteBac;
                     * Session["mentionBac"] = userLogin.mentionBac;
                     * Session["noteFstYear"] = userLogin.noteFstYear;
                     * Session["noteSndYear"] = userLogin.noteSndYear;
                     * Session["dateNaiss"] = userLogin.dateNaiss;
                     * Session["lieuNaiss"] = userLogin.lieuNaiss;
                     * Session["photo_link"] = userLogin.photo_link;
                     * Session["choix"] = userLogin.choix;*/
                    Session["role"] = "Etudiant";
                    return(RedirectToAction("Index", "Etudiant"));
                }
                else if (userLogin == null)
                {
                    message         = "Invalid cin or cne or password";
                    ViewBag.Message = message;
                    return(View());
                }
            }
            return(View());
        }
Esempio n. 10
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"));
            }
        }
Esempio n. 11
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"));
            }
        }
Esempio n. 12
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());
            }
        }
        public ActionResult Inscription()
        {
            EtudiantContext db = new EtudiantContext();

            ViewBag.Delai        = db.settings.FirstOrDefault().Delai;
            ViewBag.DatedeRappel = db.settings.FirstOrDefault().DatedeRappel;
            ViewBag.prenom       = new SelectList(etudiantContext.etudiants, "cne", "prenom");
            ViewBag.nom          = new SelectList(etudiantContext.etudiants, "cne", "nom");

            ViewBag.typeBac = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Sciences Physiques et Chimiques", Value = "1"
                },
                new SelectListItem {
                    Text = "Sciences Maths A", Value = "2"
                },
                new SelectListItem {
                    Text = "Sciences Maths B", Value = "3"
                },
                new SelectListItem {
                    Text = "Sciences et Technologies Electriques", Value = "4"
                },
                new SelectListItem {
                    Text = "Sciences et Technologies Mécaniques", Value = "5"
                }
            };
            ViewBag.mentionBac = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Passable", Value = "1"
                },
                new SelectListItem {
                    Text = "Assez bien", Value = "2"
                },
                new SelectListItem {
                    Text = "Bien", Value = "3"
                },
                new SelectListItem {
                    Text = "Très bien", Value = "4"
                },
            };


            return(View());
        }
        public IActionResult Edit(int id)
        {
            EtudiantContext   etudiantContext = new EtudiantContext(connectionString);
            Etudiant          etudiant        = etudiantContext.Get(id);
            EtudiantViewModel etudiantModel   = new EtudiantViewModel();

            etudiantModel.Identifiant = etudiant.Identifiant;
            etudiantModel.Nom         = etudiant.Nom;
            etudiantModel.Prenom      = etudiant.Prenom;
            etudiantModel.IdPromotion = etudiant.IdPromotion;
            etudiantModel.Genre       = etudiant.Genre;
            etudiantModel.Age         = etudiant.Age;

            etudiantModel.Promotions = populatesPromotion();

            return(View(etudiantModel));
        }
Esempio n. 16
0
        public void ExtraireNonValide()
        {
            EtudiantContext students = new EtudiantContext();

            //Création de la page excel
            ExcelPackage   excel     = new ExcelPackage();
            ExcelWorksheet worksheet = excel.Workbook.Worksheets.Add("Sheet1");

            //Style des noms de colonnes
            worksheet.Row(1).Style.Font.Bold           = true;
            worksheet.Row(1).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

            //Noms des colonnes
            worksheet.Cells[1, 1].Value = "Nom";
            worksheet.Cells[1, 2].Value = "Prenom";
            worksheet.Cells[1, 3].Value = "CIN";
            worksheet.Cells[1, 4].Value = "CNE";


            //Remplissage des cellules
            int rowIndex = 2;

            foreach (var student in students.etudiants.ToList())
            {
                worksheet.Cells[rowIndex, 1].Value = student.nom;
                worksheet.Cells[rowIndex, 2].Value = student.prenom;
                worksheet.Cells[rowIndex, 3].Value = student.cin;
                worksheet.Cells[rowIndex, 4].Value = student.cne;

                rowIndex++;
            }

            //Envoi du fichier dans par http
            using (var memoryStream = new MemoryStream())
            {
                Response.Clear();
                Response.ClearContent();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment; filename=EtudiantNonValideCompte.xlsx");
                excel.SaveAs(memoryStream);
                memoryStream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.Clear();
                Response.End();
            }
        }
Esempio n. 17
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. 18
0
        public ActionResult ImporterNoteExcel(HttpPostedFileBase excelFile)
        {
            if (Request != null)
            {
                EtudiantContext    db   = new EtudiantContext();
                HttpPostedFileBase file = Request.Files["excelfile"];
                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName) && (file.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx")))
                {
                    string fileName        = file.FileName;
                    string fileContentType = file.ContentType;
                    byte[] fileBytes       = new byte[file.ContentLength];
                    var    data            = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                    using (var package = new ExcelPackage(file.InputStream))
                    {
                        var currentSheet = package.Workbook.Worksheets;
                        var workSheet    = currentSheet.First();
                        var noOfCol      = workSheet.Dimension.End.Column;
                        var noOfRow      = workSheet.Dimension.End.Row;
                        Console.WriteLine("before entering ......");
                        for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                        {
                            Console.WriteLine(" entering ......");
                            Etudiant e = db.etudiants.Find(workSheet.Cells[rowIterator, 1].Value.ToString());
                            e.noteFstYear = Convert.ToDouble(workSheet.Cells[rowIterator, 2].Value);

                            e.noteSndYear = Convert.ToDouble(workSheet.Cells[rowIterator, 3].Value);



                            //db.etudiants.Add(e);
                            Console.WriteLine(" out ......");
                        }
                        db.settings.First().importNote = true;

                        db.SaveChanges();
                    }
                }
                else
                {
                    ViewBag.errI = true;
                    return(View("ImporterNotes"));
                }
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 19
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. 20
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. 21
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"));
            }
        }
 public UsersController(EtudiantContext context)
 {
     _context = context;
 }
Esempio n. 23
0
 public ParentsController(EtudiantContext context)
 {
     Context = context;
 }
Esempio n. 24
0
 public SallesController(EtudiantContext context)
 {
     _context = context;
 }
 public ItemController(EtudiantContext context)
 {
     Context = context;
 }
 public PackagesController(EtudiantContext context)
 {
     Context = context;
 }
 public CategoryController(EtudiantContext context)
 {
     Context = context;
 }
Esempio n. 28
0
 public GoodReceiveNoteMainController(EtudiantContext context)
 {
     Context = context;
 }
Esempio n. 29
0
 public BranchesController(EtudiantContext context)
 {
     _context = context;
 }
Esempio n. 30
0
 public EnseignesController(EtudiantContext context)
 {
     _context = context;
 }