protected void btnEdit_Top_Command(object sender, CommandEventArgs e)
        {
            int    i = 0;
            string id;

            foreach (GridViewRow gvrow in grvTintuc.Rows)
            {
                CheckBox chk = (CheckBox)gvrow.FindControl("CkDelete");
                if (chk != null && chk.Checked)
                {
                    id = grvTintuc.Rows[i].Cells[1].Text;
                    List <Entity.TinTuc> lst = new List <Entity.TinTuc>();

                    lst            = TinTucService.TinTuc_GetByTop("", " ID = " + id, "");
                    pnInfo.Visible = true;
                    pnData.Visible = false;

                    insert             = false;
                    fileUpLoad         = lst[0].UrlHinhAnh;
                    txtID.Text         = lst[0].Id;
                    txtIdNhanvien.Text = lst[0].Id_nhanvien;
                    txtngayviet.Text   = lst[0].Ngayviet;
                    txttieude.Text     = lst[0].TieuDe;
                    txtnoidung.Text    = lst[0].Noidung;
                    txttomtat.Text     = lst[0].Tomtat;
                    ckbActive.Checked  = lst[0].Active == "True" ? true : false;
                }
                i++;
            }
        }
Example #2
0
        private void LoadData(int pageSize)
        {
            DataTable dataTable = new DataTable();

            dataTable = ToDataTable(TinTucService.TinTuc_GetByTop("", "", " id DESC"));
            PagedDataSource pageSource = new PagedDataSource();

            pageSource.DataSource  = dataTable.DefaultView;
            pageSource.AllowPaging = true;

            pageSource.PageSize         = pageSize;
            pageSource.CurrentPageIndex = this.CurrentPage;
            if (pageSource.PageCount > 1)
            {
                repeaterPaging.Visible = true;
                ArrayList pages = new ArrayList();
                for (int i = 0; i <= pageSource.PageCount - 1; i++)
                {
                    pages.Add((i + 1).ToString());
                }
                repeaterPaging.DataSource = pages;
                repeaterPaging.DataBind();
            }
            else
            {
                repeaterPaging.Visible = false;
            }

            rptcontent.DataSource = pageSource;
            rptcontent.DataBind();
        }
        protected void lbDelete_Command(object sender, CommandEventArgs e)
        {
            int i = Int32.Parse(e.CommandArgument.ToString());
            List <Entity.TinTuc> lst = new List <Entity.TinTuc>();

            TinTucService.TinTuc_Delete(i.ToString());
            getData();
        }
