Exemplo n.º 1
0
        public ActionResult UploadNsPartNos(UpldNsPartsImpIModel model, IEnumerable<HttpPostedFileBase> uploadedFiles)
        {
            HttpPostedFileBase file = uploadedFiles.IfNotNull(f => f.First());
            if (file == null)
            {
                ModelState.AddModelError("", "No file was uploaded");
            }
            if (ModelState.IsValid)
            {
                model.FileName = file.FileName;
                model.QtyLoaded = 0;

                Stream stream = file.InputStream;
                StreamReader sr = new StreamReader(stream);

                int partCount = 0;
                if (model.SkipFirstRow)
                {
                    sr.ReadLine();
                }

                //PS_TO_NS_PARTNO newPart = new PS_TO_NS_PARTNO();
                //newPart.INTERNALID = "1";
                //newPart.NS_NAME = "One";
                //UtilDBContext.PS_TO_NS_PARTNOS.AddObject(newPart);
                //UtilDBContext.SaveChanges();

                        string sql = "DELETE FROM PS_TO_NS_PARTNO";
                        UtilDBContext.ExecuteStoreCommand(sql);
                        //UtilDBContext.SaveChanges();

                int insertCount = 0;
                insertCount = ReadFileLoadParts(sr);
                while (insertCount != 0)
                {
                    partCount = partCount + insertCount;
                    insertCount = ReadFileLoadParts(sr);
                }

                //UtilDBContext.SaveChanges();

                model.QtyLoaded = partCount;
            }
            return View(model);
        }
Exemplo n.º 2
0
 public ActionResult UploadNsPartNos()
 {
     UpldNsPartsImpIModel model = new UpldNsPartsImpIModel();
     return View(model);
 }