Esempio n. 1
0
 protected void rptSanPham_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "ThemGH")
     {
         HttpCookie cookie = Request.Cookies["TenTK"];
         if (cookie != null)
         {
             DTO_GioHang gioHang = new DTO_GioHang();
             gioHang.TenTaiKhoan = cookie.Value;
             gioHang.MaSP        = e.CommandArgument.ToString();
             gioHang.SoLuong     = 1;
             if (BUS_GioHang.ThemGioHang(gioHang))
             {
                 Response.Write("<script>alert('Thêm sản phẩm thành công')</script>");
             }
             else
             {
                 Response.Write("<script>alert('Thêm sản phẩm thành công')</script>");
             }
         }
         else
         {
             Response.Redirect("Login.aspx");
         }
     }
 }
Esempio n. 2
0
        protected void rptGiohang_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            DTO_GioHang gh = new DTO_GioHang();

            if (e.CommandName == "CapNhatGH")
            {
                gh.MaSP        = e.CommandArgument.ToString();
                gh.TenTaiKhoan = Request.Cookies["TenTK"].Value;
                gh.SoLuong     = Convert.ToInt32((e.Item.FindControl("txtSoLuong") as TextBox).Text);
                if (BUS_GioHang.ThemGioHang(gh) == true)
                {
                    Response.Write("<script>alert('Cập nhật thành công')</script>");
                    Response.Redirect("Cart.aspx");
                }
            }
            if (e.CommandName == "XoaGH")
            {
                string maSP = e.CommandArgument.ToString();
                BUS_GioHang.XoaGioHang(maSP);
                Response.Redirect("Cart.aspx");
            }
        }