Ejemplo n.º 1
0
 public ActionResult Create(FormCollection fc, CMS_Schedules obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Schedules_DAO objDAO     = new CMS_Schedules_DAO();
             CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
             int userID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = userID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm lịch họp thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Schedules"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm lịch họp không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Ejemplo n.º 2
0
 public ActionResult Edit(FormCollection fc, CMS_Schedules obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Schedules_DAO objDAO = new CMS_Schedules_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật thông báo nội bộ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Schedules"));
             }
             else
             {
                 SetAlert("Cập nhật thông báo nội bộs không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Ejemplo n.º 3
0
 public int Insert(CMS_Schedules entity)
 {
     try
     {
         entity.CreateDate = System.DateTime.Now;
         MyContext.CMS_Schedules.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Ejemplo n.º 4
0
 public bool Update(CMS_Schedules entity)
 {
     try
     {
         CMS_Schedules obj = MyContext.CMS_Schedules.Find(entity.ID);
         obj.Title            = entity.Title;
         obj.Contents         = entity.Contents;
         obj.StartDate        = entity.StartDate;
         obj.EndDate          = entity.EndDate;
         obj.Place            = entity.Place;
         obj.Participants     = entity.Participants;
         obj.UserPrepare      = entity.UserPrepare;
         obj.Ministry_leaders = entity.Ministry_leaders;
         obj.Leaders          = entity.Leaders;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }