コード例 #1
0
 //==========================================
 public bool Update(Nhom_DA_TT entity)
 {
     try
     {
         var nhom = db.Nhom_DA_TT.Find(entity.MaNhom);
         nhom.MaGV     = entity.MaGV;
         nhom.MaSV     = entity.MaSV;
         nhom.MaLoaiDA = entity.MaLoaiDA;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #2
0
 public ActionResult Edit(Nhom_DA_TT model)
 {
     if (ModelState.IsValid)
     {
         var dao = new PhanNhomDao();
         model.NgayPhanNhom = DateTime.Now;
         var result = dao.Update(model);
         if (result)
         {
             return(RedirectToAction("Index", "PhanNhom"));
         }
         else
         {
             SetAlert("Cập nhật thất bại", "error");
             return(RedirectToAction("Edit", "PhanNhom"));
         }
     }
     SetViewBag(model.MaGV);
     SetViewBag1(model.MaLoaiDA);
     return(View());
 }
コード例 #3
0
 public ActionResult ThemMoi(Nhom_DA_TT nhom)
 {
     if (ModelState.IsValid)
     {
         var dao = new PhanNhomDao();
         nhom.NgayPhanNhom = DateTime.Now;
         int id = dao.Insert(nhom);
         if (id > 0)
         {
             SetAlert("Thêm nhóm thành công", "success");
             return(RedirectToAction("Index", "PhanNhom"));
         }
         else
         {
             SetAlert("Thêm thất bại", "error");
         }
     }
     SetViewBag();
     SetViewBag1();
     return(View("Index"));
 }
コード例 #4
0
        //==============================================

        public int Insert(Nhom_DA_TT entity)
        {
            db.Nhom_DA_TT.Add(entity);
            db.SaveChanges();
            return(entity.MaNhom);
        }