コード例 #1
0
ファイル: BiensService.cs プロジェクト: salma21/SalmaP
        public void CreateBiens(AtbDataTest Biens)
        {

            utOfWork.BiensRepository.Add(Biens);


        }
コード例 #2
0
ファイル: BiensService.cs プロジェクト: salma21/SalmaP
 public void UpdateBiensDetached(AtbDataTest e)
 {
     utOfWork.BiensRepository.UpdateBiensDetached(e);
 }
コード例 #3
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<AtbDataTest> list = new List<AtbDataTest>();


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

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

                    catalogue.Num_serie = row["N° de série "].ToString();
                    catalogue.Categorie = row["Catégorie "].ToString();
                    catalogue.Modele = row["Modèle "].ToString();
                    catalogue.Marque = row["Marque "].ToString();
                    catalogue.Statut = row["Statut "].ToString();
                    catalogue.Fin_garantie = row["Fin de garantie "].ToString();
                    catalogue.Localisation_dernier = row["Localisation (dernier niveau) "].ToString();

                    catalogue.Entite_dernier = row["Entité (dernier niveau) "].ToString();
                    catalogue.Date_inventaire = row["Date inventaire "].ToString();
                    catalogue.Date_installation = row["Date d'installation "].ToString();
                    catalogue.Localisation_complet = row["Localisation (complet) "].ToString();

                    catalogue.Entite_complet = row["Entité (complet) "].ToString();
                    //catalogue.Code_materiel.ToString() = Code;
                    list.Add(catalogue);
                    BissInventaireEntities.Instance.AtbDataTest.Add(catalogue);

                    BissInventaireEntities.Instance.SaveChanges();
                }

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

                return View("Create1");
            }
            return HttpNotFound();
        }
コード例 #4
0
        public ActionResult Create1(AtbDataTest customer)
        {

            return View();
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: salma21/SalmaP
        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];
                    //Save file content goes here
                    fName = file.FileName;
                    fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName);
                    if (file != null && file.ContentLength > 0)
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}Fichiers", Server.MapPath(@"\")));
                        string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "Files");
                        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);
                    }
                }
            }
            catch
            {
                isSavedSuccessfully = false;
            }

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


                ds = ExcelParser.Instance.ExcelParserToDataTable(pathFile, null);
                foreach (DataRow row in ds.Rows)
                {
                    AtbDataTest catalogue = new AtbDataTest();
                    catalogue.Code_materiel = (int)row["test1"];

                    catalogue.Num_serie = row["test2"].ToString();
                    catalogue.Categorie = row["test3"].ToString();
                    catalogue.Modele = row["test4"].ToString();
                    catalogue.Marque = row["test5"].ToString();
                    catalogue.Statut = row["test6"].ToString();
                    catalogue.Fin_garantie = row["test7"].ToString();
                    catalogue.Localisation_dernier = row["test8"].ToString();

                    catalogue.Entite_dernier = row["test9"].ToString();
                    catalogue.Date_inventaire = row["test10"].ToString();
                    catalogue.Date_installation = row["test11"].ToString();
                    catalogue.Localisation_complet = row["test12"].ToString();

                    catalogue.Entite_complet = row["test13"].ToString();
                    list.Add(catalogue);

                }

              
                return View("Dashboard", "Admin");
            }
            return HttpNotFound();
        }
コード例 #6
0
ファイル: GestionController.cs プロジェクト: salma21/SalmaP
 public ActionResult Create1(AtbDataTest customer)
 {
     var test = bien.GetBienss();
     return View(test);
 }
コード例 #7
0
ファイル: GestionController.cs プロジェクト: salma21/SalmaP
 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");
     }
 }