Beispiel #1
0
 public ActionResult Them(TinTuc tt)
 {
     SetViewBag1();
     SetViewBag();
     if (ModelState.IsValid)
     {
         var dao = new TinTucDAO();
         tt.LuotXem = 0;
         tt.NgayTao = DateTime.Now;
         tt.NgaySua = null;
         long id = dao.Them(tt);
         if (id > 0)
         {
             logger.Info("Thêm mới tin tức " + tt.Id + " thành công!");
             SetAlert("Thêm mới tin thành công!", "success");
             return(RedirectToAction("Them"));
         }
         else
         {
             logger.Info("Thêm mới tin tức không thành công!");
             SetAlert("Thêm mới không thành công!", "error");
         }
     }
     return(View());
 }
Beispiel #2
0
 public ActionResult Sua(TinTuc tt)
 {
     SetViewBag1();
     SetViewBag();
     if (ModelState.IsValid)
     {
         var dao    = new TinTucDAO();
         var result = dao.Sua(tt);
         if (result)
         {
             logger.Info("Cập nhật tin tức " + tt.Id + " thành công!");
             SetAlert("Sửa tin tức thành công!", "success");
             if (Session["returnUrl"] == null)
             {
                 return(RedirectToAction("Them"));
             }
             else
             {
                 return(Redirect(Session["returnUrl"].ToString()));
             }
         }
         else
         {
             logger.Info("Cập nhật tin tức không thành công!");
             SetAlert("Sửa không thành công!", "error");
             ModelState.AddModelError("", "Sửa không thành công!");
         }
     }
     return(View());
 }
Beispiel #3
0
        public ActionResult Delete(int id)
        {
            var dao = new TinTucDAO();

            dao.Delete(id);
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public ActionResult Edit(int id)
        {
            var dao = new TinTucDAO().ViewDetail(id);


            return(View(dao));
        }
Beispiel #5
0
        //
        // GET: /Admin/TinTuc/

        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var dao   = new TinTucDAO();
            var model = dao.ListAllPaging(page, pageSize);

            return(View(model));
        }
Beispiel #6
0
        // GET: Admin/TinTuc/TinChoDuyet
        public ActionResult TinChoDuyet(string tukhoa, int page = 1, int pageSize = 20)
        {
            var dao   = new TinTucDAO();
            var model = dao.TinChoDuyet(tukhoa, page, pageSize);

            ViewBag.TuKhoa = tukhoa;
            return(View(model));
        }
Beispiel #7
0
        public int changeAn(int id)
        {
            var user = ((UserLogin)Session[CommonStants.USER_SESSION]).userName;
            var dao  = new TinTucDAO();
            var kq   = dao.ChangeStatus(id, user, true);

            return(kq);
        }
Beispiel #8
0
        public JsonResult ThayDoiTrangThai(long id)
        {
            var result = new TinTucDAO().ThayDoiTrangThai(id);

            return(Json(new
            {
                trangthai = result
            }));
        }
Beispiel #9
0
        public ActionResult DetailNews(int id)
        {
            var quangcaoDAO = new QuangCaoDAO();

            ViewBag.QuangCao = quangcaoDAO.DanhSachQuangCao();
            var tour = new TinTucDAO().ViewDetail(id);

            return(View(tour));
        }
Beispiel #10
0
        public int changeAnHien(int id)
        {
            var user = ((UserLogin)Session[CommonStants.USER_SESSION]).userName;
            var dao  = new TinTucDAO();
            var type = dao.GetById(id);

            var kq = dao.ChangeStatus(id, user, !type.IS_DELETE);

            return(kq);
        }
Beispiel #11
0
        //
        // GET: /TinTuc/

        public ActionResult Index(int page = 1, int pageSize = 6)
        {
            var quangcaoDAO = new QuangCaoDAO();

            ViewBag.QuangCao = quangcaoDAO.DanhSachQuangCao();
            var dao   = new TinTucDAO();
            var model = dao.ListAll(page, pageSize);

            ViewBag.News = dao.ListAll(page, pageSize);
            return(View(model));
        }
Beispiel #12
0
        public JsonResult Delete(int id)
        {
            var    dao  = new TinTucDAO();
            var    line = dao.GetByID(id);
            string link = Server.MapPath("/Data/Content/" + line.TINTUC_ID + ".cshtml");

            dao.DeleteFile(link);
            bool value = dao.Delete(id);

            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
0
        public ActionResult Sua(int id)
        {
            SetViewBag1();
            SetViewBag();
            if (Request["returnUrl"] != null)
            {
                Session["returnUrl"] = Request["returnUrl"];
            }
            var tintuc = new TinTucDAO().ViewDetailByID(id);

            return(View(tintuc));
        }
Beispiel #14
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            var tourDAO   = new TourDAO();
            var tintucDAO = new TinTucDAO();

            ViewBag.NewTour    = tourDAO.ListNewTour(4);
            ViewBag.News       = tintucDAO.ListNews(3);
            ViewBag.TourGanDay = tourDAO.GetTourGanDay(5);
            var quangcaoDAO = new QuangCaoDAO();

            ViewBag.QuangCao = quangcaoDAO.DanhSachQuangCao();
            return(View());
        }
