public ActionResult Modification([Bind(Include = "cne,nationalite,email,phone,gsm,address,ville,dateNaiss,lieuNaiss")] Etudiant etudiant, string Update, String choix1, String choix2, String choix3)
        {
            ViewBag.Current = "Modification";

            /*Update name of buttom if user click in Upload l image seule va etre modifie
             *
             */

            Etudiant etudiants = etudiantContext.etudiants.Find(etudiant.cne);

            if (Request.Files.Count > 0 && Update == "Upload")
            {
                //Recupere le fichier est le sauvegarder dans /image/
                HttpPostedFileBase file      = Request.Files[0];
                string             fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                string             extension = Path.GetExtension(file.FileName);
                ViewBag.exte = extension;
                if (fileName != "" && ImageEx.Contains(extension) == true)
                {
                    fileName             = etudiants.nom + DateTime.Now.ToString("yymmssfff") + extension;
                    etudiants.photo_link = fileName;
                    fileName             = Path.Combine(Server.MapPath("~/Image/"), fileName);
                    file.SaveAs(fileName);
                    etudiants.Modified = true;
                    etudiantContext.SaveChanges();
                    return(View(etudiants));
                }
                else
                {
                    ViewBag.err = " vous devez selectionner une image";
                    return(View(etudiants));
                }
            }

            else
            {
                ViewBag.err = null;

                //si clicke sur les valider les modification
                etudiants.Modified    = true;
                etudiants.Choix       = choix1 + choix2 + choix3;
                etudiants.nationalite = etudiant.nationalite;
                etudiants.email       = etudiant.email;
                etudiants.phone       = etudiant.phone;
                etudiants.address     = etudiant.address;
                etudiants.gsm         = etudiant.gsm;
                etudiants.address     = etudiant.address;
                etudiants.ville       = etudiant.ville;
                etudiants.dateNaiss   = etudiant.dateNaiss;
                etudiants.lieuNaiss   = etudiant.lieuNaiss;
                etudiantContext.SaveChanges();
                return(RedirectToAction("SendEmailToUser"));
            }
        }
예제 #2
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"));
            }
        }
예제 #3
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 Create(User user)
        {
            // TODO: Encrypt password
            _context.Update(user);
            _context.SaveChanges();

            return(new ObjectResult(user.Id));
        }
예제 #5
0
        public IActionResult Create(Student student)
        {
            // Save Image
            if (!string.IsNullOrEmpty(student.Photo))
            {
                string base64   = student.Photo;
                var    filePath = Path.Combine(string.Format("Uploads/Students/{0}.png", student.IndexNumber));
                _fileManager.SaveFile(filePath, base64);

                student.Photo = student.IndexNumber;
            }

            _context.Update(student);
            _context.SaveChanges();

            return(new ObjectResult(student));
        }
예제 #6
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"));
        }
예제 #7
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"));
            }
        }
예제 #8
0
 public IActionResult Create(Branch branch)
 {
     _context.Update(branch);
     _context.SaveChanges();
     return(Ok(branch.Id));
 }
예제 #9
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"));
            }
        }
예제 #10
0
        public ActionResult ImporterEtudiantExcel(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 = new Etudiant();
                            e.nom = workSheet.Cells[rowIterator, 1].Value.ToString();

                            e.prenom = workSheet.Cells[rowIterator, 2].Value.ToString();

                            //e.nationalite = workSheet.Cells[rowIterator, 3].Value.ToString();

                            e.cin = workSheet.Cells[rowIterator, 3].Value.ToString();

                            e.cne = workSheet.Cells[rowIterator, 4].Value.ToString();

                            /*
                             * e.email = workSheet.Cells[rowIterator, 6].Value.ToString();
                             *
                             * e.phone = workSheet.Cells[rowIterator, 7].Value.ToString();
                             *
                             *
                             * e.gsm = workSheet.Cells[rowIterator, 8].Value.ToString();
                             *
                             * e.address = workSheet.Cells[rowIterator, 9].Value.ToString();
                             *
                             * e.ville = workSheet.Cells[rowIterator,10].Value.ToString();
                             *
                             *
                             * e.typeBac = workSheet.Cells[rowIterator, 11].Value.ToString();*/

                            //e.anneeBac = Convert.ToDateTime(DateTime.Now);

                            //e.anneeBac = Convert.ToDateTime(DateTime.Now);

                            e.dateNaiss = Convert.ToDateTime(DateTime.Now);

                            /*
                             * e.noteBac = Convert.ToDouble(workSheet.Cells[rowIterator, 13].Value);
                             * e.mentionBac = workSheet.Cells[rowIterator, 14].Value.ToString();
                             *
                             * e.lieuNaiss = workSheet.Cells[rowIterator, 16].Value.ToString();
                             */
                            db.etudiants.Add(e);
                            Console.WriteLine(" out ......");
                        }
                        db.settings.First().importEtudiant = true;
                        db.SaveChanges();
                        for (int i = 0; i < db.etudiants.ToList().Count; i++)
                        {
                            db.etudiants.ToList()[i].Choix = "FDT";
                        }
                        db.SaveChanges();
                    }
                }
                else
                {
                    ViewBag.errI = true;
                    return(View("ImporterEtudiants"));
                }
            }
            return(RedirectToAction("Index"));
            //return View("Index");
        }
예제 #11
0
 public IActionResult Create(Class @class)
 {
     _context.Update(@class);
     _context.SaveChanges();
     return(Ok(@class.Id));
 }
예제 #12
0
 public void Save(Etudiant e)
 {
     db.Etudiant.Add(e);
     db.SaveChanges();
 }
예제 #13
0
 public IActionResult Create(Attendance attendance)
 {
     _context.Update(attendance);
     _context.SaveChanges();
     return(Ok(attendance.Id));
 }
예제 #14
0
 public IActionResult Create(StudentClass studentClass)
 {
     _context.Update(studentClass);
     _context.SaveChanges();
     return(Ok(studentClass.Id));
 }