コード例 #1
0
 public bool Update(TbDotthi entity)
 {
     try
     {
         var dotthi = db.TbDotthis.SingleOrDefault(x => x.MaDT == entity.MaDT);
         dotthi.MaDT      = entity.MaDT;
         dotthi.TenDT     = entity.TenDT;
         dotthi.TrangThai = entity.TrangThai;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: DtController.cs プロジェクト: sonnn-1091/monitoring
        public ActionResult Create(TbDotthi dt)
        {
            var dao = new DtDao();
            var id  = dao.Insert(dt);

            if (id > 0)
            {
                SetAlert("Thêm đợt thi mới thành công", "success");
                return(RedirectToAction("Index", "Dt"));
            }
            else
            {
                ModelState.AddModelError("", "Thêm mới không thành công");
            }
            return(View("Index"));
        }
コード例 #3
0
ファイル: DtController.cs プロジェクト: sonnn-1091/monitoring
 public ActionResult Edit(TbDotthi dt)
 {
     if (ModelState.IsValid)
     {
         var dao    = new DtDao();
         var result = dao.Update(dt);
         if (result)
         {
             SetAlert("Sửa đợt thi thành công", "success");
             return(RedirectToAction("Index", "Dt"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật không thành công");
         }
     }
     return(View("Index"));
 }
コード例 #4
0
 public int Insert(TbDotthi entity)
 {
     db.TbDotthis.Add(entity);
     db.SaveChanges();
     return(entity.MaDT);
 }