Beispiel #15
0
        public ActionResult Create(TinTucModel sp)
        {
            var dao = new TinTucDAO();
            var tk  = dao.GetByTitle(sp.TIEUDE_TINTUC);

            if (tk != null)
            {
                SetAlert("Tin tức đã  tồn tại", "fail");
                return(RedirectToAction("Index", "TinTuc"));
            }

            //string txtContent = ViewBag.GhiChu;

            var txtContent = Request.Unvalidated.Form.Get("txtContent");

            // encode the data
            sp.CREATEBY   = ((UserLogin)Session[CommonStants.USER_SESSION]).userName;
            sp.CREATEDATE = DateTime.Now;
            sp.IDTAIKHOAN = ((UserLogin)Session[CommonStants.USER_SESSION]).userID;

            decimal id = dao.Insert(sp);

            if (id > 0)
            {
                //var LastId = dao.getIDLastChild();
                //string exePath = System.AppContext.BaseDirectory + "\\Data\\Content\\" + namenew + ".html";
                string     exePath = Server.MapPath("\\Data\\Content\\tt" + id + ".cshtml");
                FileStream fs      = new FileStream(exePath, FileMode.Create);
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    foreach (var s in txtContent)
                    {
                        sw.Write(s);
                    }
                    sw.Flush();
                }
                fs.Close();
                string link = "/Data/Content/tt" + id + ".html";
                dao.updatenoidung(link, id);
                SetAlert("Thêm Thành công", "success");
                return(RedirectToAction("Index", "TinTuc"));
            }
            else
            {
                ModelState.AddModelError("", "Thêm không thành công!");
            }


            return(View("Index"));
        }
Beispiel #16
0
        // GET: Admin/TinTuc
        public ActionResult Index()
        {
            TinTucDAO dao = new TinTucDAO();


            var x    = ((UserLogin)Session[CommonStants.USER_SESSION]).userID;
            var user = new UserDAO().ViewDetail(x);

            //  ViewBag.typeLoai = getTypeUserView(user);
            getTypeNews();
            var result = dao.listTintuc();

            //Add a Dummy Row.

            return(View(result));
        }
Beispiel #17
0
        public string changeImage(long id, string picture)
        {
            if (id == null)
            {
                return("Mã không tồn tại");
            }
            var t      = new TinTucDAO();
            var result = t.GetById(id);

            if (result == null)
            {
                return("Mã không tồn tại");
            }
            t.changeImage(id, picture);
            return("");
        }
Beispiel #18
0
 public ActionResult Create(tblTINTUC tintuc)
 {
     if (ModelState.IsValid)
     {
         var  dao = new TinTucDAO();
         long id  = dao.Insert(tintuc);
         if (id > 0)
         {
             return(RedirectToAction("Index", "TinTuc"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm tin tức không thành công");
         }
     }
     return(View("Create"));
 }
Beispiel #19
0
 public ActionResult Edit(tblTINTUC tintuc)
 {
     if (ModelState.IsValid)
     {
         var dao    = new TinTucDAO();
         var result = dao.Update(tintuc);
         if (result)
         {
             return(RedirectToAction("Index", "TinTuc"));
         }
         else
         {
             ModelState.AddModelError("", "Sửa tin không thành công");
         }
     }
     return(View("Edit"));
 }
Beispiel #20
0
        public ActionResult Edit(TINTUC tin)
        {
            if (ModelState.IsValid)
            {
                var dao = new TinTucDAO();

                tin.MODIFILEDBY = ((UserLogin)Session[CommonStants.USER_SESSION]).userName;
                var id = dao.Update(tin);
                if (id)
                {
                    SetAlert("Sửa thành công", "success");
                    return(RedirectToAction("Index", "tin"));
                }
                else
                {
                    SetAlert("Sửa không thành công", "danger");
                    ModelState.AddModelError("", "Cập nhật không thành Công!");
                }
            }
            return(View("Index"));
        }
Beispiel #21
0
        public ActionResult Delete(int id)
        {
            var dao    = new TinTucDAO();
            var result = dao.Delete(id);

            switch (result)
            {
            case true:
            {
                SetAlert("Xóa tin tức " + id + " thành công!", "success");
                logger.Info("Xóa tin tức " + id + " thành công!");
                return(RedirectToAction("Index"));
            }

            case false:
            {
                SetAlert("Xóa tin tức " + id + " không thành công!", "error");
                logger.Error("Xóa  tin tức " + id + " không thành công!");
                return(RedirectToAction("Index"));
            }
            }
            return(View("AllTin"));
        }
Beispiel #22
0
        public ActionResult Edit(int id)
        {
            var tintuc = new TinTucDAO().ViewDetail(id);

            return(View(tintuc));
        }
Beispiel #23
0
 public static DataTable gettintucphapluat()
 {
     return(TinTucDAO.gettintucphapluat());
 }
Beispiel #24
0
 public static DataTable gettintucdoisong()
 {
     return(TinTucDAO.gettintucdoisong());
 }
Beispiel #25
0
 public static DataTable gettintucslide3()
 {
     return(TinTucDAO.gettintucslide3());
 }
Beispiel #26
0
 public static DataTable gettintuc(int matin)
 {
     return(TinTucDAO.gettintuc(matin));
 }
Beispiel #27
0
 public static DataTable gettintucphobien()
 {
     return(TinTucDAO.gettintucphobien());
 }