Пример #1
0
    /// <summary>
    /// Returns Quantity on Hand (inventory stock value)
    /// </summary>
    /// <param name="Value"></param>
    /// <returns></returns>
    protected void CheckInventory()
    {
        _product = Product;

        if (_product.ProductID > 0)
        {
            QuantityRangeValidator.MaximumValue = _product.QuantityOnHand.ToString();
            int CurrentQuantity = _product.QuantityOnHand;

            //Retreive shopping cart object from current session
            shoppingCart = ZNodeShoppingCart.CurrentShoppingCart();

            if (shoppingCart != null)
            {
                ZNodeShoppingCartItem Item = new ZNodeShoppingCartItem();
                Item.Product = _product;

                //Get Current Qunatity by Subtracting QunatityOrdered from Quantity On Hand(Inventory)
                CurrentQuantity -= shoppingCart.GetQuantityOrdered(Item);
            }

            if (CurrentQuantity <= 0)
            {
                CurrentQuantity = 0;
            }

            QuantityRangeValidator.MaximumValue = CurrentQuantity.ToString();
        }
        else
        {
            QuantityRangeValidator.MaximumValue = "1";
        }
    }
Пример #2
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // get product sku from querystring
        if (Request.Params["sku"] != null)
        {
            SKU = Request.Params["sku"];
        }

        // get product num # from querystring
        if (Request.QueryString["product_num"] != null)
        {
            _productNum = Request.QueryString["product_num"];
        }

        // get quantity from querystring
        if (Request.Params["quantity"] != null)
        {
            if (!int.TryParse(Request.Params["quantity"],out _quantity))
            {
                _quantity = 1;
            }
        }

        if (SKU.Length == 0 && _productNum.Length == 0)
        {
            Response.Redirect("~/error.aspx");
            return;
        }

        if (!Page.IsPostBack)
        {
            ZNodeSKU productSKU = new ZNodeSKU();

            if (SKU.Length > 0)
            {
                productSKU = ZNodeSKU.CreateBySKU(SKU);

                if (productSKU.SKUID == 0)
                {
                    ProductService productService = new ProductService();
                    ProductQuery filters = new ProductQuery();
                    filters.AppendEquals(ProductColumn.SKU, SKU);
                    TList<Product> productList = productService.Find(filters.GetParameters());

                    if (productList != null)
                    {
                        if (productList.Count == 0)
                        {
                            // If SKUID or Invalid SKU is Zero then Redirected to default page
                            Response.Redirect("~/error.aspx");
                        }
                    }
                    else
                    {
                        // If SKUID or Invalid SKU is Zero then Redirected to default page
                        Response.Redirect("~/error.aspx");
                    }

                    ProductID = productList[0].ProductID;

                    _product = ZNodeProduct.Create(ProductID, ZNodeConfigManager.SiteConfig.PortalID);
                }
                else
                {
                    // If SKU parameter is supplied & it has value
                    ProductID = productSKU.ProductID;

                    _product = ZNodeProduct.Create(ProductID, ZNodeConfigManager.SiteConfig.PortalID);

                    // Set product SKU
                    _product.SelectedSKU = productSKU;
                }
            }
            else if (_productNum.Length > 0)
            {
                ProductService productService = new ProductService();
                ProductQuery filters = new ProductQuery();
                filters.AppendEquals(ProductColumn.ProductNum, _productNum);
                TList<Product> productList = productService.Find(filters.GetParameters());

                if (productList != null)
                {
                    if (productList.Count == 0)
                    {
                        // If SKUID or Invalid SKU is Zero then Redirected to default page
                        Response.Redirect("~/error.aspx");
                    }
                }
                else
                {
                    // If SKUID or Invalid SKU is Zero then Redirected to default page
                    Response.Redirect("~/error.aspx");
                }

                ProductID = productList[0].ProductID;

                _product = ZNodeProduct.Create(ProductID, ZNodeConfigManager.SiteConfig.PortalID);
            }
            else
            {
                // If SKUID or Invalid SKU is Zero then Redirected to default page
                Response.Redirect("~/error.aspx");
            }

            // Check product attributes count
            if (_product.ZNodeAttributeTypeCollection.Count > 0 && productSKU.SKUID == 0)
            {
                Response.Redirect(_product.ViewProductLink);
            }

            // Loop through the product addons
            foreach (ZNodeAddOn _addOn in _product.ZNodeAddOnCollection)
            {
                if (!_addOn.OptionalInd)
                {
                    Response.Redirect(_product.ViewProductLink);
                }
            }

            // Create shopping cart item
            ZNodeShoppingCartItem item = new ZNodeShoppingCartItem();
            item.Product = new ZNodeProductBase(_product);
            item.Quantity = _quantity;

            // Add product to cart
            ZNodeShoppingCart shoppingCart = ZNodeShoppingCart.CurrentShoppingCart();

            // If shopping cart is null, create in session
            if (shoppingCart == null)
            {
                shoppingCart = new ZNodeShoppingCart();
                shoppingCart.AddToSession(ZNodeSessionKeyType.ShoppingCart);
            }

            // add item to cart
            if (shoppingCart.AddToCart(item))
            {
                string link = "~/shoppingcart.aspx";
                Response.Redirect(link);
            }
            else
            {
                // If Product is out of Stock - Redirected to Product Details  page
                Response.Redirect("~/error.aspx");
            }
        }
    }
