public List <HoSoLuuTru> GetHoSoLuuTru(string maBN) { List <HoSoLuuTru> hslts = new List <HoSoLuuTru>(); List <dtb_patient_document> listFiles = (from s in dbFile.dtb_patient_documents select s).ToList(); foreach (var file in listFiles) { if (file.patient_code == maBN) { HoSoLuuTru hs = new HoSoLuuTru(); hs.Id = file.id; hs.FileId = Convert.ToInt32(file.doc_id); hs.FileName = file.file_name; hs.MaBN = file.patient_code; hslts.Add(hs); } } return(hslts); }
public ActionResult ThemHoSo(FormCollection collection, HttpPostedFileBase TenDinhDanh) { if (User.Identity == null || Request.IsAuthenticated == false) { return(RedirectToAction("Login", "Home")); } string tenDinhDanhSystem = ""; string id = User.Identity.Name + "" + DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second; string name = User.Identity.Name; string LoaiHoSo; if (TenDinhDanh != null) { if (TenDinhDanh.FileName != "" && TenDinhDanh.ContentLength > 0)//500kb { string link = WebConfigurationManager.AppSettings["linkWebsiteQuanLyHoSo"]; string path = link + "/QuanLyHoSo/" + name + "/"; if (Directory.Exists(path) == false) { htmlHelper.createFolder(name); } tenDinhDanhSystem = id + Path.GetFileName(TenDinhDanh.FileName); var filePath = path + tenDinhDanhSystem; TenDinhDanh.SaveAs(Server.MapPath(filePath)); string[] doc = tenDinhDanhSystem.Split('.'); LoaiHoSo = doc[doc.Length - 1]; HoSoLuuTru hoso = new HoSoLuuTru(); hoso.NguoiDung = name; hoso.DuongDan = filePath; hoso.LoaiHoSo = LoaiHoSo; hoso.TenDinhDanh = tenDinhDanhSystem; hoso.TenHoSo = collection["txtHoSo"].ToString(); hoso.GhiChu = collection["txtGhiChu"].ToString(); string str = this.gISRepository.saveHoSoLuuTru(hoso); if (str.Trim().Length > 0) { ViewBag.message = "Hệ thống đang quá tải. Vui lòng thử lại lúc khác"; } else { ViewBag.message = "Đã lưu hồ sơ thành công"; } } else { ViewBag.message = "Bạn chưa chọn hồ sơ để lưu vào hệ thống"; } } else { ViewBag.message = "Bạn chưa chọn hồ sơ để lưu vào hệ thống"; } return(View()); }