コード例 #1
0
        public bool Update(LoaiND entity)
        {
            var LoaiND = db.LoaiNDs.Find(entity.MaLoaiND);

            LoaiND.TenLoai    = entity.TenLoai;
            LoaiND.SoDinhDanh = entity.SoDinhDanh;

            db.SaveChanges();
            return(true);
        }
コード例 #2
0
 public bool Insert(LoaiND entity)
 {
     if (!string.IsNullOrEmpty(entity.MaLoaiND))
     {
         db.LoaiNDs.Add(entity);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        public ActionResult Create(LoaiND sp)
        {
            if (ModelState.IsValid)
            {
                var dao = new LoaiNDDAO();

                bool id = dao.Insert(sp);
                if (id)
                {
                    return(RedirectToAction("Index", "LoaiND"));
                }
                else
                {
                    ModelState.AddModelError("", "Tạo loại nd thất bại!");
                }
            }
            return(View("Index"));
        }
コード例 #4
0
 public ActionResult Edit(LoaiND sp)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var dao    = new LoaiNDDAO();
             var result = dao.Update(sp);
             if (result)
             {
                 return(RedirectToAction("Index", "LoaiND"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật thất bại!");
             }
         }
         return(View("Index"));
     }
     catch
     {
         return(View());
     }
 }