⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addresspicker.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Controls.Shop
{
    using PowerEasy.Accessories;
    using PowerEasy.Controls;
    using PowerEasy.Web.UI;
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class AddressPicker : BaseUserControl
    {
        protected DropDownList DropArea;
        protected DropDownList DropCity;
        protected DropDownList DropCountry;
        protected DropDownList DropProvince;
        protected HiddenField HdnZipCode;
        protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
        protected TextBox TxtAddress;
        protected System.Web.UI.UpdatePanel UpnlAddress;
        protected PowerEasy.Controls.RequiredFieldValidator ValrAddress;

        public event EventHandler AddressChanged;

        private void DataBindArea()
        {
            this.DropArea.DataSource = Region.GetAreaListByCity(this.DropCity.SelectedValue);
            this.DropArea.DataBind();
        }

        private void DataBindCity()
        {
            this.DropCity.DataSource = Region.GetCityListByProvince(this.DropProvince.SelectedValue);
            this.DropCity.DataBind();
        }

        protected void DropArea_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GetSelectedValue();
        }

        protected void DropCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DataBindArea();
            this.GetSelectedValue();
        }

        protected void DropCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DropProvince.DataSource = Region.GetProvinceListByCountry(this.DropCountry.SelectedValue);
            this.DropProvince.DataBind();
            this.DataBindCity();
            this.DataBindArea();
            this.GetSelectedValue();
        }

        protected void DropProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DataBindCity();
            this.DataBindArea();
            this.GetSelectedValue();
        }

        private void GetSelectedValue()
        {
            this.HdnZipCode.Value = Region.GetZipCodeByArea(this.DropCountry.SelectedValue, this.DropProvince.SelectedValue, this.DropCity.SelectedValue, this.DropArea.SelectedValue);
            this.AddressChanged(this, EventArgs.Empty);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack && (this.DropCountry.Items.Count == 0))
            {
                this.SelectRegion("请选择所属国家", "", "", "");
            }
        }

        public void Reset()
        {
            this.SelectRegion("请选择所属国家", "", "", "");
            this.HdnZipCode.Value = "";
            this.TxtAddress.Text = "";
        }

        public void SelectRegion(string country, string province, string city, string area)
        {
            string selectedValue = this.DropCountry.SelectedValue;
            string str2 = this.DropProvince.SelectedValue;
            string str3 = this.DropCity.SelectedValue;
            if (this.DropCountry.Items.Count == 0)
            {
                this.DropCountry.DataSource = Region.GetCountryList();
                this.DropCountry.DataBind();
                this.DropCountry.Items.Insert(0, new ListItem("请选择所属国家", "-1"));
            }
            if (selectedValue != country)
            {
                BaseUserControl.SetSelectedIndexByValue(this.DropCountry, country);
                this.DropProvince.DataSource = Region.GetProvinceListByCountry(country);
                this.DropProvince.DataBind();
            }
            if (str2 != province)
            {
                BaseUserControl.SetSelectedIndexByValue(this.DropProvince, province);
                this.DropCity.DataSource = Region.GetCityListByProvince(province);
                this.DropCity.DataBind();
            }
            if (str3 != city)
            {
                BaseUserControl.SetSelectedIndexByValue(this.DropCity, city);
                this.DropArea.DataSource = Region.GetAreaListByCity(this.DropCity.SelectedValue);
                this.DropArea.DataBind();
            }
            BaseUserControl.SetSelectedIndexByValue(this.DropArea, area);
        }

        public string Address
        {
            get
            {
                return this.TxtAddress.Text.Trim();
            }
            set
            {
                this.TxtAddress.Text = value;
            }
        }

        public string Area
        {
            get
            {
                return this.DropArea.SelectedValue;
            }
            set
            {
                this.DropArea.SelectedValue = value;
            }
        }

        public string City
        {
            get
            {
                return this.DropCity.SelectedValue;
            }
            set
            {
                this.DropCity.SelectedValue = value;
            }
        }

        public string Country
        {
            get
            {
                return this.DropCountry.SelectedValue;
            }
            set
            {
                this.DropCountry.SelectedValue = value;
            }
        }

        public string Province
        {
            get
            {
                return this.DropProvince.SelectedValue;
            }
            set
            {
                this.DropProvince.SelectedValue = value;
            }
        }

        public string ZipCode
        {
            get
            {
                return this.HdnZipCode.Value;
            }
            set
            {
                this.HdnZipCode.Value = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -