コード例 #1
0
ファイル: PersonnelController.cs プロジェクト: salma21/SalmaP
        public ActionResult CreatePersonnel(Personnel pers, FormCollection collection)
        {
            int idregion     = db.FindRegionByBatiment(pers.idBatiment);
            int idgou        = db.FindGouverneratByBatiment(pers.idBatiment);
            int idpays       = db.FindPaysByBatiment(pers.idBatiment);
            int iddelegation = db.FindDelegationByBatiment(pers.idBatiment);
            int idorg        = db.FindOrganisationByDelegation(pers.idBatiment);

            pers.idDelegation   = iddelegation;
            pers.idRegion       = idregion;
            pers.idOrganisation = idorg;
            pers.idPays         = idpays;
            pers.idGouvernorat  = idgou;
            try
            {
                BissInventaireEntities.Instance.Personnel.Add(pers);
                BissInventaireEntities.Instance.SaveChanges();
                return(RedirectToAction("GetPersonnel"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #2
0
        public ActionResult CreateUsersTest(Utilisateur user, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    user.etatUtilisateur = true;
                    db1.CreateUtilisateurs(user);
                    db1.SaveEmploye();

                    var   Emp = (Utilisateur)Session["identifiant"];
                    Trace tr  = new Trace();
                    tr.Dates   = DateTime.Now;
                    tr.Actions = "Ajout utilisateur";
                    tr.Champs  = (user.Personnel.Matricule).ToString();
                    tr.Tables  = "Utilisateur";
                    tr.Users   = (Emp.Personnel.Matricule).ToString();
                    BissInventaireEntities.Instance.Trace.Add(tr);
                    BissInventaireEntities.Instance.SaveChanges();
                    return(RedirectToAction("GetUsers"));
                }
                catch (DbEntityValidationException r)
                {
                    foreach (var eve in r.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        LogThread.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors: " +
                                            eve.Entry.Entity.GetType().Name + " " + eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                            LogThread.WriteLine("- Property: \"{0}\", Error: \"{1}\" " +
                                                ve.PropertyName + " " + ve.ErrorMessage);
                            ViewBag.msg2 = "Exeption:  " + ve.ErrorMessage;
                        }
                    }

                    return(RedirectToAction("Index", "Error"));
                }
                catch (SqlException sq)
                {
                    LogThread.WriteLine(sq.Message);
                    return(RedirectToAction("Index", "Error"));
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["personel"] = new SelectList(BissInventaireEntities.Instance.Personnel.ToList(), "id", "Matricule");
                ViewData["batiment"] = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");
                return(View());
            }
        }
コード例 #3
0
        public ActionResult CreateRole(Role Catm, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (etat)
                    {
                        BissInventaireEntities.Instance.Role.Add(Catm);
                        BissInventaireEntities.Instance.SaveChanges();
                        return(RedirectToAction("GetRole"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Error"));
                    }
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                return(View());
            }
        }
コード例 #4
0
        public ActionResult CreateBienAdmin(Bien Bur, FormCollection collection)
        {
            if (Session["identifiant"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    BissInventaireEntities.Instance.Bien.Add(Bur);
                    BissInventaireEntities.Instance.SaveChanges();

                    return(RedirectToAction("RapportBien"));
                }

                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["depts"]  = new SelectList(db.GetBureaux(), "Id", "Description");
                ViewData["Bureau"] = new SelectList(BissInventaireEntities.Instance.Depot.ToList(), "id", "Description");
                return(View());
            }
        }
コード例 #5
0
        public ActionResult EditBureaux(Bureau etg)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.UpdateBureauDetached(etg);
                    db.SaveBureau();
                    return(RedirectToAction("GetBureuax"));
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["pays"]         = new SelectList(BissInventaireEntities.Instance.Pays.ToList(), "idPays", "libelle");
                ViewData["region"]       = new SelectList(BissInventaireEntities.Instance.Region.ToList(), "idRegion", "libelle");
                ViewData["gouvernorat"]  = new SelectList(BissInventaireEntities.Instance.Gouvernorat.ToList(), "idGouvernorat", "libelle");
                ViewData["organisation"] = new SelectList(BissInventaireEntities.Instance.Organisation.ToList(), "idOrganisation", "libelle");
                ViewData["delegation"]   = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                ViewData["batiment"]     = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");
                ViewData["etages"]       = new SelectList(BissInventaireEntities.Instance.Etage.ToList(), "Id_etage", "Description");
                return(View());
            }
        }
コード例 #6
0
        public ActionResult CreateEtage(Etage etag, FormCollection collection)
        {
            int iddelegation = db.FindDelegationByBatiment(etag.idBatiment);

            IEtageService et = new EtageService();

            if (ModelState.IsValid)
            {
                try
                {
                    et.CreateEtage(etag);
                    et.SaveEtage();
                    return(RedirectToAction("GetEtage"));
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["delegation"] = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                ViewData["batiment"]   = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");

                return(View());
            }
        }
コード例 #7
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        public ActionResult ActDesactiveUsers(int id)
        {
            var test = db1.GetUtilisateurById(id);

            try
            {
                if (test.etatUtilisateur == true)
                {
                    test.etatUtilisateur = false;
                    db1.UpdateUtilisateurDetached(test);
                    db1.SaveEmploye();
                }
                else
                {
                    test.etatUtilisateur = true;
                    db1.UpdateUtilisateurDetached(test);
                    db1.SaveEmploye();
                }


                return(RedirectToAction("GetUsers"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #8
0
        public ActionResult createMarque(Marque marque, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (etat)
                    {
                        BissInventaireEntities.Instance.Marque.Add(marque);
                        BissInventaireEntities.Instance.SaveChanges();
                        return(RedirectToAction("getMarque"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Error"));
                    }
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["categorie"] = new SelectList(BissInventaireEntities.Instance.Categorie.ToList(), "Id_categorie", "libelle");
                return(View());
            }
        }
コード例 #9
0
        public ActionResult CreateInventaire(Inventaire reg)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    reg.Date = DateTime.Now;
                    //db.CreateInventaire(reg);
                    //db.SaveInventaire();
                    BissInventaireEntities.Instance.Inventaire.Add(reg);
                    BissInventaireEntities.Instance.SaveChanges();

                    return(RedirectToAction("GetInventaire"));
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                return(View());
            }
        }
コード例 #10
0
        public ActionResult createSousModele(Sous_modele sousModele, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (etat)
                    {
                        BissInventaireEntities.Instance.Sous_modele.Add(sousModele);
                        BissInventaireEntities.Instance.SaveChanges();
                        return(RedirectToAction("getSousModele"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Error"));
                    }
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                return(View());
            }
        }
コード例 #11
0
        public ActionResult CreateAchat(Achat achat, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var four = fourni.FindFourByID(achat.Id_fournisseur);
                    //achat.Date_d_achat = System.DateTime.Now;
                    achat.idDelegation = four.idDelegation;
                    db.Achat.Add(achat);
                    db.SaveChanges();


                    return(RedirectToAction("GetAchat"));
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["region"]       = new SelectList(BissInventaireEntities.Instance.Region.ToList(), "idRegion", "libelle");
                ViewData["pays"]         = new SelectList(BissInventaireEntities.Instance.Pays.ToList(), "idPays", "libelle");
                ViewData["delegations"]  = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                ViewData["gouvers"]      = new SelectList(BissInventaireEntities.Instance.Gouvernorat.ToList(), "idGouvernorat", "libelle");
                ViewData["fournisseurs"] = new SelectList(BissInventaireEntities.Instance.Fournisseur.ToList(), "Id_fournisseur", "Nom");

                ViewData["contratgar"] = new SelectList(BissInventaireEntities.Instance.Contrat.ToList(), "Id_contrat_garanti", "Num");
                ViewData["achats"]     = new SelectList(BissInventaireEntities.Instance.Achat.ToList(), "Id_achat", "Num_facture");
                return(View());
            }
        }
コード例 #12
0
        public ActionResult CreatePersonnel(Personnel pers, FormCollection collection)
        {
            //int idregion = db.FindRegionByBatiment(pers.idBatiment);
            //int idgou = db.FindGouverneratByBatiment(pers.idBatiment);
            //int idpays = db.FindPaysByBatiment(pers.idBatiment);
            //int iddelegation = db.FindDelegationByBatiment(pers.idBatiment);
            //int idorg = db.FindOrganisationByDelegation(pers.idBatiment);
            //pers.idDelegation = iddelegation;
            //pers.idRegion = idregion;
            //pers.idOrganisation = idorg;
            //pers.idPays = idpays;
            //pers.idGouvernorat = idgou;

            if (ModelState.IsValid)
            {
                try
                {
                    if (etat)
                    {
                        BissInventaireEntities.Instance.Personnel.Add(pers);
                        BissInventaireEntities.Instance.SaveChanges();
                        var   Emp = (Utilisateur)Session["identifiant"];
                        Trace tr  = new Trace();
                        tr.Dates   = DateTime.Now;
                        tr.Actions = "Ajout Personnel";
                        tr.Champs  = (pers.Matricule).ToString();
                        tr.Tables  = "Personnel";
                        tr.Users   = (Emp.Personnel.Matricule).ToString();
                        BissInventaireEntities.Instance.Trace.Add(tr);
                        BissInventaireEntities.Instance.SaveChanges();
                        return(RedirectToAction("GetPersonnel"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Error"));
                    }
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return(RedirectToAction("Index", "Error"));
                }
            }
            else

            {
                ViewData["role"] = new SelectList(BissInventaireEntities.Instance.Role.ToList(), "id", "libelle");

                ViewData["batiment"]  = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");
                ViewData["direction"] = new SelectList(BissInventaireEntities.Instance.Direction.ToList(), "Id_direction", "Libelle");
                ViewData["service"]   = new SelectList(BissInventaireEntities.Instance.ServiceD.ToList(), "Id_service", "Libelle");
                ViewData["etage"]     = new SelectList(BissInventaireEntities.Instance.Etage.ToList(), "Id_etage", "description");
                ViewData["bureau"]    = new SelectList(BissInventaireEntities.Instance.Bureau.ToList(), "Id_bureau", "Description");
                return(View());
            }
        }
コード例 #13
0
 public ActionResult EditCategorie_materiel(Categorie_materiel Catm)
 {
     try
     {
         db.UpdateCategorie_materielDetached(Catm);
         db.SaveCategorie_materiel();
         return(RedirectToAction("GetCategorie_materiel"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #14
0
 public ActionResult CreateCategorie_materiel(Categorie_materiel Catm, FormCollection collection)
 {
     try
     {
         BissInventaireEntities.Instance.Categorie_materiel.Add(Catm);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetCategorie_materiel"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #15
0
        // GET: Categorie_materiel/Details/5
        public ActionResult Details(int Id_categorie)
        {
            try
            {
                var archive = BissInventaireEntities.Instance.Categorie_materiel.Find(Id_categorie);

                return(View(archive));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #16
0
 public ActionResult EditRegion(Region reg)
 {
     try
     {
         db.UpdateRegionDetached(reg);
         db.SaveRegion();
         return(RedirectToAction("GetRegion"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #17
0
 public ActionResult CreateGouvernorat1(Gouvernorat gouv)
 {
     try
     {
         BissInventaireEntities.Instance.Gouvernorat.Add(gouv);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetGouvernorat1"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #18
0
 public ActionResult EditEtage(Etage etg)
 {
     try
     {
         etage.UpdateEtageDetached(etg);
         etage.SaveEtage();
         return(RedirectToAction("GetEtage"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #19
0
 public ActionResult EditStock(Stock etg)
 {
     try
     {
         bien.UpdateStockDetached(etg);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetStock"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #20
0
 public ActionResult CreateEtage(Etage etg)
 {
     try
     {
         BissInventaireEntities.Instance.Etage.Add(etg);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetEtage"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #21
0
 public ActionResult CreateDirection(Direction direction)
 {
     try
     {
         BissInventaireEntities.Instance.Direction.Add(direction);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetDirection"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #22
0
 public ActionResult CreatePays(Pays pay)
 {
     try
     {
         BissInventaireEntities.Instance.Pays.Add(pay);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetPays"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #23
0
 public ActionResult EditOrganisation(Organisation org)
 {
     try
     {
         db3.UpdateOrganisationDetached(org);
         db3.SaveOrganisation();
         return(RedirectToAction("GetOrganisation"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #24
0
 public ActionResult EditGouvernorat(Gouvernorat gouv)
 {
     try
     {
         db1.UpdateGouvernoratDetached(gouv);
         db1.SaveGouvernorat();
         return(RedirectToAction("GetGouvernorat"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #25
0
 public ActionResult EditAchat(Achat acht, FormCollection collection)
 {
     try
     {
         db1.UpdateAchatDetached(acht);
         db.SaveChanges();
         return(RedirectToAction("GetAchat"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #26
0
 public ActionResult CreateBiens(AtbDataTest reg)
 {
     try
     {
         BissInventaireEntities.Instance.AtbDataTest.Add(reg);
         BissInventaireEntities.Instance.SaveChanges();
         return(RedirectToAction("GetRegion"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #27
0
 public ActionResult EditServiceD(ServiceD Catm, FormCollection collection)
 {
     try
     {
         db.UpdateServiceDDetached(Catm);
         db.SaveServiceD();
         return(RedirectToAction("GetServiceD"));
     }
     catch (Exception ex)
     {
         LogThread.WriteLine(ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
コード例 #28
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        // GET: Admin/Details/5
        public ActionResult DetailsBien(int id)
        {
            try
            {
                var archive = BissInventaireEntities.Instance.Bien.Find(id);

                return(View(archive));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #29
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        public ActionResult CreateBureaux(Bureau Bur, FormCollection collection)
        {
            try
            {
                db.CreateBureau(Bur);
                db.SaveBureau();

                return(RedirectToAction("GetBureuax"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #30
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        public ActionResult CreateUsers(Utilisateur user, FormCollection collection)
        {
            try
            {
                db1.CreateUtilisateurs(user);
                db1.SaveEmploye();

                return(RedirectToAction("GetUsers"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }