/// <summary>
    /// Clean specified part of the form.
    /// </summary>
    private void CleanForm(bool billing, bool shipping, bool company)
    {
        AddressInfo defaultCustomerAddress = null;

        if (ShoppingCart?.Customer != null)
        {
            defaultCustomerAddress = ECommerceHelper.GetLastUsedOrDefaultAddress(ShoppingCart.Customer.CustomerID);
        }

        if (shipping)
        {
            txtShippingName.Text  = "";
            txtShippingAddr1.Text = "";
            txtShippingAddr2.Text = "";
            txtShippingCity.Text  = "";
            txtShippingZip.Text   = "";
            txtShippingPhone.Text = "";

            // Pre-load default country
            CountrySelector2.CountryID = defaultCustomerAddress?.AddressCountryID ?? 0;
            CountrySelector2.StateID   = defaultCustomerAddress?.AddressStateID ?? 0;
            CountrySelector2.ReloadData(true);
        }
        if (billing)
        {
            txtBillingName.Text  = "";
            txtBillingAddr1.Text = "";
            txtBillingAddr2.Text = "";
            txtBillingCity.Text  = "";
            txtBillingZip.Text   = "";
            txtBillingPhone.Text = "";

            // Pre-load default country
            CountrySelector1.CountryID = defaultCustomerAddress?.AddressCountryID ?? 0;
            CountrySelector1.StateID   = defaultCustomerAddress?.AddressStateID ?? 0;
            CountrySelector1.ReloadData(true);
        }
        if (company)
        {
            txtCompanyName.Text  = "";
            txtCompanyLine1.Text = "";
            txtCompanyLine2.Text = "";
            txtCompanyCity.Text  = "";
            txtCompanyZip.Text   = "";
            txtCompanyPhone.Text = "";

            // Pre-load default country
            CountrySelector3.CountryID = defaultCustomerAddress?.AddressCountryID ?? 0;
            CountrySelector3.StateID   = defaultCustomerAddress?.AddressStateID ?? 0;
            CountrySelector3.ReloadData(true);
        }
    }
    /// <summary>
    /// Loads selected billing  address info.
    /// </summary>
    protected void LoadBillingAddressInfo()
    {
        // Try to select company address from ViewState first
        if (!ShoppingCartControl.IsCurrentStepPostBack && ShoppingCartControl.GetTempValue(BILLING_ADDRESS_ID) != null)
        {
            LoadBillingFromViewState();
        }
        else
        {
            if (drpBillingAddr.SelectedValue != "0")
            {
                var addressId = Convert.ToInt32(drpBillingAddr.SelectedValue);

                var ai = AddressInfoProvider.GetAddressInfo(addressId);
                if (ai != null)
                {
                    txtBillingName.Text        = ai.AddressPersonalName;
                    txtBillingAddr1.Text       = ai.AddressLine1;
                    txtBillingAddr2.Text       = ai.AddressLine2;
                    txtBillingCity.Text        = ai.AddressCity;
                    txtBillingZip.Text         = ai.AddressZip;
                    txtBillingPhone.Text       = ai.AddressPhone;
                    CountrySelector1.CountryID = ai.AddressCountryID;
                    CountrySelector1.StateID   = ai.AddressStateID;
                    CountrySelector1.ReloadData(true);
                }
            }
            else
            {
                // Clean billing part of the form
                CleanForm(true, false, false);

                // Prefill customer company name or full name
                if ((ShoppingCart.Customer != null) &&
                    (ShoppingCart.Customer.CustomerCompany != ""))
                {
                    txtBillingName.Text = ShoppingCart.Customer.CustomerCompany;
                }
                else
                {
                    txtBillingName.Text = ShoppingCart.Customer.CustomerFirstName + " " + ShoppingCart.Customer.CustomerLastName;
                }
            }
        }
    }
    /// <summary>
    /// Clean specified part of the form.
    /// </summary>
    private void CleanForm(bool billing, bool shipping, bool company)
    {
        var defaultCountryId = 0;
        var defaultStateId   = 0;

        // Prefill country from customer if any
        if ((ShoppingCart != null) && (ShoppingCart.Customer != null))
        {
            defaultCountryId = ShoppingCart.Customer.CustomerCountryID;
            defaultStateId   = ShoppingCart.Customer.CustomerStateID;
        }

        // Prefill default store country if customers country not found
        if ((defaultCountryId <= 0) && (SiteContext.CurrentSite != null))
        {
            var countryName = ECommerceSettings.DefaultCountryName(SiteContext.CurrentSite.SiteName);
            var ci          = CountryInfoProvider.GetCountryInfo(countryName);
            defaultCountryId = (ci != null) ? ci.CountryID : 0;
            defaultStateId   = 0;
        }

        if (shipping)
        {
            txtShippingName.Text  = "";
            txtShippingAddr1.Text = "";
            txtShippingAddr2.Text = "";
            txtShippingCity.Text  = "";
            txtShippingZip.Text   = "";
            txtShippingPhone.Text = "";

            // Pre-load default country
            CountrySelector2.CountryID = defaultCountryId;
            CountrySelector2.StateID   = defaultStateId;
            CountrySelector2.ReloadData(true);
        }
        if (billing)
        {
            txtBillingName.Text  = "";
            txtBillingAddr1.Text = "";
            txtBillingAddr2.Text = "";
            txtBillingCity.Text  = "";
            txtBillingZip.Text   = "";
            txtBillingPhone.Text = "";

            // Pre-load default country
            CountrySelector1.CountryID = defaultCountryId;
            CountrySelector1.StateID   = defaultStateId;
            CountrySelector1.ReloadData(true);
        }
        if (company)
        {
            txtCompanyName.Text  = "";
            txtCompanyLine1.Text = "";
            txtCompanyLine2.Text = "";
            txtCompanyCity.Text  = "";
            txtCompanyZip.Text   = "";
            txtCompanyPhone.Text = "";

            // Pre-load default country
            CountrySelector3.CountryID = defaultCountryId;
            CountrySelector3.StateID   = defaultStateId;
            CountrySelector3.ReloadData(true);
        }
    }