예제 #1
0
 public ActionResult InputChargeCode(PM_budgettable model, int?id)
 {
     if (ModelState.IsValid)
     {
         if (id > 0)
         {
             var cm = db.PM_budgettable.Where(x => x.Chargecode == id).FirstOrDefault();
             cm.Chargecode      = Convert.ToInt32(id);
             cm.Chargecodename  = model.Chargecodename;
             db.Entry(cm).State = EntityState.Modified;
             db.SaveChanges();
             ModelState.Clear();
             TempData["msg"] = "Update Succussfully";
             return(RedirectToAction("ChargeCodeDetails"));
         }
         else
         {
             db.PM_budgettable.Add(model);
             db.SaveChanges();
             ModelState.Clear();
             TempData["msg"] = " Created Successfully";
             return(RedirectToAction("ChargeCodeDetails"));
         }
     }
     return(View());
 }
예제 #2
0
        public ActionResult InputChargeCode(int?id, string E)
        {
            var Originator = (from x in db.Users.Where(x => x.UserType == "Originator") select new SelectListItem {
                Value = x.Id.ToString(), Text = x.FirstName
            }).ToList();

            ViewBag.Originator = Originator;
            if (id > 0 && E == "D")
            {
                PM_budgettable model = db.PM_budgettable.Find(id);
                db.Entry(model).State = EntityState.Deleted;
                db.SaveChanges();
                TempData["msg"] = "Deleted Sucessfully!";
                return(RedirectToAction("ChargeCodeDetails"));
            }

            else if (id > 0)
            {
                PM_budgettable model = db.PM_budgettable.Find(id);
                return(View(model));
            }
            return(View());
        }