コード例 #1
0
        public ActionResult GridViewUpdatePartial(table_produk_detail item)
        {
            var model = db.table_produk_detail;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.produk_detail_id == item.produk_detail_id);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewBag.GeneralError = e.Message;
                }
            }
            else
            {
                ViewBag.GeneralError = "Please, correct all errors.";
            }
            return(GridViewPartial());
        }
コード例 #2
0
        public ActionResult GridViewAddNewPartial(table_produk_detail item)
        {
            var model = db.table_produk_detail;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewBag.GeneralError = e.Message;
                }
            }
            else
            {
                ViewBag.GeneralError = "Please, correct all errors.";
            }
            return(GridViewPartial());
        }