Пример #1
0
        public ActionResult Modify(string id)
        {
            int Id = Convert.ToInt32(id);

            Models.EL_MasterDataDetails modify = (from s in db.EL_MasterDataDetails where s.ID == Id select s).FirstOrDefault();
            DbEntityEntry entry = db.Entry <Models.EL_MasterDataDetails>(modify);

            //对每个字段进行修改
            db.Set <MvcDemo3.Models.EL_MasterDataDetails>().Attach(modify);
            entry.State = System.Data.EntityState.Modified;
            db.SaveChanges();
            return(View("~/Views/Master/Modify.cshtml", modify));
        }
Пример #2
0
        // GET:删除

        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }

            Models.EL_MasterDataDetails movie = db.EL_MasterDataDetails.Find(id);
            if (movie == null)
            {
                return(HttpNotFound());
            }
            return(View(movie));
        }
Пример #3
0
 public ActionResult Modify(Models.EL_MasterDataDetails modify)
 {
     if (ModelState.IsValid)
     {
         //上下文
         DbEntityEntry entry = db.Entry <Models.EL_MasterDataDetails>(modify);
         //对每个字段进行修改
         db.Set <MvcDemo3.Models.EL_MasterDataDetails>().Attach(modify);
         entry.State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View("~/Views/Master/Modify.cshtml", modify));
 }
Пример #4
0
 public ActionResult Delete(int id)
 {
     try
     {
         Models.EL_MasterDataDetails ID = new Models.EL_MasterDataDetails {
             ID = id
         };
         DbEntityEntry <Models.EL_MasterDataDetails> entry = db.Entry <Models.EL_MasterDataDetails>(ID);
         entry.State = System.Data.EntityState.Deleted;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }