/// <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 company address info.
    /// </summary>
    protected void LoadCompanyAddressInfo()
    {
        // Load company address info only if company part is visible
        if (plcCompanyDetail.Visible)
        {
            // Try to select company address from ViewState first
            if (!ShoppingCartControl.IsCurrentStepPostBack && ShoppingCartControl.GetTempValue(COMPANY_ADDRESS_ID) != null)
            {
                LoadCompanyFromViewState();
            }
            else
            {
                if (drpCompanyAddress.SelectedValue != "0")
                {
                    var addressId = Convert.ToInt32(drpCompanyAddress.SelectedValue);

                    var ai = AddressInfoProvider.GetAddressInfo(addressId);
                    if (ai != null)
                    {
                        txtCompanyName.Text        = ai.AddressPersonalName;
                        txtCompanyLine1.Text       = ai.AddressLine1;
                        txtCompanyLine2.Text       = ai.AddressLine2;
                        txtCompanyCity.Text        = ai.AddressCity;
                        txtCompanyZip.Text         = ai.AddressZip;
                        txtCompanyPhone.Text       = ai.AddressPhone;
                        CountrySelector3.CountryID = ai.AddressCountryID;
                        CountrySelector3.StateID   = ai.AddressStateID;
                        CountrySelector3.ReloadData(true);
                    }
                }
                else
                {
                    // clean shipping part of the form
                    CleanForm(false, false, true);

                    // Prefill customer company name or full name
                    if ((ShoppingCart.Customer != null) &&
                        (ShoppingCart.Customer.CustomerCompany != ""))
                    {
                        txtCompanyName.Text = ShoppingCart.Customer.CustomerCompany;
                    }
                    else
                    {
                        txtCompanyName.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);
        }
    }