示例#1
0
 public PartialViewResult LienHe(string title, string category, CMS_Contact obj, FormCollection fc)
 {
     try
     {
         ViewBag.abc  = title;
         ViewBag.CATE = category;
         if (ModelState.IsValid)
         {
             CMS_Contact_DAO objDAO = new CMS_Contact_DAO();
             obj.Title = fc["xTitle"].ToString();
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Gửi thông tin liên hệ thành công", AlertType.Success);
             }
         }
         CMS_Contact n = new CMS_Contact();
         return(PartialView(null));
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(PartialView());
     }
 }
示例#2
0
 public ActionResult Create(FormCollection fc, CMS_Contact obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Contact_DAO objDAO   = new CMS_Contact_DAO();
             int             ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm thông tin liên hệ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Contact"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm thông tin liên hệ 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());
     }
 }
示例#3
0
 public ActionResult Edit(FormCollection fc, CMS_Contact obj, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Contact_DAO objDAO = new CMS_Contact_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật thông tin liên hệ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Contact"));
             }
             else
             {
                 SetAlert("Cập nhật thông tin liên hệ 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());
     }
 }
示例#4
0
 public ActionResult Edit(int id)
 {
     try
     {
         CMS_Contact_DAO objDAO  = new CMS_Contact_DAO();
         var             Partial = objDAO.GetContactByID(id);
         return(View(Partial));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
示例#5
0
 public ActionResult Index(string keyWord, int?page)
 {
     try
     {
         CMS_Contact_DAO objDAO = new CMS_Contact_DAO();
         keyWord = keyWord != null ? keyWord : "";
         var data = objDAO.Search(keyWord);
         ViewBag.SearchString = keyWord;
         int pageSize   = 10;
         int pageNumber = (page ?? 1);
         return(View(data.ToPagedList(pageNumber, pageSize)));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), "error");
         Logs.WriteLog(ex);
         return(View());
     }
 }
示例#6
0
        public JsonResult Delete(int id)
        {
            try
            {
                CMS_Contact_DAO objDAO = new CMS_Contact_DAO();

                if (objDAO.Delete(id))
                {
                    SetAlert("Xóa thông tin liên hệ thành công", AlertType.Success);
                    return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { status = false, message = "Lỗi xóa thông tin liên hệ" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex);
                return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
            }
        }