Exemple #1
0
        //them
        protected void submit_create_Click(object sender, EventArgs e)
        {
            //kiem tra trong
            if (txtTenTinTuc.Text == "" || txtMoTaNgan.Text == "" || txtChiTiet.Text == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "vanh", "blank()", true);
                return;
            }
            //them
            DTO.TinTuc tint = new DTO.TinTuc();
            tint.TenTinTuc  = txtTenTinTuc.Text;
            tint.MoTa       = txtMoTaNgan.Text;
            tint.ChiTiet    = txtChiTiet.Text;
            tint.NguoiDang  = txtNguoiDang.Text;
            tint.LuotXem    = Int32.Parse(txtLuotXem.Text);
            tint.Status     = checkStatus_create.Checked;
            tint.Created_at = Convert.ToString(DateTime.Now);
            string path = Server.MapPath("../assets/images/TinTucs/");

            FileUploadImage.SaveAs(path + FileUploadImage.FileName);
            tint.Anh = FileUploadImage.FileName;
            tint.DanhMucTinTuc_Id = Int32.Parse(ddrDanhMuc.SelectedValue);
            obj.create(tint);
            //load list
            Response.Redirect(Request.Url.ToString());
        }
Exemple #2
0
        public void create(DTO.TinTuc c)
        {
            //
            string sql = "insert tbl_TinTuc values(N'" + c.TenTinTuc + "' , '" + "~/assets/images/TinTucs/" + c.Anh + "', '" + c.DanhMucTinTuc_Id + "', N'" + c.MoTa + "', N'" + c.ChiTiet +
                         "','" + c.NguoiDang + "','" + c.LuotXem + "', '" + c.Status + "', '" + c.Created_at + "')";

            obj.ExecuteNonQuery(sql);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            load();
            string id = Request.QueryString["Id"];

            DTO.TinTuc tint = new DTO.TinTuc();
            DataTable  tb   = new DataTable();

            tb = obj.searchByID(id);
            string luotxem = "";

            if (tb.Rows.Count > 0)
            {
                luotxem = tb.Rows[0]["LuotXem"].ToString();
            }
            tint.LuotXem = Int32.Parse(luotxem) + 1;
            obj.updateLuotXem(tint.LuotXem, id);
        }
Exemple #4
0
        protected void btnSua_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["Id"]);

            DTO.TinTuc tint = new DTO.TinTuc();
            tint.TenTinTuc = txtTen.Text;
            //tint.Anh = FileUploadAnhSua.FileName;
            //string path = Server.MapPath("../assets/images/TinTucs/");
            //FileUploadAnhSua.SaveAs(path + FileUploadAnhSua.FileName);
            tint.Anh = FileUploadAnhSua.FileName;

            if (FileUploadAnhSua.HasFile)
            {
                string path = Server.MapPath("../assets/images/TinTucs/");
                FileUploadAnhSua.SaveAs(path + FileUploadAnhSua.FileName);
                tint.Anh = FileUploadAnhSua.FileName;

                string fileName = "~/assets/images/TinTucs/" + FileUploadAnhSua.FileName;
                imgSua.ImageUrl = fileName;
            }
            else
            {
                tint.Anh = txtlink.Value;
            }



            tint.MoTa             = txtMoTa.Text;
            tint.ChiTiet          = CKEditorControl1.Text;
            tint.NguoiDang        = txtNguoiDang.Text;
            tint.LuotXem          = Int32.Parse(txtLuotXem.Text) + 1;
            tint.Status           = CheckBox1.Checked;
            tint.DanhMucTinTuc_Id = Int32.Parse(DropDownList1.SelectedValue);
            tint.Created_at       = Convert.ToString(DateTime.Now);
            obj.update(tint, id);
            Response.Redirect("TinTuc.aspx");
        }
Exemple #5
0
        public void updateLuotXem(DTO.TinTuc c, int id)
        {
            string sql = "update tbl_TinTuc set LuotXem = N'" + c.LuotXem + "' where id = '" + id + "'";

            obj.ExecuteNonQuery(sql);
        }
Exemple #6
0
        public void update(DTO.TinTuc c, int id)
        {
            string sql = "update tbl_TinTuc set TenTinTuc = N'" + c.TenTinTuc + "' , Anh = '" + "~/assets/images/TinTucs/" + c.Anh + "',DanhMucTinTuc_Id= '" + c.DanhMucTinTuc_Id + "' , MoTa = N'" + c.MoTa + "', ChiTiet = N'" + c.ChiTiet + "', NguoiDang = N'" + c.NguoiDang + "', LuotXem = N'" + c.LuotXem + "', status = '" + c.Status + "',Created_at= '" + c.Created_at + "' where id = '" + id + "'";

            obj.ExecuteNonQuery(sql);
        }