コード例 #1
0
        public void CreateBien(Bien Bien)
        {

            utOfWork.BienRepository.Add(Bien);


        }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        public ActionResult CreateBienAdmin(Bien Bur, FormCollection collection)
        {
            try
            {
                BissInventaireEntities.Instance.Bien.Add(Bur);
                BissInventaireEntities.Instance.SaveChanges();

                return RedirectToAction("RapportBien");
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return RedirectToAction("Index", "Error");
            }
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: salma21/SalmaP
        public ActionResult CreateBien(Bien Bur, FormCollection collection)
        {
            //int region = db2.FindRegionByDelegation(Bur.idDelegation);
            //int gouv = db2.FindGouvByDelegation(Bur.idDelegation);
            //int pays = db2.FindPaysByDelegation(Bur.idDelegation);
            //int organisation = db2.FindOrganisationByDelegation(Bur.idBatiment);
            int direct = db2.FindDirectionByDelegation(Bur.Id_bureau);

            //Bur.idRegion = region;
            //Bur.idGouvernorat = gouv;
            //Bur.idPays = pays;
            //Bur.idOrganisation = organisation;
            Bur.Id_direction = direct;

            BissInventaireEntities.Instance.Bien.Add(Bur);
                BissInventaireEntities.Instance.SaveChanges();

                return RedirectToAction("RapportBien");
        
        }
コード例 #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 CreateBien(Bien bien, FormCollection collection)
        {
            if (Session["identifiant"] == null)
            { return RedirectToAction("Index", "Home"); }
            if (ModelState.IsValid)
            {

                try
                {
                    HttpPostedFileBase file = Request.Files["ImageData"];
                    bien.Photo = ConvertToBytes(file);
                    var photo = bien.Photo;
                    BissInventaireEntities.Instance.Bien.Add(bien);
                    BissInventaireEntities.Instance.SaveChanges();

                    return RedirectToAction("RapportBien");

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

            {
                ViewData["achats"] = new SelectList(BissInventaireEntities.Instance.Achat.ToList(), "Id_achat", "Num_livraison");

                ViewData["societemain"] = new SelectList(BissInventaireEntities.Instance.Fournisseur.ToList(), "Id_fournisseur", "Libelle");
                ViewData["pers"] = new SelectList(BissInventaireEntities.Instance.Personnel.ToList(), "id_pers", "nom", "prenom");
                ViewData["personnel"] = new SelectList(BissInventaireEntities.Instance.Personnel.ToList(), "id_pers", "Matricule");
                ViewData["categorie"] = new SelectList(BissInventaireEntities.Instance.Categorie.ToList(), "Id_categorie", "libelle");
                ViewData["Delegation"] = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                ViewData["service"] = new SelectList(BissInventaireEntities.Instance.ServiceD.ToList(), "Id_service", "Libelle");
                ViewData["contratmain"] = new SelectList(BissInventaireEntities.Instance.Contrat.ToList(), "Id_contrat_maintenance", "Num");
                ViewData["categorie"] = new SelectList(BissInventaireEntities.Instance.Categorie.ToList(), "Id_categorie", "libelle");
                ViewData["Depot"] = new SelectList(BissInventaireEntities.Instance.Depot.ToList(), "IdDepot", "libelle");
                ViewData["Bureau"] = new SelectList(BissInventaireEntities.Instance.Depot.ToList(), "id", "Description");

                return View();
            }
        }
コード例 #6
0
        public ActionResult SaveUploadedFile(string id)
        {
            bool isSavedSuccessfully = true;
            string fName = "";
            string fileName1 = "";
            string fileExtension = "";
            string pathFile = "";
            DataTable ds = new DataTable();
            try
            {
                foreach (string fileName in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[fileName];

                    fName = file.FileName;
                    fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName);
                    if (file != null && file.ContentLength > 0 && (file.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx")))
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}Fichiers", Server.MapPath(@"\")));
                        string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "Exels");
                        fileName1 = Path.GetFileName(file.FileName);
                        bool isExists = System.IO.Directory.Exists(pathString);
                        if (!isExists)
                            System.IO.Directory.CreateDirectory(pathString);
                        pathFile = string.Format("{0}\\{1}", pathString, file.FileName);
                        file.SaveAs(pathFile);
                    }
                    else
                    {
                        ViewBag.Error = "Selectionner un fichier Excel SVP !!!";
                        return View("Index");
                    }


                }
            }
            catch (Exception ex)
            {
                isSavedSuccessfully = false;
            }

            if (isSavedSuccessfully)
            {
                List<Bien> list = new List<Bien>();


                ds = ExcelParser.Instance.ExcelParserToDataTable(pathFile, null);
                foreach (DataRow row in ds.Rows)
                {
                    Bien catalogue = new Bien();

                    //catalogue.Code_a_barre = Convert.ToInt32(row["Code matériel "]);

                    catalogue.Num_Serie = row["N° de série "].ToString();
                    ///var i = db.FindCategorie_materielByNom(row["Catégorie "].ToString());
                    //catalogue.Categorie_materiel = Convert.ToString(i.Id_Categorie_materiel);

                    catalogue.Modele = row["Modèle "].ToString();
                    catalogue.Marque = row["Marque "].ToString();
                    catalogue.Etat = row["Statut "].ToString();
                    //catalogue.Fin_garantie = Convert.ToDateTime(row["Fin de garantie "]);
                    catalogue.Id_etage = Convert.ToInt32(row["Localisation (dernier niveau) "]);

                    catalogue.idBatiment = Convert.ToInt32(row["Entité (dernier niveau) "]);
                    //catalogue.Date_d_inventaire = Convert.ToDateTime(row["Date inventaire "]);
                    catalogue.Date_d_installation = Convert.ToDateTime(row["Date d'installation "]);
                    catalogue.idBatiment = Convert.ToInt32(row["Localisation (complet) "]);

                    //catalogue.id_direction = Convert.ToInt32(row["Entité (complet) "]);
                    //catalogue.Code_materiel.ToString() = Code;
                    list.Add(catalogue);
                    BissInventaireEntities.Instance.Bien.Add(catalogue);

                    BissInventaireEntities.Instance.SaveChanges();
                }

                Session["Tesst"] = list.ToList();

                return View("Create1");
            }
            return HttpNotFound();
        }
コード例 #7
0
        public ActionResult ImportTxt()
        {
            if (Session["identifiant"] == null)
            { return RedirectToAction("Index", "Home"); }
            bool isSavedSuccessfully = true;
            string fName = "";
            string fileName1 = "";
            string fileExtension = "";
            string pathFile = "";
            DataTable ds = new DataTable();
            try
            {
                foreach (string fileName in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[fileName];

                    fName = file.FileName;
                    fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName);
                    if (file != null && file.ContentLength > 0 && (file.FileName.EndsWith("txt")))
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}Fichiers", Server.MapPath(@"\")));
                        string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "Exels");
                        fileName1 = Path.GetFileName(file.FileName);
                        bool isExists = System.IO.Directory.Exists(pathString);
                        if (!isExists)
                            System.IO.Directory.CreateDirectory(pathString);
                        pathFile = string.Format("{0}\\{1}", pathString, file.FileName);
                        file.SaveAs(pathFile);
                        System.IO.Stream fileStream = file.InputStream;
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(fileStream))
                        {

                            int nbRows = System.IO.File.ReadAllLines(pathFile).Length;
                            //Read the first line from the file and write it the textbox.
                            var str = sr.ReadLine();
                            bool insert_test = true;
                            while (sr.Peek() != -1)
                            {
                                try
                                {
                                    str = sr.ReadLine();
                                    string[] splitVou = str.Split(new char[] { ';' });
                                    //Définition de la variable de récupération du résultat de l'exécution de la requête ci-dessus

                                    Bien a = new Bien();
                                    //a.Code_a_barre = Convert.ToInt32(splitVou[0]);
                                    //a.Num_Modele = Convert.ToInt32(splitVou[1]);
                                    BissInventaireEntities.Instance.Bien.Add(a);
                                    BissInventaireEntities.Instance.SaveChanges();
                                    insert_test = false;
                                }

                                catch (Exception)
                                {
                                    insert_test = false;
                                    return View("ImportTxt");

                                }
                                return RedirectToAction("Cipherlab");
                            }
                        }
                    }
                    else
                    {
                        ViewBag.Error = "Selectionner un fichier Text SVP !!!";
                        return View("ImportTxt");
                    }


                }
            }
            catch (Exception ex)
            {
                isSavedSuccessfully = false;
                return View("ImportTxt");
            }
            return View("ImportTxt");
        }
コード例 #8
0
        public ActionResult Create1(Bien customer)
        {
            if (Session["identifiant"] == null)
            { return RedirectToAction("Index", "Home"); }

            return View();
        }
コード例 #9
0
 public void UpdateBienDetached(Bien e)
 {
     utOfWork.BienRepository.UpdateBienDetached(e);
 }