Example #4
0
 public HomeController(ILogger <HomeController> logger, KinhNghiemDuLichService kinhNghiemDuLichService,
                       LienHeService lienHeService, TinTucService tinTucService, TourService tourService)
 {
     _logger = logger;
     this._kinhNghiemDuLichService = kinhNghiemDuLichService;
     this._lienHeService           = lienHeService;
     this._tinTucService           = tinTucService;
     this._tourService             = tourService;
 }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?so = null;
            int id = Convert.ToInt32(Request["Id"]);
            List <Entity.TinTuc> lst = new List <Entity.TinTuc>();

            TinTucService.TinTucView_Update(id.ToString());
            rptbantin.DataSource = TinTucService.TinTuc_GetByTop("", " id='" + id + "'", "");
            rptbantin.DataBind();
            rptcacbaikhac.DataSource = TinTucService.TinTuc_GetByTop("2", "", " NEWID()");
            rptcacbaikhac.DataBind();
        }
        void getData()
        {
            List <Entity.TinTuc> lst = new List <Entity.TinTuc>();

            lst = TinTucService.TinTuc_GetByTop("", "", "");



            grvTintuc.DataSource = lst;
            grvTintuc.DataBind();
            txtngayviet.Text = DateTime.Now.ToShortDateString();
        }
        protected void lbEdit_Command(object sender, CommandEventArgs e)
        {
            int i = Int32.Parse(e.CommandArgument.ToString());
            List <Entity.TinTuc> lst = new List <Entity.TinTuc>();

            lst            = TinTucService.TinTuc_GetByTop("", " ID = " + i, "");
            pnInfo.Visible = true;
            pnData.Visible = false;

            insert             = false;
            fileUpLoad         = lst[0].UrlHinhAnh;
            txtID.Text         = lst[0].Id;
            txtIdNhanvien.Text = lst[0].Id_nhanvien;
            txtngayviet.Text   = lst[0].Ngayviet;
            txttieude.Text     = lst[0].TieuDe;
            txtnoidung.Text    = lst[0].Noidung;
            txttomtat.Text     = lst[0].Tomtat;
            ckbActive.Checked  = lst[0].Active == "True" ? true : false;
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int    i = 0;
            string id;

            foreach (GridViewRow gvrow in grvTintuc.Rows)
            {
                CheckBox chk = (CheckBox)gvrow.FindControl("CkDelete");
                if (chk != null && chk.Checked)
                {
                    id = grvTintuc.Rows[i].Cells[1].Text;
                    TinTucService.TinTuc_Delete(id);
                }
                i++;
            }



            getData();
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblsonguoiOnline.Text = Application["OnlineUsers"].ToString();
                if (Session["slspgiohang"] != null)
                {
                    lblslgiohang.Text = Session["slspgiohang"].ToString();
                }

                if (Session["display_name"] != null)
                {
                    //lblsonguoidangnhap.Text = Application["LoggedInUsers"].ToString();
                    btndangki.Text   = Session["display_name"].ToString() + " / ";
                    btndangnhap.Text = "Đăng xuất";
                }
                khdbDataContext db = new khdbDataContext();
                rptTinTuc.DataSource = TinTucService.TinTuc_GetByTop("4", "Active='true'", "");
                rptTinTuc.DataBind();
                // rptTinTucMoiNhat.DataSource = TinTucService.TinTuc_GetByTop("", " Active='true' AND ngayviet=(SELECT MAX(ngayviet) from tbl_TinTuc)", "");
                rptTinTucMoiNhat.DataSource = db.tbl_TinTucs.OrderByDescending(x => x.id).Where(x => x.Active == true).Take(1).ToList();
                rptTinTucMoiNhat.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblsonguoiOnline.Text = Application["OnlineUsers"].ToString();
                if (Session["slspgiohang"] != null)
                {
                    lblslgiohang.Text = Session["slspgiohang"].ToString();
                }

                if (Session["TenDangNhap"] != null)
                {
                    //lblsonguoidangnhap.Text = Application["LoggedInUsers"].ToString();

                    btndangki.Text   = Session["TenDangNhap"].ToString();
                    btndangnhap.Text = "Đăng xuất";
                }

                rptTinTuc.DataSource = TinTucService.TinTuc_GetByTop("4", "", "");
                rptTinTuc.DataBind();
                rptTinTucMoiNhat.DataSource = TinTucService.TinTuc_GetByTop("", " ngayviet=(SELECT MAX(ngayviet) from tbl_TinTuc) ", "");
                rptTinTucMoiNhat.DataBind();
            }
        }
        protected void btnSave_Top_Click(object sender, EventArgs e)
        {
            Entity.TinTuc dt = new Entity.TinTuc();
            if (insert == true)
            {
                dt.TieuDe      = txttieude.Text;
                dt.Tomtat      = txttomtat.Text;
                dt.Noidung     = txtnoidung.Text;
                dt.Ngayviet    = txtngayviet.Text;
                dt.Id_nhanvien = txtIdNhanvien.Text;
                if (FileUpload2.HasFile)
                {
                    try
                    {
                        string Duoi_filename = Path.GetExtension(FileUpload2.FileName);
                        string filename      = FileUpload2.FileName.ToString();

                        if (Duoi_filename == ".jpeg" || Duoi_filename == ".jpg" || Duoi_filename == ".png" || Duoi_filename == ".PNG" || Duoi_filename == ".JPG" || Duoi_filename == ".JPEG")
                        {
                            FileUpload2.SaveAs(Server.MapPath("~/images/") + filename);
                            dt.UrlHinhAnh = "images/" + filename;
                        }
                        else
                        {
                            Response.Write("<script>alert('Bạn chỉ được upload jpg,png,jpeg')</script>");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                }


                dt.Active = ckbActive.Checked == true ? "True" : "False";
                TinTucService.TinTuc_Insert(dt);
                Response.Write("<script>alert('Insert thành công!!!')</script>");
                getData();
            }
            else
            {
                dt.Id          = txtID.Text;
                dt.TieuDe      = txttieude.Text;
                dt.Tomtat      = txttomtat.Text;
                dt.Noidung     = txtnoidung.Text;
                dt.Ngayviet    = txtngayviet.Text;
                dt.Id_nhanvien = txtIdNhanvien.Text;
                if (FileUpload2.HasFile)
                {
                    try
                    {
                        string Duoi_filename = Path.GetExtension(FileUpload2.FileName);
                        string filename      = FileUpload2.FileName.ToString();

                        if (Duoi_filename == ".jpeg" || Duoi_filename == ".jpg" || Duoi_filename == ".png" || Duoi_filename == ".PNG" || Duoi_filename == ".JPG" || Duoi_filename == ".JPEG")
                        {
                            FileUpload2.SaveAs(Server.MapPath("~/images/") + filename);
                            dt.UrlHinhAnh = "images/" + filename;
                        }
                        else
                        {
                            Response.Write("<script>alert('Bạn chỉ được upload jpg,png,jpeg')</script>");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    dt.UrlHinhAnh = fileUpLoad;
                }

                dt.Active = ckbActive.Checked == true ? "True" : "False";
                TinTucService.TinTuc_Update(dt);
                Response.Write("<script>alert('Update thành công!!!')</script>");
                getData();
            }
            insert         = true;
            pnData.Visible = true;
            pnInfo.Visible = false;
            ClearText();
        }