Пример #3
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        _shoppingCart = (ZNodeShoppingCart)ZNodeShoppingCart.CreateFromSession(ZNodeSessionKeyType.ShoppingCart);

        if (_shoppingCart != null)
        {
            _shoppingCart.Payment = uxPayment.Payment;

            if (UserAccount.AccountID > 0)
            {
                uxPayment.UserAccount = UserAccount;
                _shoppingCart.Payment.BillingAddress = BillingAddress;
                _shoppingCart.Payment.ShippingAddress = ShippingAddress;
            }

            if (_shoppingCart.ShoppingCartItems.Count > 0 && UserAccount.AccountID > 0)
            {
                pnlPaymentShipping.Visible = true;
                CalculateTaxes(_shoppingCart); //Calculate tax if Customer selected
            }

            if (_shoppingCart.ShoppingCartItems.Count > 0)
            {
                uxPayment.CalculateShipping(); //Calculate shipping
                uxShoppingCart.Visible = true;

                uxShoppingCart.ShoppingCartObject = _shoppingCart;
                uxShoppingCart.Bind();//Bind Shopping Cart items
            }
            else
            {
                uxShoppingCart.Visible = false;
            }

            if (_shoppingCart.Total == 0)
            {
                uxPayment.ShowPaymentSection = false;
            }
            else
            {
                uxPayment.ShowPaymentSection = true;
            }
        }
        else
        {
            uxShoppingCart.Visible = false;
        }
    }
Пример #4
0
    /// <summary>
    /// Page Load Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Browser.Browser.Equals("IE"))
        {
            UpdateProgressIE.Visible = true;
        }
        else if (Request.Browser.Browser.Equals("Firefox"))
        {
            UpdateProgressMozilla.Visible = true;
        }
        else
        {
            UpdateProgressMozilla.Visible = true;
        }

        //registers the event for the customer search (child) control
        this.uxCustomerSearch.SelectedIndexChanged += new EventHandler(FoundUsers_SelectedIndexChanged);

        //registers the event for the create user (child) control
        this.uxCreateUser.ButtonClick += new EventHandler(btnCancel_Click);

        //registers the event for the create user (child) control
        this.uxCustomerSearch.SearchButtonClick += new EventHandler(btnSearchClose_Click);

        //registers the event for the quick Order (child) control - Addto cart button
        this.uxQuickOrder.SubmitButtonClicked += new EventHandler(AddToCart_Click);

        //registers the event for the quick Order (child) control - Addto cart button
        this.uxQuickOrder.CancelButtonClicked += new EventHandler(AddToCart_Click);

        //registers the event for the quick Order (child) control - Add another product button
        this.uxQuickOrder.AddProductButtonClicked += new EventHandler(AddAnotherProduct_Click);

        //registers the event for the payment (child) control - Shipping Type selected change list
        this.uxPayment.ShippingSelectedIndexChanged += new EventHandler(Shipping_SelectedIndexChanged);

        if (!Page.IsPostBack)
        {
            _shoppingCart = (ZNodeShoppingCart)ZNodeShoppingCart.CreateFromSession(ZNodeSessionKeyType.ShoppingCart);

            if (_shoppingCart != null)
            {
                _shoppingCart.EmptyCart();
            }

            // Bind fields
            Bind();
        }
    }
Пример #5
0
    /// <summary>
    /// Cancel Order Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCancelOrder_Click(object sender, EventArgs e)
    {
        _shoppingCart = ZNodeShoppingCart.CurrentShoppingCart();

        if (_shoppingCart != null)
        {
            _shoppingCart.EmptyCart();
            _shoppingCart = null;

            Session.Remove(ZNodeSessionKeyType.ShoppingCart.ToString());
        }

        ResetProfileCache();

        Response.Redirect("~/admin/Secure/default.aspx");
    }
Пример #6
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnBack_Click(object sender, EventArgs e)
    {
        _shoppingCart = ZNodeShoppingCart.CurrentShoppingCart();

        if (_shoppingCart != null)
        {
            _shoppingCart.EmptyCart();
            _shoppingCart = null;

            Session.Remove(ZNodeSessionKeyType.ShoppingCart.ToString());
        }

        ResetProfileCache();

        if (Page.Session["AccountObject"] != null)
        {
            //Remove account object
            Page.Session.Remove("AccountObject");
        }

        Response.Redirect("~/admin/Secure/default.aspx");
    }