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


            }
            catch
            {
                return View();
            }
        }
示例#3
0
 public ActionResult Delete(int id, PYMT_TBL paymentModel, FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             paymentModel = db.PYMT_TBL.FirstOrDefault(p => p.Pymt_id == id);
             var entry = db.Entry<PYMT_TBL>(paymentModel);
             entry.State = EntityState.Deleted;
             db.PYMT_TBL.ToList().RemoveAll(p => p.Pymt_id == paymentModel.Pymt_id);
             db.SaveChanges();
             return RedirectToAction("Index", db.PYMT_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }