protected void grv_sp_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Chonsp") { string tensp = e.CommandArgument.ToString(); DTO_Sanpham sp = BUS_Sanpham.LayThongTinsp(tensp); if (sp != null) { txb_masp.Text = sp.Masp; txb_tensp.Text = sp.Tensp; txb_giatien.Text = sp.Giatien; txb_sltonkho.Text = sp.Soluongtonkho; txb_thongtin.Text = sp.Thongtin; txb_maloaisp.Text = sp.Maloaisp; } } if (e.CommandName == "Xoasp") { string tensp = e.CommandArgument.ToString(); if (BUS_Sanpham.XoaSP(tensp)) { //XoaForm(); LoadDSSP(); } else { Response.Write("<script>alert('Xóa tài khoản thất bại');</script>"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { rpt_slider.DataSource = BUS_Sanpham.LayDSsp(); rpt_slider.DataBind(); HttpCookie cookie = Request.Cookies["tenTK"]; if (cookie != null) { string tenTK = cookie.Value; if (!Page.IsPostBack) { DataTable dtb_giohang = BUS_giohang.loadgiohang(tenTK); TaiKhoanDTO tk = TaiKhoanBUS.LayThongTinTaiKhoan(tenTK); grvGioHang.DataSource = dtb_giohang; grvGioHang.DataBind(); lblTongTien.Text = BUS_giohang.tinhtien(tenTK) + " USD"; //lb_tongtien.Text = BUS_giohang.tinhtien(tenTK) + " USD"; //txb_tenTK.Text = tk.TenTaiKhoan; //txb_sdt.Text = tk.SDT; //txb_diachi.Text = tk.DiaChi; //txb_ngaymua.Text = DateTime.Now.ToString(); } } else { Response.Redirect("../DangNhap.aspx"); } } }
protected void btn_themsp_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txb_masp.Text) || string.IsNullOrWhiteSpace(txb_tensp.Text) || string.IsNullOrWhiteSpace(txb_thongtin.Text) || string.IsNullOrWhiteSpace(txb_sltonkho.Text) || string.IsNullOrWhiteSpace(txb_giatien.Text) || string.IsNullOrWhiteSpace(txb_maloaisp.Text)) { Response.Write("<script>alert('Phải điền dầy đủ thông tin');</script>"); } else { DTO_Sanpham sp = new DTO_Sanpham(); sp.Masp = txb_masp.Text; sp.Tensp = txb_tensp.Text; sp.Thongtin = txb_thongtin.Text; sp.Giatien = txb_giatien.Text; sp.Soluongtonkho = txb_sltonkho.Text; sp.Maloaisp = txb_maloaisp.Text; if (BUS_Sanpham.Themsp(sp)) { Response.Write("<script>alert('them moi san pham thanh cong');</script>"); } else { Response.Write("<script>alert('them moi that bai');</script>"); } } }
protected void ddl_sanpham_SelectedIndexChanged(object sender, EventArgs e) { string malsp = ddl_sanpham.SelectedValue; dtl_sanpham.DataSource = BUS_Sanpham.LayDSsp(malsp); dtl_sanpham.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { var id = Request.QueryString["id"]; if (!Page.IsPostBack) { BUS_Sanpham.LayThongTinsp(id); } }
protected void Page_Load(object sender, EventArgs e) { var keyword = Request.QueryString["keyword"]; if (!Page.IsPostBack) { DTO_Sanpham sp = new DTO_Sanpham(); dtl_sanpham.DataSource = BUS_Sanpham.timkiemSP(keyword); dtl_sanpham.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { dtl_sanpham.DataSource = BUS_Sanpham.LayDSsp(); dtl_sanpham.DataBind(); ddl_sanpham.DataSource = BUS_Loaisanpham.LayDSLoaiSanPham(); ddl_sanpham.DataTextField = "TenLoaiSP"; ddl_sanpham.DataValueField = "MaLoaiSP"; ddl_sanpham.AutoPostBack = true; ddl_sanpham.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { dtl_sanpham.DataSource = BUS_Sanpham.LayDSsp(); dtl_sanpham.DataBind(); rpt_slider.DataSource = BUS_Sanpham.LayDSsp(); rpt_slider.DataBind(); //Response.Write("xin chao" + Session["username"]); } //protected void ddlLoaiSanPham_SelectedIndexChanged(object sender, EventArgs e) //{ // string maLoaiSP = ddlLoaiSanPham.SelectedValue; // rptSanPham.DataSource = SanPhamBUS.LayDSSanPham(maLoaiSP); // rptSanPham.DataBind(); ////} }
protected void btnSua_Click(object sender, EventArgs e) { DTO_Sanpham sp = BUS_Sanpham.LayThongTinsp(txt_tensp.Text); sp.Tensp = txt_tensp.Text; sp.Thongtin = txt_thongtinsp.Text; sp.Maloaisp = txt_maloaisp.Text; sp.Giatien = txt_giatien.Text; sp.TrangThai = chkTrangThai.Checked; if (BUS_Sanpham.Suasp(sp)) { XoaForm(); loadsp(); GiaoDienThem(true); } else { Response.Write("<script>alert('Sửa san pham thất bại');</script>"); } }
protected void btnThem_Click(object sender, EventArgs e) { DTO_Sanpham sp = new DTO_Sanpham(); sp.Masp = txt_masp.Text; sp.Tensp = txt_tensp.Text; sp.Thongtin = txt_thongtinsp.Text; sp.Giatien = txt_giatien.Text; sp.Soluongtonkho = txt_slton.Text; sp.Maloaisp = txt_maloaisp.Text; sp.TrangThai = chkTrangThai.Checked; if (BUS_Sanpham.Themsp(sp)) { XoaForm(); loadsp(); GiaoDienThem(true); } else { Response.Write("<script>alert('Thêm sản phẩm thất bại');</script>"); } }
protected void grv_sp_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Chonsp") { string tensp = e.CommandArgument.ToString(); DTO_Sanpham sp = BUS_Sanpham.LayThongTinsp(tensp); if (sp != null) { txt_masp.Text = sp.Masp; txt_tensp.Text = sp.Tensp; txt_giatien.Text = sp.Giatien; txt_slton.Text = sp.Soluongtonkho; txt_thongtinsp.Text = sp.Thongtin; txt_maloaisp.Text = sp.Maloaisp; img_anhminhhoa.Text = sp.Anhminhhoa; chkTrangThai.Checked = sp.TrangThai; GiaoDienThem(false); } } if (e.CommandName == "Xoasp") { string tensp = e.CommandArgument.ToString(); if (BUS_Sanpham.XoaSP(tensp)) { XoaForm(); loadsp(); } else { Response.Write("<script>alert('Xóa tài sản phẩm thất bại');</script>"); } } }
protected void loadsp() { grv_sp.DataSource = BUS_Sanpham.LayDSsp(); grv_sp.DataBind(); }