コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 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));
     }
 }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
 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));
     }
 }