예제 #1
0
 private void ValidateModel(Quanlichitieu model)
 {
     if (model.Total <= 0)
     {
         ModelState.AddModelError("Total", "Số tiền quá ít!");
     }
 }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Quanlichitieu quanlichitieu = db.Quanlichitieux.Find(id);

            db.Quanlichitieux.Remove(quanlichitieu);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "id,Date,Total,Detail")] Quanlichitieu quanlichitieu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quanlichitieu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(quanlichitieu));
 }
예제 #4
0
        public ActionResult Create(Quanlichitieu model)
        {
            ValidateModel(model);
            if (ModelState.IsValid)
            {
                model.Date = DateTime.Today;
                db.Quanlichitieux.Add(model);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
예제 #5
0
        // GET: /quanli/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Quanlichitieu quanlichitieu = db.Quanlichitieux.Find(id);

            if (quanlichitieu == null)
            {
                return(HttpNotFound());
            }
            return(View(quanlichitieu));
        }