Beispiel #1
0
        protected void dlPriceSearchedProducts_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "ProductView")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                Session["ProductViewId"] = id;

                Response.Redirect("~/Customer/ProductQuickView.aspx");
            }
            else if (e.CommandName == "CartView")
            {
                int  colorid      = Convert.ToInt32(e.CommandArgument);
                var  cololrSearch = _color.Search(colorid);
                var  data         = product.Search(cololrSearch.ProductId);
                int  UserId       = Convert.ToInt32(Session["UserId"]);
                bool item         = cart.ProductSearchByColor(data.ProductId, UserId, cololrSearch.Colourname);

                if (item == true)
                {
                    cart.Insert(new Cart
                    {
                        ProductId  = data.ProductId,
                        Quantity   = 1,
                        Date       = DateTime.Today,
                        UserId     = UserId,
                        ColorId    = cololrSearch.Colourname,
                        Size       = data.Size,
                        NewColorId = colorid
                    });

                    Label lblcarts = Page.Master.FindControl("lblcart") as Label;
                    //  Label lblwishlist = Page.Master.FindControl("lblwishlist") as Label;
                    lblcarts.Text = cart.getTotalCountOfCart(UserId).ToString();
                    //    lblwishlist.Text = wishlist.getTotalCountOfCart((UserId)).ToString();
                }
            }
            else if (e.CommandName == "WishlistView")
            {
                int  colorid      = Convert.ToInt32(e.CommandArgument);
                var  cololrSearch = _color.Search(colorid);
                var  data         = product.Search(cololrSearch.ProductId);
                int  UserId       = Convert.ToInt32(Session["UserId"]);
                bool item         = wishlist.ProductSearch(cololrSearch.ProductId, UserId, colorid);

                if (item == true)
                {
                    wishlist.Insert(new Wishlist
                    {
                        ProductId = data.ProductId,
                        UserId    = UserId, ColorId = colorid
                    });
                    // Label lblcarts = Page.Master.FindControl("lblcart") as Label;
                    Label lblwishlist = Page.Master.FindControl("lblwishlist") as Label;
                    // lblcarts.Text = cart.getTotalCountOfCart(UserId).ToString();
                    lblwishlist.Text = wishlist.getTotalCountOfCart((UserId)).ToString();
                }
            }
        }
Beispiel #2
0
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            int  colorid      = Convert.ToInt32(Session["ProductViewId"]);
            var  colorDetails = _colour.Search(colorid);
            var  data         = product.Search(colorDetails.ProductId);
            int  UserId       = Convert.ToInt32(Session["UserId"]);
            bool item         = wishlist.ProductSearch(colorDetails.ProductId, UserId, colorDetails.ColourId);

            if (item == true)
            {
                wishlist.Insert(new Wishlist
                {
                    ProductId = data.ProductId,
                    UserId    = UserId,
                    ColorId   = colorid
                });

                //  Label lblcarts = Page.Master.FindControl("lblcart") as Label;
                Label lblwishlist = Page.Master.FindControl("lblwishlist") as Label;
                //  lblcarts.Text = cart.getTotalCountOfCart(UserId).ToString();
                lblwishlist.Text = wishlist.getTotalCountOfCart((UserId)).ToString();
            }
        }
Beispiel #3
0
        protected void datalistCartView_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Remove")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                cart.Delete(id);
                datalistCartView.DataBind();
            }
            if (e.CommandName == "WishlistMove")
            {
                int  colorid     = Convert.ToInt32(e.CommandArgument);
                var  colodetails = _color.Search(colorid);
                var  cartDetails = cart.SearchByColorid(colorid);
                var  data        = product.Search(cartDetails.ProductId);
                int  UserId      = Convert.ToInt32(Session["UserId"]);
                bool item        = wishlist.ProductSearch(cartDetails.ProductId, UserId, cartDetails.NewColorId);

                if (item == true)
                {
                    wishlist.Insert(new Wishlist
                    {
                        ProductId = data.ProductId,
                        UserId    = UserId,
                        ColorId   = colorid
                    });

                    cart.Delete(cartDetails.CartId);
                }
                //  Label lblcarts = Page.Master.FindControl("lblcart") as Label;
                Label lblwishlist = Page.Master.FindControl("lblwishlist") as Label;
                //  lblcart.Text = _cart.getTotalCountOfCart(Convert.ToInt32(Session["UserId"])).ToString();
                lblwishlist.Text = wishlist.getTotalCountOfCart((UserId)).ToString();


                datalistCartView.DataBind();
            }
        }