//update SuperCategory public int UpdateSuper(Master_SuperCategory a) { int i; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); string q = "update Master_SuperCategory set SuperCategoryName=@SuperCategoryName, SuperCategoryDescription=@SuperCategoryDescription where SuperCategoryID=@SuperCategoryID"; SqlCommand com = new SqlCommand(q, con); com.Parameters.AddWithValue("@SuperCategoryID", a.SuperCategoryID); com.Parameters.AddWithValue("@SuperCategoryName", a.SuperCategoryName); com.Parameters.AddWithValue("@SuperCategoryDescription", a.SuperCategoryDescription); i = com.ExecuteNonQuery(); } return(i); }
public JsonResult AddSuper(Master_SuperCategory sc) { HttpPostedFileBase file = Request.Files[0]; //Uploaded file int fileSize = file.ContentLength; string fileName = file.FileName; string filePath = "/SuperImages/" + fileName; file.SaveAs(Server.MapPath(filePath)); string mimeType = file.ContentType; System.IO.Stream fileContent = file.InputStream; //To save file, use SaveAs method //fname = Path.Combine(Server.MapPath("~/SuperImages/" + fileName)); //file.SaveAs(fname); //File will be saved in application root //sc.SuperCategoryIcon = fname; sc.SuperCategoryIcon = filePath; return(Json(db.AddSuperC(sc), JsonRequestBehavior.AllowGet)); }
//Add SuperCategory public int AddSuperC(Master_SuperCategory sc) { int i; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); string q = "insert into Master_SuperCategory(SuperCategoryName,SuperCategoryDescription,SuperCategoryIcon) values(@SuperCategoryName,@SuperCategoryDescription,@SuperCategoryIcon)"; SqlCommand com = new SqlCommand(q, con); // com.Parameters.AddWithValue("@SuperCategoryID", sc.SuperCategoryID); com.Parameters.AddWithValue("@SuperCategoryName", sc.SuperCategoryName); com.Parameters.AddWithValue("@SuperCategoryDescription", sc.SuperCategoryDescription); com.Parameters.AddWithValue("@SuperCategoryIcon", sc.SuperCategoryIcon); i = com.ExecuteNonQuery(); //try //{ // if (SuperCategoryIcon != null && SuperCategoryIcon.ContentLength > 0) // { // string filename = Path.GetFileName(SuperCategoryIcon.FileName); // //string fileExtension = Path.GetExtension(filename); // string imgpath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/SuperImages/"), filename); // SuperCategoryIcon.SaveAs(imgpath); // } // com.Parameters.AddWithValue("@SuperCategoryIcon", "~/SuperImages/" + SuperCategoryIcon.FileName); //} //catch (Exception ex) //{ // return 0; //} return(i); } }
public JsonResult update(Master_SuperCategory sc) { return(Json(db.UpdateSuper(sc), JsonRequestBehavior.AllowGet)); }