public ActionResult PancardDoc(userdocument user) { connection(); SqlCommand cmd = new SqlCommand("sp_Uploaduserocument", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); //if (user.Cardno != null) //{ cmd.Parameters.AddWithValue("@userid", Convert.ToString(Session["userid"])); cmd.Parameters.AddWithValue("@Documetname", user.Documetname); cmd.Parameters.AddWithValue("@Cardno", user.Cardno); cmd.Parameters.AddWithValue("@Createdate", user.Createdate); cmd.Parameters.AddWithValue("@Expirydate", user.expirydate); if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any()) { var pic = System.Web.HttpContext.Current.Request.Files["HelpSectionImages"]; cmd.Parameters.AddWithValue("@ImgFileName", pic.FileName); cmd.Parameters.AddWithValue("@imgType", pic.ContentType); cmd.Parameters.AddWithValue("@imgContentLength", pic.ContentLength); cmd.Parameters.AddWithValue("@imgInputStream", pic.InputStream); } cmd.ExecuteNonQuery(); con.Close(); return(RedirectToAction("UploadDocument")); //} //else //{ // return View(user); //} }
public ActionResult ViewImage(userdocument user) { ViewBag.Message = "Success"; connection(); con.Open(); SqlCommand cmd = new SqlCommand("select * from user_documetlist", con); SqlDataReader reader = cmd.ExecuteReader(); //SqlCommand cmd = new SqlCommand("sp_ViewImage", con); //cmd.CommandType = CommandType.StoredProcedure; //SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (Convert.ToInt32(Session["userid"]) == Convert.ToInt32(reader["userid"])) { byte[] binaryString = (byte[])reader["imgInputStream"]; MemoryStream ms = new MemoryStream(); ms.Write(binaryString, 0, binaryString.Length); user = new userdocument(); //user.docimage = Encoding.UTF8.GetString(binaryString); string base64 = Convert.ToBase64String(ms.ToArray()); var imgsrc = String.Format("data:image/png;base64, {0}", base64); ViewData["imgpath"] = imgsrc; } } return(View(user)); }
/// <summary> /// Show All Your Docments /// </summary> /// <returns></returns> public ActionResult UploadDocument() { ViewBag.Message = "Success"; userdocument user = new userdocument(); List <userdocument> userlist = new List <userdocument>(); userlist = user.showdoc(Convert.ToInt32(Session["userid"])); ViewData["userdata"] = userlist; return(View()); }
public List <userdocument> showdoc(int id) { dbcon.Connection(); SqlCommand cmd = new SqlCommand("select * from user_documetlist", dbcon.con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (id == Convert.ToInt32(reader["userid"])) { userdocument user = new userdocument(); user.userdocno = Convert.ToInt32(reader["Userdocno"]); user.Documetname = Convert.ToString(reader["Documetname"]); //DocumentsName Documetname = (DocumentsName)Enum.ToObject(typeof(DocumentsName), Convert.ToString(reader.GetSqlValue(2))) ; user.Cardno = Convert.ToString(reader["Cardno"]); user.Createdate = Convert.ToString(reader["Createdate"]); user.expirydate = Convert.ToString(reader["Expirydate"]); userdoc.Add(user); } } return(userdoc); }
public ActionResult UpdateDocument(userdocument user) { return(View(user)); }