Пример #1
0
    /// <summary>
    /// Saves data
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        if (!StopProcessing)
        {
            // Set current address
            AddressInfo ai = addressForm.EditedObject as AddressInfo;
            if (ai != null)
            {
                CurrentCartAddress = ai;
                var customer = ShoppingCart.Customer;

                if (string.IsNullOrEmpty(ai.AddressPersonalName) && (customer != null))
                {
                    ai.AddressPersonalName = TextHelper.LimitLength(string.Format("{0} {1}", customer.CustomerFirstName, customer.CustomerLastName), 200);
                }

                if (ai.AddressID != 0)
                {
                    // Save potential customer changes before address is updated
                    if ((customer != null) && (customer.CustomerID != 0))
                    {
                        customer.Update();
                    }

                    ai.Update();
                }
            }
        }

        // Clear shipping address if shipping checkbox is unchecked
        if ((AddressType == SHIPPING) && (!chkShowAddress.Checked))
        {
            ShoppingCart.ShoppingCartShippingAddress = null;
        }

        // Set shopping cart with current address change
        ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
        ShoppingCart.InvalidateCalculations();
    }