Пример #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
        private void leftRightSales()
        {
            db        = new Web.Library.E_TicaretDataContext();
            saleMaxID = db.Products.Max(p => p.ProductID);

            i                       = (i + rnd.Next(1, saleMaxID.Value)) % saleMaxID.Value;
            saleleft                = db.Products.FirstOrDefault(p => p.ProductID > i);
            hfSaleLeft.Value        = saleleft.ProductID.ToString();
            ImgbtnSaleLeft.ImageUrl = saleleft.SmallPhotoPath;
            Session["saleLeftProd"] = saleleft;

            saleNew                = db.Products.FirstOrDefault(p => p.ProductID == saleMaxID);
            hfSaleNew.Value        = saleMaxID.ToString();
            ImgbtnSaleNew.ImageUrl = saleNew.SmallPhotoPath;
            Session["saleNewProd"] = saleNew;
        }
Пример #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;
            }
        }