public ActionResult Edit(int Id) { using (InventryDBEntities db = new InventryDBEntities()) { var std = db.Tbl_products.Where(s => s.product_id == Id).FirstOrDefault(); //PSession.bid = std.brand_id; //PSession.cid = std.category_id; return(View(std)); } }
public JsonResult GetAllBrands(int bid) { using (InventryDBEntities db = new InventryDBEntities()) { IEnumerable <GetAllBrands_Result> obj = db.Database.SqlQuery <GetAllBrands_Result>("exec GetAllBrands").ToList <GetAllBrands_Result>().ToList(); List <SelectListItem> result = new List <SelectListItem>(); result.Add(new SelectListItem { Text = "--Select--", Value = 0.ToString() }); result.AddRange(obj.Select(d => new SelectListItem { Text = d.brand_name, Value = d.brand_id.ToString() }).ToList()); return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteProduct(int pid) { try { using (InventryDBEntities db = new InventryDBEntities()) { Tbl_products std = db.Tbl_products.Where(x => x.product_id == pid).FirstOrDefault(); db.Tbl_products.Remove(std); db.SaveChanges(); } return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(false, JsonRequestBehavior.DenyGet)); } }
public JsonResult GetallProduct() { try { using (var ctx = new InventryDBEntities()) { int recordsTotal = 0; var courseList = ctx.Database.SqlQuery <GetAllProducts_Result>("exec GetAllProducts").ToList <GetAllProducts_Result>(); JavaScriptSerializer js = new JavaScriptSerializer(); recordsTotal = courseList.Count(); return(Json(new { draw = courseList, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = courseList })); } } catch (Exception e) { return(Json(false, JsonRequestBehavior.DenyGet)); } }
public ActionResult Add(Tbl_products Product, HttpPostedFileBase filesrefdoc) { //update student in DB using EntityFramework in real-life application try { using (InventryDBEntities db = new InventryDBEntities()) { //update list by removing old student and adding updated student for demo purpose db.Tbl_products.Add(Product); db.SaveChanges(); return(RedirectToAction("index")); } } catch (Exception e) { return(Json(true, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(Tbl_products std, HttpPostedFileBase filesrefdoc) { //update student in DB using EntityFramework in real-life application try { using (InventryDBEntities db = new InventryDBEntities()) { ////update list by removing old student and adding updated student for demo purpose var student = db.Tbl_products.Where(s => s.product_id == std.product_id).FirstOrDefault(); db.Tbl_products.Remove(student); db.Tbl_products.Add(std); db.SaveChanges(); return(RedirectToAction("home/index")); } } catch (Exception e) { return(Json(true, JsonRequestBehavior.AllowGet)); } }