コード例 #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));
        }