public ActionResult ImageFiles() { try { var Employee_Id = Session["UserID"]; var docname = Request.Params["docname"].ToString(); if (Request.Files.Count > 0) { var file = Request.Files[0]; string FileName = file.FileName; if (file != null && file.ContentLength > 0) { BinaryReader reader = new BinaryReader(file.InputStream); MTSHRDataLayer.EmployeeDocuments data_doc = new MTSHRDataLayer.EmployeeDocuments(); byte[] bytes = reader.ReadBytes((int)file.ContentLength); int result = data_doc.Create(Employee_Id, docname, bytes, FileName); return(Content("Success")); } } } catch (Exception exec) { BaseExceptionHandler.HandleException(ref exec); } return(Content("Failed")); }
private List <SelectListItem> getdocumentname() { MTSHRDataLayer.EmployeeDocuments data_doc = new MTSHRDataLayer.EmployeeDocuments(); var Documents = data_doc.getemployeedocuments(); List <SelectListItem> docu = new List <SelectListItem>(); docu.Add(new SelectListItem() { Value = "", Text = "----Select Documents----" }); for (int i = 0; i < Documents.Tables[0].Rows.Count; i++) { docu.Add(new SelectListItem() { Value = Documents.Tables[0].Rows[i]["id"].ToString(), Text = Documents.Tables[0].Rows[i]["Documents"].ToString() }); } return(docu); }
public ActionResult GetDocuments(string Documents, string functiontype) { try { Int64 Employee_Id = Convert.ToInt64(Request.Headers["employeeid"]); if (Employee_Id == 0) { Employee_Id = Convert.ToInt64(Session["UserID"]); } int Documentid = Convert.ToInt32(Documents); MTSHRDataLayer.EmployeeDocuments data_document = new MTSHRDataLayer.EmployeeDocuments(); DataTable Documentimage = data_document.Read(Documentid, Employee_Id); if (Documentimage.Rows.Count > 0) { byte[] imagedata = Documentimage.Rows[0]["DocumentImage"] as byte[]; string imagename = Documentimage.Rows[0]["DocumentName"].ToString(); string baseimage = Convert.ToBase64String(imagedata); TempData["image"] = baseimage; TempData["imagename"] = imagename; TempData["functiontype"] = functiontype; TempData.Keep("functiontype"); return(Content("Success")); } else { return(Content("Failed")); } } catch (Exception exec) { BaseExceptionHandler.HandleException(ref exec); } return(Content("Failed")); }