Beispiel #1
0
        public JsonResult UpdateDetail(int ID, string COLUMN, string VALUE)
        {
            HIS_DETAIL his    = new HIS_DETAIL();
            var        result = his.Update(ID, COLUMN, VALUE);

            return(Json(result));
        }
Beispiel #2
0
        public ActionResult Upload(HttpPostedFileBase OUTCOME_RESULT, int ID)
        {
            var allowedExtensions = new[] { ".ppt", ".pptx" };
            var ext = Path.GetExtension(OUTCOME_RESULT.FileName).ToLower();

            if (!allowedExtensions.Contains(ext))
            {
                TempData["message"] = "Upload fail. Please select ppt/pptx file";
                return(Redirect(Request.UrlReferrer.ToString()));
            }
            HIS_DETAIL detail = new HIS_DETAIL();
            var        mypath = "~/Upload/File/" + ID.ToString();
            var        path   = Server.MapPath(mypath);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            DirectoryInfo di = new DirectoryInfo(path);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            string savedFileName = Path.Combine(path, Path.GetFileName(OUTCOME_RESULT.FileName));

            OUTCOME_RESULT.SaveAs(savedFileName);
            string fileName = Path.GetFileName(OUTCOME_RESULT.FileName);

            var result = detail.Update(ID, "OUTCOME_RESULT", mypath + "/" + fileName);

            if (result > 0)
            {
                TempData["message"] = "Upload success";
            }
            else
            {
                TempData["message"] = "Upload fail";
            }
            return(Redirect(Request.UrlReferrer.ToString()));
        }