Esempio n. 1
0
    private void LoadData()
    {
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);

        EditedObject = oi;

        if (oi != null)
        {
            // Check order site ID
            CheckOrderSiteID(oi.OrderSiteID);

            customerId                     = oi.OrderCustomerID;
            addressElem.CustomerID         = customerId;
            drpShippingOption.ShoppingCart = this.ShoppingCartInfoObj;

            if (!RequestHelper.IsPostBack())
            {
                txtTrackingNumber.Text       = oi.OrderTrackingNumber;
                addressElem.CustomerID       = customerId;
                addressElem.AddressID        = oi.OrderShippingAddressID;
                drpShippingOption.ShippingID = oi.OrderShippingOptionID;
            }
        }

        // Enable edit address only if address selected
        btnEdit.Enabled = addressElem.AddressID != 0;

        // If order is paid
        if ((oi != null) && (oi.OrderIsPaid))
        {
            // Disable shipping option edit
            this.drpShippingOption.Enabled = false;

            // Get site information
            SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID);

            // If tax is based on shipping address
            if ((si != null) && (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress))
            {
                // Disable shipping address edit
                this.addressElem.Enabled = false;
                this.btnEdit.Enabled     = false;
                this.btnNew.Enabled      = false;
            }
        }
    }
Esempio n. 2
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // check 'EcommerceModify' permission
        if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
        }

        // Get order
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);

        if (oi != null)
        {
            // Get order site
            SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID);

            // If shipping address is required
            if (((this.ShoppingCartInfoObj != null) && (ShippingOptionInfoProvider.IsShippingNeeded(this.ShoppingCartInfoObj))) ||
                ((si != null) && (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress)))
            {
                // If shipping address is not set
                if (this.addressElem.AddressID <= 0)
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Order_Edit_Shipping.NoAddress");

                    return;
                }
            }

            try
            {
                // Load the shopping cart to process the data
                ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
                if (sci != null)
                {
                    // Set order new properties
                    sci.ShoppingCartShippingOptionID  = drpShippingOption.ShippingID;
                    sci.ShoppingCartShippingAddressID = this.addressElem.AddressID;

                    // Evaulate order data
                    ShoppingCartInfoProvider.EvaluateShoppingCart(sci);

                    // Update order data
                    ShoppingCartInfoProvider.SetOrder(sci, false);
                }

                // Update tracking number
                oi.OrderTrackingNumber = txtTrackingNumber.Text.Trim();
                OrderInfoProvider.SetOrderInfo(oi);

                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // check 'EcommerceModify' permission
        if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
        }

        // Get order
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);

        if (oi != null)
        {
            // Are taxes based on shipping address?
            bool     taxesBasedOnShipping = false;
            SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID);
            if (si != null)
            {
                taxesBasedOnShipping = (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress);
            }

            // Is shipping needed?
            bool isShippingNeeded = ((ShoppingCartInfoObj != null) && (ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCartInfoObj)));

            // If shipping address is required
            if (isShippingNeeded || taxesBasedOnShipping)
            {
                // If shipping address is not set
                if (addressElem.AddressID <= 0)
                {
                    // Show error message
                    ShowError(GetString("Order_Edit_Shipping.NoAddress"));

                    return;
                }
            }

            try
            {
                // Load the shopping cart to process the data
                ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
                if (sci != null)
                {
                    // Set order new properties
                    sci.ShoppingCartShippingOptionID  = drpShippingOption.ShippingID;
                    sci.ShoppingCartShippingAddressID = addressElem.AddressID;

                    // Evaluate order data
                    ShoppingCartInfoProvider.EvaluateShoppingCart(sci);

                    // Update order data
                    ShoppingCartInfoProvider.SetOrder(sci, false);
                }

                // Update tracking number
                oi.OrderTrackingNumber = txtTrackingNumber.Text.Trim();
                OrderInfoProvider.SetOrderInfo(oi);

                // Show message
                ShowChangesSaved();

                // Update shipping charge in selector
                if (taxesBasedOnShipping)
                {
                    drpShippingOption.ShoppingCart = sci;
                    drpShippingOption.Reload(false);
                }
            }
            catch (Exception ex)
            {
                // Show error message
                ShowError(ex.Message);
            }
        }
    }