コード例 #1
0
 public ActionResult Create(FormCollection collection,PRDCT_TYPE prdctTypeModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             db.PRDCT_TYPE.Add(prdctTypeModel);
             db.SaveChanges();
             return RedirectToAction("Index", db.PRDCT_TYPE.ToList());
         }
     }
     catch
     {
         return View();
     }
 }
コード例 #2
0
        public ActionResult Edit(int id, FormCollection collection,PRDCT_TYPE prdctTypeModel)
        {
            try
            {
                prdctTypeModel.Product_type_id = id;
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    var entry = db.Entry<PRDCT_TYPE>(prdctTypeModel);
                    if (entry.State.Equals(EntityState.Detached))
                    {
                        db.PRDCT_TYPE.Attach(prdctTypeModel);
                    }
                    entry.State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index", db.PRDCT_TYPE.ToList());
                }


            }
            catch
            {
                return View();
            }
        }
コード例 #3
0
 public ActionResult Delete(int id, FormCollection collection,PRDCT_TYPE prdctTypeModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             prdctTypeModel = db.PRDCT_TYPE.FirstOrDefault(p => p.Product_type_id == id);
             var entry = db.Entry<PRDCT_TYPE>(prdctTypeModel);
             entry.State = EntityState.Deleted;
             db.PRDCT_TYPE.ToList().RemoveAll(p => p.Product_type_id == prdctTypeModel.Product_type_id);
             db.SaveChanges();
             return RedirectToAction("Index", db.PLAN_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }