예제 #1
0
        protected void btnADD_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["TenTK"];

            if (cookie != null)
            {
                GioHangDTO gh = new GioHangDTO();
                gh.TenTaiKhoan = cookie.Value;
                gh.MaSP        = lblMaSP.Text;
                gh.SizeGiay    = DropDownList_size.SelectedItem.Text;
                gh.SoLuong     = Convert.ToInt32(txtSoluong.Text);


                if (gh.SoLuong > Convert.ToInt32(lblSLTK.Text))
                {
                    Response.Write("<script>alert('Thêm thất bại')</script>");
                }

                else if (GioHangBUS.ThemGH(gh))
                {
                    Response.Redirect("GioHang.aspx");
                }
                else
                {
                    Response.Write("<script>alert('Thêm thất bại')</script>");
                }
            }
            else
            {
                Response.Redirect("DangNhap.aspx");
            }
        }
        protected void rptSanPham_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "ThemGH")
            {
                HttpCookie cookie = Request.Cookies["TenTK"];
                if (cookie != null)
                {
                    GioHangDTO gh = new GioHangDTO();
                    gh.TenTaiKhoan = cookie.Value;
                    gh.MaSP        = e.CommandArgument.ToString();
                    gh.SoLuong     = 1;

                    if (GioHangBUS.ThemGH(gh))
                    {
                        Response.Redirect("GioHang.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('Thêm thất bại')</script>");
                    }
                }
                else
                {
                    Response.Redirect("DangNhap.aspx");
                }
            }
        }