コード例 #1
0
        private void PopulateAddress(AddressOverviewModel address, out string countryName)
        {
            countryName = string.Empty;

            if (address.Name != string.Empty)
            {
                ltlName.Text = address.Name;
            }

            if (address.AddressLine1 != string.Empty)
            {
                ltlAddr1.Text = address.AddressLine1;
            }

            if (address.AddressLine2 != string.Empty)
            {
                ltlAddr2.Text = address.AddressLine2;
            }

            if (address.City != string.Empty)
            {
                ltlCity.Text = address.City;
            }

            if (address.County != string.Empty)
            {
                phCountryField.Visible = true;
                ltlCounty.Text         = address.County;
            }
            else
            {
                phCountryField.Visible = false;
            }

            if (address.PostCode != string.Empty)
            {
                ltlPostCode.Text = address.PostCode;
            }

            if (address.CountryId != 0)
            {
                Country country = ShippingService.GetCountryById(address.CountryId);

                countryName     = country.Name;
                ltlCountry.Text = country.Name;
                _countryCode    = country.ISO3166Code;
                _countryId      = country.Id;
            }
            else
            {
                _countryCode = string.Empty;
            }

            phStateField.Visible = false;
            phState.Visible      = false;
            _hasUSState          = false;
            ltlState.Text        = string.Empty;
            ltlStateCode.Text    = "-";

            if (_countryCode == US && address.USStateId != 0)
            {
                USState usState = ShippingService.GetUSStateById(address.USStateId);

                if (usState != null)
                {
                    phStateField.Visible = true;
                    phState.Visible      = true;
                    _hasUSState          = true;
                    ltlState.Text        = usState.State;
                    ltlStateCode.Text    = usState.Code;
                }
            }
        }