예제 #1
0
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            int productId = Convert.ToInt32(e.CommandArgument.ToString());

            switch (e.CommandName)
            {
            case "details":
            {
                Response.Redirect("~/ProductDetails.aspx?ProductId=" + productId.ToString());
            }
            break;

            case "addToCart":
            {
                db = new Web.Library.E_TicaretDataContext();
                Web.Library.Product selectedProd = db.Products.FirstOrDefault(p => p.ProductID == Convert.ToInt32(e.CommandArgument));

                Web.Library.Cart.CartProduct currentItem = new Web.Library.Cart.CartProduct();
                currentItem.selectedProduct = selectedProd;
                currentItem.Quantity++;

                List <Web.Library.Cart.CartProduct> listemiz = Web.Library.Cart.CartTools.AddItem(currentItem, Session["myCart"]);
                //Web.Library.Cart.CartTools.GetAllCartProduct(Session["myCart"]);

                Session["mycart"] = listemiz;
                Response.Redirect(Page.Request.Url.ToString());
            }
            break;
            }
        }
예제 #2
0
        }                                        // ? -> Nullable boş olum durumunda hata vermez

        // ----------------------------------------------------------------------------
        // Sepetten Ürün silme
        // ----------------------------------------------------------------------------
        protected void btnSecilenleriKaldir_Click(object sender, EventArgs e)
        {
            List <Web.Library.Cart.CartProduct> listemiz = (List <Web.Library.Cart.CartProduct>)Session["myCart"];

            if (listemiz != null)
            {
                List <Web.Library.Cart.CartProduct> kaldirilacaklar = new List <Web.Library.Cart.CartProduct>();
                foreach (RepeaterItem rpt in rptMyCart.Items)
                {
                    CheckBox chk = rpt.FindControl("chkCheck") as CheckBox;
                    if (chk.Checked)
                    {
                        HiddenField hf = rpt.FindControl("hfProductID") as HiddenField;

                        if (string.IsNullOrEmpty(hf.Value) == false)
                        {
                            int id = Convert.ToInt32(hf.Value);

                            Web.Library.Cart.CartProduct prod = new Web.Library.Cart.CartProduct();
                            prod = listemiz.FirstOrDefault(x => x.ProductID == id);
                            listemiz.Remove(prod);
                        }
                    }
                }

                Session["myCart"] = listemiz;

                Response.Redirect(Page.Request.Url.ToString());

                sepetiDoldur();
            }
        }
예제 #3
0
        // ----------------------------------------------------------------------------
        // GenelProdDetails Command (command yapısından dolayı datalistleri ayırdım)
        // ----------------------------------------------------------------------------
        protected void GenelProdDetails_Command(object sender, CommandEventArgs e)
        {
            int productId = Convert.ToInt32(hdfProductID.Value);

            switch (e.CommandName)
            {
            case "kategori":
            {
                Response.Redirect("~/Products.aspx?CategoryID=" + e.CommandArgument.ToString());
            }
            break;

            case "AddToCart":
            {
                db = new Web.Library.E_TicaretDataContext();

                Web.Library.Product          selectedProd = db.Products.FirstOrDefault(p => p.ProductID == Convert.ToInt32(hdfProductID.Value));
                Web.Library.Cart.CartProduct currentItem  = new Web.Library.Cart.CartProduct();

                currentItem.selectedProduct = selectedProd;
                currentItem.Quantity++;

                List <Web.Library.Cart.CartProduct> listemiz = Web.Library.Cart.CartTools.AddItem(currentItem, Session["myCart"]);

                Session["mycart"] = listemiz;
                Response.Redirect("~/ProductDetails.aspx?ProductId=" + selectedProd.ProductID.ToString());
            }
            break;

            case "Compare":
            {
                db = new Web.Library.E_TicaretDataContext();

                Web.Library.Product        selectedProd       = db.Products.FirstOrDefault(p => p.ProductID == Convert.ToInt32(hdfProductID.Value));
                List <Web.Library.Product> comparableItemsEnd = Web.Library.Compare.CompareTools.AddCompare(Session["myComparable"], selectedProd);

                selectedProduct         = selectedProd;
                Session["myComparable"] = comparableItemsEnd;

                Response.Redirect(Page.Request.Url.ToString());
            }
            break;
            }
        }
예제 #4
0
        // ----------------------------------------------------------------------------
        // DataList Command
        // ----------------------------------------------------------------------------
        protected void GenelDataList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            int productId = Convert.ToInt32(e.CommandArgument.ToString());

            switch (e.CommandName)
            {
            case "detailsFromProductName":
            {
                Response.Redirect("~/ProductDetails.aspx?ProductId=" + productId.ToString());
            }
            break;

            case "details":
            {
                Response.Redirect("~/ProductDetails.aspx?ProductId=" + productId.ToString());
            }
            break;

            case "addToCart":
            {
                DropDownList drpStokAdedi = e.Item.FindControl("drpQuantity") as DropDownList;

                db = new Web.Library.E_TicaretDataContext();
                Web.Library.Product selectedProd = db.Products.FirstOrDefault(p => p.ProductID == Convert.ToInt32(hdfProductID.Value));

                Web.Library.Cart.CartProduct currentItem = new Web.Library.Cart.CartProduct();
                currentItem.selectedProduct = selectedProd;
                currentItem.Quantity++;


                List <Web.Library.Cart.CartProduct> listemiz = Web.Library.Cart.CartTools.AddItem(currentItem, Session["myCart"]);
                Session["mycart"] = listemiz;

                // Response.Redirect("~/ProductDetails.aspx?ProductId=" + productId.ToString());
                Response.Redirect(Page.Request.Url.ToString());
            }
            break;
            }
        }