Ejemplo n.º 1
0
        protected override void CreateChildControls()
        {
            this.Controls.Clear();
            if (!this.dataLoaded)
            {
                if (!string.IsNullOrEmpty(this.Context.Request.Form["regionSelectorValue"]))
                {
                    this.currentRegionId = new int?(int.Parse(this.Context.Request.Form["regionSelectorValue"]));
                }
                this.dataLoaded = true;
            }
            if (this.currentRegionId.HasValue)
            {
                XmlNode region = RegionHelper.GetRegion(this.currentRegionId.Value);
                if (region != null)
                {
                    if (region.Name == "county")
                    {
                        this.countyId   = new int?(this.currentRegionId.Value);
                        this.cityId     = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                        this.provinceId = new int?(int.Parse(region.ParentNode.ParentNode.Attributes["id"].Value));
                    }
                    else if (region.Name == "city")
                    {
                        this.cityId     = new int?(this.currentRegionId.Value);
                        this.provinceId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                    }
                    else if (region.Name == "province")
                    {
                        this.provinceId = new int?(this.currentRegionId.Value);
                    }
                }
            }
            this.ddlProvinces = this.CreateDropDownList("ddlRegions1", "-请选择省-");
            FillDropDownList(this.ddlProvinces, RegionHelper.GetAllProvinces(), this.provinceId);
            this.Controls.Add(CreateTag("<span>"));
            this.Controls.Add(this.ddlProvinces);
            this.Controls.Add(CreateTag("</span>"));
            this.ddlCitys = this.CreateDropDownList("ddlRegions2", "-请选择市-");
            if (this.provinceId.HasValue)
            {
                FillDropDownList(this.ddlCitys, RegionHelper.GetCitys(this.provinceId.Value), this.cityId);
            }


            this.Controls.Add(CreateTag("<span>"));
            this.Controls.Add(this.ddlCitys);
            this.Controls.Add(CreateTag("</span>"));
            if (this.CountyTitle != "0")
            {
                this.ddlCountys = this.CreateDropDownList("ddlRegions3", "-请选择区-");
                if (this.cityId.HasValue)
                {
                    FillDropDownList(this.ddlCountys, RegionHelper.GetCountys(this.cityId.Value), this.countyId);
                }
                this.Controls.Add(CreateTag("<span>"));
                this.Controls.Add(this.ddlCountys);
                this.Controls.Add(CreateTag("</span>"));
            }
        }
Ejemplo n.º 2
0
 protected override void CreateChildControls()
 {
     Controls.Clear();
     if (!dataLoaded)
     {
         if (!string.IsNullOrEmpty(Context.Request.Form["regionSelectorValue"]))
         {
             currentRegionId = new int?(int.Parse(Context.Request.Form["regionSelectorValue"]));
         }
         dataLoaded = true;
     }
     if (currentRegionId.HasValue)
     {
         XmlNode region = RegionHelper.GetRegion(currentRegionId.Value);
         if (region != null)
         {
             if (region.Name == "county")
             {
                 countyId   = new int?(currentRegionId.Value);
                 cityId     = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                 provinceId = new int?(int.Parse(region.ParentNode.ParentNode.Attributes["id"].Value));
             }
             else if (region.Name == "city")
             {
                 cityId     = new int?(currentRegionId.Value);
                 provinceId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
             }
             else if (region.Name == "province")
             {
                 provinceId = new int?(currentRegionId.Value);
             }
         }
     }
     Controls.Add(CreateTitleControl(ProvinceTitle));
     ddlProvinces = CreateDropDownList("ddlRegions1");
     FillDropDownList(ddlProvinces, RegionHelper.GetAllProvinces(), provinceId);
     Controls.Add(CreateTag("<span>"));
     Controls.Add(ddlProvinces);
     Controls.Add(CreateTag("</span>"));
     Controls.Add(CreateTitleControl(CityTitle));
     ddlCitys = CreateDropDownList("ddlRegions2");
     if (provinceId.HasValue)
     {
         FillDropDownList(ddlCitys, RegionHelper.GetCitys(provinceId.Value), cityId);
     }
     Controls.Add(CreateTag("<span>"));
     Controls.Add(ddlCitys);
     Controls.Add(CreateTag("</span>"));
     Controls.Add(CreateTitleControl(CountyTitle));
     ddlCountys = CreateDropDownList("ddlRegions3");
     if (cityId.HasValue)
     {
         FillDropDownList(ddlCountys, RegionHelper.GetCountys(cityId.Value), countyId);
     }
     Controls.Add(CreateTag("<span>"));
     Controls.Add(ddlCountys);
     Controls.Add(CreateTag("</span>"));
 }
Ejemplo n.º 3
0
        private List <RegionListItem> GetRegionDictionary()
        {
            List <RegionListItem> pItems = new List <RegionListItem>();

            Dictionary <int, string> provinces = RegionHelper.GetAllProvinces();

            RegionListItem province = null;

            foreach (var p in provinces)
            {
                province = new RegionListItem("PROVINCE", 1);

                province.Id       = p.Key;
                province.Name     = p.Value;
                province.ParentId = 0;

                Dictionary <int, string> cities = RegionHelper.GetCitys(province.Id);

                List <RegionListItem> cItems = new List <RegionListItem>();
                RegionListItem        city   = null;
                foreach (var c in cities)
                {
                    city = new RegionListItem("CITY", 2);

                    city.Id       = c.Key;
                    city.Name     = c.Value;
                    city.ParentId = province.Id;

                    Dictionary <int, string> districts = RegionHelper.GetCountys(city.Id);
                    List <RegionListItem>    dItems    = new List <RegionListItem>();
                    RegionListItem           district  = null;
                    foreach (var d in districts)
                    {
                        district = new RegionListItem("DISTRICT", 3);

                        district.Id       = d.Key;
                        district.Name     = d.Value;
                        district.ParentId = city.Id;

                        dItems.Add(district);
                    }

                    city.Children = dItems;

                    cItems.Add(city);
                }

                province.Children = cItems;

                pItems.Add(province);
            }

            return(pItems);
        }
Ejemplo n.º 4
0
        private static void GetRegions(HttpContext context)
        {
            Dictionary <int, string> citys;

            context.Response.ContentType = "application/json";
            int result = 0;

            int.TryParse(context.Request["parentId"], out result);
            if (result > 0)
            {
                XmlNode region = RegionHelper.GetRegion(result);
                if (region == null)
                {
                    context.Response.Write("{\"Status\":\"0\"}");
                    return;
                }
                if (region.Name.Equals("province"))
                {
                    citys = RegionHelper.GetCitys(result);
                }
                else
                {
                    citys = RegionHelper.GetCountys(result);
                }
            }
            else
            {
                citys = RegionHelper.GetAllProvinces();
            }
            if (citys.Count == 0)
            {
                context.Response.Write("{\"Status\":\"0\"}");
            }
            else
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("{");
                builder.Append("\"Status\":\"OK\",");
                builder.Append("\"Regions\":[");
                foreach (int num2 in citys.Keys)
                {
                    builder.Append("{");
                    builder.AppendFormat("\"RegionId\":\"{0}\",", num2.ToString(CultureInfo.InvariantCulture));
                    builder.AppendFormat("\"RegionName\":\"{0}\"", citys[num2]);
                    builder.Append("},");
                }
                builder.Remove(builder.Length - 1, 1);
                builder.Append("]}");
                citys.Clear();
                context.Response.Write(builder.ToString());
            }
        }
Ejemplo n.º 5
0
        private static void GetRegions(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int num = 0;

            int.TryParse(context.Request["parentId"], out num);
            Dictionary <int, string> dictionary;

            if (num > 0)
            {
                XmlNode region = RegionHelper.GetRegion(num);
                if (region == null)
                {
                    context.Response.Write("{\"Status\":\"0\"}");
                    return;
                }
                if (region.Name.Equals("province"))
                {
                    dictionary = RegionHelper.GetCitys(num);
                }
                else
                {
                    dictionary = RegionHelper.GetCountys(num);
                }
            }
            else
            {
                dictionary = RegionHelper.GetAllProvinces();
            }
            if (dictionary.Count == 0)
            {
                context.Response.Write("{\"Status\":\"0\"}");
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("{");
            stringBuilder.Append("\"Status\":\"OK\",");
            stringBuilder.Append("\"Regions\":[");
            foreach (int current in dictionary.Keys)
            {
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"RegionId\":\"{0}\",", current.ToString(CultureInfo.InvariantCulture));
                stringBuilder.AppendFormat("\"RegionName\":\"{0}\"", dictionary[current]);
                stringBuilder.Append("},");
            }
            stringBuilder.Remove(stringBuilder.Length - 1, 1);
            stringBuilder.Append("]}");
            dictionary.Clear();
            context.Response.Write(stringBuilder.ToString());
        }
Ejemplo n.º 6
0
        private void btnEditProfile_Click(object sender, System.EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            if (!this.rsddlRegion.GetSelectedRegionId().HasValue || string.IsNullOrEmpty(this.txtRealName.Text.Trim()) || string.IsNullOrEmpty(this.txtAddress.Text.Trim()) || string.IsNullOrEmpty(this.txtZip.Text.Trim()) || string.IsNullOrEmpty(this.txtCellPhone.Text.Trim()))
            {
                this.ShowMsg("错误:收货人、所在区域、具体地址、邮编、手机必填", false);
                return;
            }
            int    value           = this.rsddlRegion.GetSelectedRegionId().Value;
            string selectedRegions = this.rsddlRegion.SelectedRegions;

            string[] array = selectedRegions.Split(",".ToCharArray());
            if (array.Length == 1 && RegionHelper.GetCitys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            if (array.Length == 2 && RegionHelper.GetCountys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
            manager.Email = this.txtprivateEmail.Text;
            if (!this.ValidationManageEamilr(manager))
            {
                return;
            }
            string[] userRoleNames = Hidistro.Membership.Core.RoleHelper.GetUserRoleNames(manager.Username);
            string[] array2        = userRoleNames;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (!Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text) || string.Compare(text, "SystemAdministrator") == 0)
                {
                    Hidistro.Membership.Core.RoleHelper.RemoveUserFromRole(manager.Username, text);
                }
            }
            Hidistro.Membership.Core.RoleHelper.AddUserToRole(manager.Username, "区域发货点");
            if (ManagerHelper.Update(manager))
            {
                Methods.Supplier_ShipPointUpdate(this.userId, this.fkRemark.Text, new int?(value), selectedRegions, this.txtRealName.Text.Trim(), this.txtAddress.Text.Trim(), this.txtZip.Text.Trim(), this.txtCellPhone.Text.Trim(), this.txtPhone.Text.Trim());
                this.ShowMsg("成功修改了当前区域发货点的个人资料", true);
                return;
            }
            this.ShowMsg("当前区域发货点的个人信息修改失败", false);
        }
Ejemplo n.º 7
0
        private static void GetRegions(HttpContext context)
        {
            Dictionary <int, string> citys;
            string fieldCode = "ProvinceId";

            context.Response.ContentType = "application/json";
            int result = 0;

            int.TryParse(context.Request["parentId"], out result);
            if (result > 0)//如果传回来的省份有值,则根据省份筛选
            {
                XmlNode region = RegionHelper.GetRegion(result);
                if (region == null)
                {
                    context.Response.Write("{\"Status\":\"0\"}");
                    return;
                }
                if (region.Name.Equals("province"))
                {
                    citys     = RegionHelper.GetCitys(result);
                    fieldCode = "CityId";
                }
                else
                {
                    citys     = RegionHelper.GetCountys(result);
                    fieldCode = "CountyId";
                }
            }
            else//如果没有传递值来,是初始化载入所有的省
            {
                citys = RegionHelper.GetAllProvinces();

                //如果开启了门店配送功能,则是根据支持的街道信息来过滤绑定省份信息
            }

            if (Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AutoShipping && System.Web.HttpContext.Current.Request.Path.IndexOf("/" + "admin" + "/") < 0)
            {
                //如果是后台,则不进行过滤,前端过滤.

                DataTable dtAll  = Hidistro.ControlPanel.Sales.SalesHelper.GetAllStreetRegionId();
                var       vcitys = citys.Where(x => dtAll.AsEnumerable().Select(a => a.Field <int>(fieldCode)).Any(a => x.Key.Equals(a)));

                if (vcitys.Count() == 0)
                {
                    context.Response.Write("{\"Status\":\"0\"}");
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("{");
                    builder.Append("\"Status\":\"OK\",");
                    builder.Append("\"Regions\":[");

                    foreach (var q in vcitys)
                    {
                        builder.Append("{");
                        builder.AppendFormat("\"RegionId\":\"{0}\",", q.Key);
                        builder.AppendFormat("\"RegionName\":\"{0}\"", q.Value);
                        builder.Append("},");
                    }
                    builder.Remove(builder.Length - 1, 1);
                    builder.Append("]}");
                    citys.Clear();
                    context.Response.Write(builder.ToString());
                }
            }
            else
            {
                #region
                if (citys.Count == 0)
                {
                    context.Response.Write("{\"Status\":\"0\"}");
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("{");
                    builder.Append("\"Status\":\"OK\",");
                    builder.Append("\"Regions\":[");

                    foreach (int num2 in citys.Keys)
                    {
                        builder.Append("{");
                        builder.AppendFormat("\"RegionId\":\"{0}\",", num2.ToString(CultureInfo.InvariantCulture));
                        builder.AppendFormat("\"RegionName\":\"{0}\"", citys[num2]);
                        builder.Append("},");
                    }
                    builder.Remove(builder.Length - 1, 1);
                    builder.Append("]}");
                    citys.Clear();
                    context.Response.Write(builder.ToString());
                }
                #endregion
            }
        }
Ejemplo n.º 8
0
        public void BuildJson()
        {
            DateTime      now            = DateTime.Now;
            StringBuilder stringBuilder  = new StringBuilder();
            StringBuilder stringBuilder2 = new StringBuilder();
            StringBuilder stringBuilder3 = new StringBuilder();

            stringBuilder3.Append("{");
            stringBuilder3.Append("\"province\":[");
            int num  = 9;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            IDictionary <int, string> regionArea = this.GetRegionArea();

            foreach (KeyValuePair <int, string> item in regionArea)
            {
                IDictionary <int, string> provinces = RegionHelper.GetProvinces(item.Key, false);
                foreach (KeyValuePair <int, string> item2 in provinces)
                {
                    num++;
                    num2 = 0;
                    if (num > 10)
                    {
                        stringBuilder3.Append(",{");
                    }
                    else
                    {
                        stringBuilder3.Append("{");
                    }
                    stringBuilder3.Append($"\"id\":\"{item2.Key}\",");
                    stringBuilder3.Append($"\"name\":\"{item2.Value}\",");
                    stringBuilder3.Append("\"city\":[");
                    IDictionary <int, string> citys = RegionHelper.GetCitys(item2.Key, false);
                    foreach (KeyValuePair <int, string> item3 in citys)
                    {
                        num2++;
                        if (num2 > 1)
                        {
                            stringBuilder3.Append(",{");
                        }
                        else
                        {
                            stringBuilder3.Append("{");
                        }
                        stringBuilder3.Append($"\"id\":\"{item3.Key}\",");
                        stringBuilder3.Append($"\"name\":\"{item3.Value}\",");
                        stringBuilder3.Append("\"county\":[");
                        num3 = 0;
                        IDictionary <int, string> countys = RegionHelper.GetCountys(item3.Key, false);
                        foreach (KeyValuePair <int, string> item4 in countys)
                        {
                            num3++;
                            if (num3 > 1)
                            {
                                stringBuilder3.Append(",{");
                            }
                            else
                            {
                                stringBuilder3.Append("{");
                            }
                            stringBuilder3.Append($"\"id\":\"{item4.Key}\",");
                            stringBuilder3.Append($"\"name\":\"{item4.Value}\",");
                            stringBuilder3.Append("\"street\":[");
                            num4 = 0;
                            IList <RegionInfo> streetsFromDB = RegionHelper.GetStreetsFromDB(item4.Key, false);
                            if (streetsFromDB != null && streetsFromDB.Count > 0)
                            {
                                foreach (RegionInfo item5 in streetsFromDB)
                                {
                                    num4++;
                                    if (num4 > 1)
                                    {
                                        stringBuilder3.Append(",{");
                                    }
                                    else
                                    {
                                        stringBuilder3.Append("{");
                                    }
                                    stringBuilder3.Append($"\"id\":\"{item5.RegionId}\",");
                                    stringBuilder3.Append($"\"name\":\"{item5.RegionName}\"");
                                    stringBuilder3.Append("}");
                                }
                            }
                            stringBuilder3.Append("]}");
                        }
                        stringBuilder3.Append("]}");
                    }
                    stringBuilder3.Append("]}");
                }
            }
            stringBuilder3.Append("]}");
            using (StreamWriter streamWriter = File.CreateText(HttpContext.Current.Request.MapPath("/config/region.js")))
            {
                streamWriter.WriteLine(stringBuilder3.ToString());
                streamWriter.Flush();
                streamWriter.Close();
            }
            this.ShowMsg("同步数据成功", true, "AreaManage.aspx");
        }
Ejemplo n.º 9
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = "supplier_" + System.DateTime.Now.Ticks.ToString() + "@tom.com";
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            siteManager.Comment        = this.fkRemark.Text;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            if (!this.rsddlRegion.GetSelectedRegionId().HasValue || string.IsNullOrEmpty(this.txtRealName.Text.Trim()) || string.IsNullOrEmpty(this.txtAddress.Text.Trim()) || string.IsNullOrEmpty(this.txtZip.Text.Trim()) || string.IsNullOrEmpty(this.txtCellPhone.Text.Trim()))
            {
                this.ShowMsg("错误:收货人、所在区域、具体地址、邮编、手机必填", false);
                return;
            }
            int    value           = this.rsddlRegion.GetSelectedRegionId().Value;
            string selectedRegions = this.rsddlRegion.SelectedRegions;

            string[] array = selectedRegions.Split(",".ToCharArray());
            if (array.Length == 1 && RegionHelper.GetCitys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            if (array.Length == 2 && RegionHelper.GetCountys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            try
            {
                createUserStatus = ManagerHelper.Create(siteManager, "区域发货点");
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                Methods.Supplier_ShipPointUpdate(siteManager.UserId, this.fkRemark.Text, new int?(value), selectedRegions, this.txtRealName.Text.Trim(), this.txtAddress.Text.Trim(), this.txtZip.Text.Trim(), this.txtCellPhone.Text.Trim(), this.txtPhone.Text.Trim());
                this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "sucess", string.Format("<script language=\"javascript\" >alert('添加成功');window.location.href=\"{0}\"</script>", System.Web.HttpContext.Current.Request.RawUrl));
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateUsername:
                this.ShowMsg("您输入的用户名已经被注册使用", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateEmailAddress:
                this.ShowMsg("您输入的电子邮件地址已经被注册使用", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
Ejemplo n.º 10
0
        protected override void CreateChildControls()
        {
            this.Controls.Clear();
            if (!this.dataLoaded)
            {
                if (!string.IsNullOrEmpty(this.Context.Request.Form[IDPrev + "regionSelectorValue"]))
                {
                    this.currentRegionId = new int?(int.Parse(this.Context.Request.Form[IDPrev + "regionSelectorValue"]));
                }
                this.dataLoaded = true;
            }
            if (this.currentRegionId.HasValue)
            {
                XmlNode region = RegionHelper.GetRegion(this.currentRegionId.Value);
                if (region != null)
                {
                    if (region.Name == "county")
                    {
                        this.countyId   = new int?(this.currentRegionId.Value);
                        this.cityId     = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                        this.provinceId = new int?(int.Parse(region.ParentNode.ParentNode.Attributes["id"].Value));
                    }
                    else if (region.Name == "city")
                    {
                        this.cityId     = new int?(this.currentRegionId.Value);
                        this.provinceId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                    }
                    else if (region.Name == "province")
                    {
                        this.provinceId = new int?(this.currentRegionId.Value);
                    }
                }
            }
            this.Controls.Add(CreateTag("<div class=\"address_wap\"><div class=\"dp_border\"></div><div class=\"dp_address\">"));
            this.ddlProvinces = this.CreateHypLink("province_top", "provincename", this.provinceId, this.ProvinceTitle, this.ProvinceWidth, out this.proviceSpan);
            this.FillHypLink(this.proviceSpan, "province", RegionHelper.GetAllProvinces(), this.provinceId, out this.proviceDiv);
            this.ddlCitys = this.CreateHypLink("city_top", "cityname", this.cityId, this.CityTitle, this.CityWidth, out this.citySpan);
            Dictionary <int, string> regions = new Dictionary <int, string>();

            if (this.provinceId.HasValue)
            {
                regions = RegionHelper.GetCitys(this.provinceId.Value);
            }
            this.FillHypLink(this.citySpan, "city", regions, this.cityId, out this.cityDiv);
            this.ddlCountys = this.CreateHypLink("area_top", "areaname", this.cityId, this.CountyTitle, this.CountyWidth, out this.areaSpan);
            Dictionary <int, string> countys = new Dictionary <int, string>();

            if (this.cityId.HasValue)
            {
                countys = RegionHelper.GetCountys(this.cityId.Value);
            }
            this.FillHypLink(this.areaSpan, "area", countys, this.countyId, out this.areaDiv);
            this.Controls.Add(this.ddlProvinces);
            this.Controls.Add(this.ddlCitys);
            this.Controls.Add(this.ddlCountys);
            this.Controls.Add(CreateTag("</div>"));
            this.Controls.Add(this.proviceDiv);
            this.Controls.Add(this.cityDiv);
            this.Controls.Add(this.areaDiv);
            this.Controls.Add(CreateTag("</div>"));
            if (!this.CustomerCss)
            {
                Literal       child   = new Literal();
                StringBuilder builder = new StringBuilder();
                builder.Append("<style type=\"text/css\">");
                builder.AppendLine(".dropdown_button {" + string.Format("background: url('{0}') no-repeat;", this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "Hidistro.UI.Common.Controls.images.combo_arrow.jpg")) + "}");
                builder.AppendLine(".dp_address a:hover .dropdown_button {" + string.Format("background: url('{0}') no-repeat;", this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "Hidistro.UI.Common.Controls.images.combo_arrow1.jpg")) + "}");
                builder.AppendLine("</style>");
                child.Text = builder.ToString();
                this.Controls.Add(child);
                WebControl control = new WebControl(HtmlTextWriterTag.Link);
                control.Attributes.Add("rel", "stylesheet");
                control.Attributes.Add("href", this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "Hidistro.UI.Common.Controls.css.region.css"));
                control.Attributes.Add("type", "text/css");
                control.Attributes.Add("media", "screen");
                control.ID = "regionStyle";
                //this.Controls.Add(control);
            }
        }
Ejemplo n.º 11
0
        private bool ValShippingAddress(System.Web.HttpContext context, ref string erromsg)
        {
            //System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[\\u4e00-\\u9fa5a-zA-Z]+[\\u4e00-\\u9fa5_a-zA-Z0-9]*");
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^[\\u4e00-\\u9fa5]{2,6}$");
            if (string.IsNullOrEmpty(context.Request.Params["ShippingTo"].Trim()) || !regex.IsMatch(context.Request.Params["ShippingTo"].Trim()))
            {
                //erromsg = "收货人名字不能为空,只能是汉字或字母开头,长度在2-20个字符之间";
                erromsg = "收货人名字只能为2-6个汉字";
                return(false);
            }
            if (string.IsNullOrEmpty(context.Request.Params["AddressDetails"].Trim()))
            {
                erromsg = "详细地址不能为空";
                return(false);
            }
            if (context.Request.Params["AddressDetails"].Trim().Length < 3 || context.Request.Params["AddressDetails"].Trim().Length > 60)
            {
                erromsg = "详细地址长度在3-60个字符之间";
                return(false);
            }
            int cityId = 0, provinceId = 0;

            if (context.Request.Params["CityId"] != null && !string.IsNullOrEmpty(context.Request.Params["CityId"].Trim()))
            {
                cityId = Convert.ToInt32(context.Request.Params["CityId"].Trim());
            }

            if (context.Request.Params["ProvinceId"] != null && !string.IsNullOrEmpty(context.Request.Params["ProvinceId"].Trim()))
            {
                provinceId = Convert.ToInt32(context.Request.Params["ProvinceId"].Trim());
            }

            Dictionary <int, string> dic        = RegionHelper.GetCitys(provinceId);
            Dictionary <int, string> dictionary = RegionHelper.GetCountys(cityId);

            if ((dic.Count > 0 && cityId <= 0) || (dictionary.Count > 0 && (string.IsNullOrEmpty(context.Request.Params["RegionId"].Trim()) || System.Convert.ToInt32(context.Request.Params["RegionId"].Trim()) <= 0)))
            {
                erromsg = "请选择收货地址";
                return(false);
            }

            int    regionId                     = Convert.ToInt32(context.Request.Params["RegionId"].Trim());
            string regionIdstr                  = RegionHelper.GetFullPath(regionId);

            if ((dic.Count > 0 && cityId <= 0) || (dictionary.Count > 0 && regionIdstr.Split(',').Length != 3))
            {
                erromsg = "请选择完整的地区";
                return(false);
            }

            if (string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim().Trim()))
            {
                erromsg = "电话号码和手机二者必填其一";
                return(false);
            }
            if (!string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && (context.Request.Params["TelPhone"].Trim().Length < 3 || context.Request.Params["TelPhone"].Trim().Length > 20))
            {
                erromsg = "电话号码长度限制在3-20个字符之间";
                return(false);
            }
            if (!string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim()) && (context.Request.Params["CellHphone"].Trim().Length < 3 || context.Request.Params["CellHphone"].Trim().Length > 20))
            {
                erromsg = "手机号码长度限制在3-20个字符之间";
                return(false);
            }
            string patternIdentityCard = "^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$";

            System.Text.RegularExpressions.Regex regexIdentityCard = new System.Text.RegularExpressions.Regex(patternIdentityCard);
            string IdentityCard = context.Request.Params["IdentityCard"].Trim();

            //if (!string.IsNullOrEmpty(IdentityCard) && !regexIdentityCard.IsMatch(IdentityCard))
            //{
            //     erromsg="请输入正确的身份证号码";
            //    return false;
            //}
            if (MemberProcessor.GetShippingAddressCount() > HiContext.Current.Config.ShippingAddressQuantity)
            {
                erromsg = string.Format("最多只能添加{0}个收货地址", HiContext.Current.Config.ShippingAddressQuantity);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 12
0
        protected override void CreateChildControls()
        {
            this.Controls.Clear();
            if (!this.dataLoaded)
            {
                if (!string.IsNullOrEmpty(this.Context.Request.Form[RegionSelector.IDPrev + "regionSelectorValue"]))
                {
                    this.currentRegionId = int.Parse(this.Context.Request.Form[RegionSelector.IDPrev + "regionSelectorValue"]);
                }
                this.dataLoaded = true;
            }
            if (this.currentRegionId.HasValue)
            {
                Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(this.currentRegionId.Value, true);
                if (region != null)
                {
                    if (region.Depth == 4)
                    {
                        this.streetId   = this.currentRegionId;
                        this.countyId   = region.ParentRegionId;
                        this.cityId     = RegionHelper.GetCityId(region.ParentRegionId);
                        this.provinceId = RegionHelper.GetTopRegionId(region.ParentRegionId, true);
                    }
                    if (region.Depth == 3)
                    {
                        this.countyId   = this.currentRegionId.Value;
                        this.cityId     = region.ParentRegionId;
                        this.provinceId = RegionHelper.GetTopRegionId(region.ParentRegionId, true);
                    }
                    else if (region.Depth == 2)
                    {
                        this.cityId     = this.currentRegionId.Value;
                        this.provinceId = region.ParentRegionId;
                    }
                    else if (region.Depth == 1)
                    {
                        this.provinceId = this.currentRegionId.Value;
                    }
                }
            }
            this.Controls.Add(RegionSelector.CreateTag("<div class=\"address_wap\"><div class=\"dp_border\"></div><div class=\"dp_address\">"));
            this.ddlProvinces = this.CreateHypLink("province_top", "provincename", this.provinceId, this.ProvinceTitle, this.ProvinceWidth, out this.proviceSpan);
            this.FillHypLink(this.proviceSpan, "province", (Dictionary <int, string>)RegionHelper.GetAllProvinces(false), this.provinceId, (int?)0, out this.proviceDiv);
            this.ddlCitys = this.CreateHypLink("city_top", "cityname", this.cityId, this.CityTitle, this.CityWidth, out this.citySpan);
            Dictionary <int, string> regions = new Dictionary <int, string>();

            if (this.provinceId.HasValue)
            {
                regions = RegionHelper.GetCitys(this.provinceId.Value, false);
            }
            this.FillHypLink(this.citySpan, "city", regions, this.cityId, this.provinceId, out this.cityDiv);
            this.ddlCountys = this.CreateHypLink("area_top", "areaname", this.countyId, this.CountyTitle, this.CountyWidth, out this.areaSpan);
            Dictionary <int, string> regions2 = new Dictionary <int, string>();

            if (this.cityId.HasValue)
            {
                regions2 = RegionHelper.GetCountys(this.cityId.Value, false);
            }
            this.FillHypLink(this.areaSpan, "area", regions2, this.countyId, this.cityId, out this.areaDiv);
            if (this.DisplayStreet)
            {
                this.ddlStreets = this.CreateHypLink("street_top", "streetname", this.streetId, this.StreetTitle, this.StreetWidth, out this.streetSpan);
                Dictionary <int, string> regions3 = new Dictionary <int, string>();
                if (this.countyId.HasValue)
                {
                    regions3 = RegionHelper.GetStreets(this.countyId.Value, false);
                }
                this.FillHypLink(this.streetSpan, "street", regions3, this.streetId, this.countyId, out this.streetDiv);
            }
            this.Controls.Add(this.ddlProvinces);
            this.Controls.Add(this.ddlCitys);
            this.Controls.Add(this.ddlCountys);
            if (this.DisplayStreet)
            {
                this.Controls.Add(this.ddlStreets);
            }
            this.Controls.Add(RegionSelector.CreateTag("</div>"));
            this.Controls.Add(this.proviceDiv);
            this.Controls.Add(this.cityDiv);
            this.Controls.Add(this.areaDiv);
            if (this.DisplayStreet)
            {
                this.Controls.Add(this.streetDiv);
            }
            this.Controls.Add(RegionSelector.CreateTag("</div>"));
            if (!this.CustomerCss)
            {
                Literal       literal       = new Literal();
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("<style type=\"text/css\">");
                stringBuilder.AppendLine(".dropdown_button {" + string.Format("background: url('{0}') no-repeat;", "/Admin/images/combo_arrow.jpg") + "}");
                stringBuilder.AppendLine(".dp_address a:hover .dropdown_button {" + string.Format("background: url('{0}') no-repeat;", "/Admin/images/combo_arrow1.jpg") + "}");
                stringBuilder.AppendLine("</style>");
                literal.Text = stringBuilder.ToString();
                this.Controls.Add(literal);
                WebControl webControl = new WebControl(HtmlTextWriterTag.Link);
                webControl.Attributes.Add("rel", "stylesheet");
                webControl.Attributes.Add("href", "/Admin/css/region.css");
                webControl.Attributes.Add("type", "text/css");
                webControl.Attributes.Add("media", "screen");
                webControl.ID = "regionStyle";
                this.Controls.Add(webControl);
            }
        }
Ejemplo n.º 13
0
 private static void GetRegions(HttpContext context)
 {
     try
     {
         context.Response.ContentType = "application/json";
         int num = 0;
         int.TryParse(context.Request["parentId"], out num);
         int num2 = 1;
         IDictionary <int, string> dictionary;
         if (num == 0)
         {
             dictionary = RegionHelper.GetAllProvinces(false);
             num2       = 1;
         }
         else
         {
             Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(num, true);
             if (region == null)
             {
                 context.Response.Write("{\"Status\":\"0\"}");
                 goto end_IL_0001;
             }
             num2       = region.Depth + 1;
             dictionary = ((region.Depth != 1) ? ((region.Depth != 2) ? RegionHelper.GetStreets(num, false) : RegionHelper.GetCountys(num, false)) : RegionHelper.GetCitys(num, false));
             if (dictionary == null || dictionary.Count == 0)
             {
                 context.Response.Write("{\"Status\":\"0\"}");
                 goto end_IL_0001;
             }
         }
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append("{");
         stringBuilder.Append("\"Status\":\"OK\",");
         stringBuilder.Append("\"Regions\":[");
         foreach (int key in dictionary.Keys)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"RegionId\":\"{0}\",", key.ToString(CultureInfo.InvariantCulture));
             stringBuilder.AppendFormat("\"RegionName\":\"{0}\"", dictionary[key]);
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
         stringBuilder.Append("]}");
         dictionary.Clear();
         context.Response.Write(stringBuilder.ToString());
         end_IL_0001 :;
     }
     catch (Exception ex)
     {
         context.Response.Write(ex.Message);
     }
 }
Ejemplo n.º 14
0
        private void BuildJson(HttpContext context)
        {
            DateTime      now            = DateTime.Now;
            StringBuilder stringBuilder  = new StringBuilder();
            StringBuilder stringBuilder2 = new StringBuilder();
            StringBuilder stringBuilder3 = new StringBuilder();

            stringBuilder3.Append("{");
            stringBuilder3.Append("\"province\":[");
            int num  = 9;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            IDictionary <int, string> regionArea = this.GetRegionArea();

            foreach (KeyValuePair <int, string> item in regionArea)
            {
                IDictionary <int, string> provinces = RegionHelper.GetProvinces(item.Key, false);
                foreach (KeyValuePair <int, string> item2 in provinces)
                {
                    num++;
                    num2 = 0;
                    if (num > 10)
                    {
                        stringBuilder3.Append(",{");
                    }
                    else
                    {
                        stringBuilder3.Append("{");
                    }
                    stringBuilder3.Append($"\"id\":\"{item2.Key}\",");
                    stringBuilder3.Append($"\"name\":\"{item2.Value}\",");
                    stringBuilder3.Append("\"city\":[");
                    IDictionary <int, string> citys = RegionHelper.GetCitys(item2.Key, false);
                    foreach (KeyValuePair <int, string> item3 in citys)
                    {
                        num2++;
                        if (num2 > 1)
                        {
                            stringBuilder3.Append(",{");
                        }
                        else
                        {
                            stringBuilder3.Append("{");
                        }
                        stringBuilder3.Append($"\"id\":\"{item3.Key}\",");
                        stringBuilder3.Append($"\"name\":\"{item3.Value}\",");
                        stringBuilder3.Append("\"county\":[");
                        num3 = 0;
                        IDictionary <int, string> countys = RegionHelper.GetCountys(item3.Key, false);
                        foreach (KeyValuePair <int, string> item4 in countys)
                        {
                            num3++;
                            if (num3 > 1)
                            {
                                stringBuilder3.Append(",{");
                            }
                            else
                            {
                                stringBuilder3.Append("{");
                            }
                            stringBuilder3.Append($"\"id\":\"{item4.Key}\",");
                            stringBuilder3.Append($"\"name\":\"{item4.Value}\",");
                            stringBuilder3.Append("\"street\":[");
                            num4 = 0;
                            IDictionary <int, string> streets = RegionHelper.GetStreets(item4.Key, false);
                            if (streets != null && streets.Count > 0)
                            {
                                foreach (KeyValuePair <int, string> item5 in streets)
                                {
                                    num4++;
                                    if (num4 > 1)
                                    {
                                        stringBuilder3.Append(",{");
                                    }
                                    else
                                    {
                                        stringBuilder3.Append("{");
                                    }
                                    stringBuilder3.Append($"\"id\":\"{item5.Key}\",");
                                    stringBuilder3.Append($"\"name\":\"{item5.Value}\"");
                                    stringBuilder3.Append("}");
                                }
                            }
                            stringBuilder3.Append("]}");
                        }
                        stringBuilder3.Append("]}");
                    }
                    stringBuilder3.Append("]}");
                }
            }
            stringBuilder3.Append("]}");
            using (StreamWriter streamWriter = File.CreateText(HttpContext.Current.Request.MapPath("/config/region.js")))
            {
                streamWriter.WriteLine(stringBuilder3.ToString());
                streamWriter.Flush();
                streamWriter.Close();
            }
            context.Response.ContentType = "application/json";
            context.Response.Write("{\"Status\":\"true\"}");
        }
Ejemplo n.º 15
0
        protected override void CreateChildControls()
        {
            this.Controls.Clear();
            if (!this.dataLoaded)
            {
                if (!string.IsNullOrEmpty(this.Context.Request.Form["regionSelectorValue"]))
                {
                    this.currentRegionId = new int?(int.Parse(this.Context.Request.Form["regionSelectorValue"]));
                }
                this.dataLoaded = true;
            }
            if (this.currentRegionId.HasValue)
            {
                XmlNode region = RegionHelper.GetRegion(this.currentRegionId.Value);
                if (region != null)
                {
                    if (region.Name == "county")
                    {
                        this.countyId   = new int?(this.currentRegionId.Value);
                        this.cityId     = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                        this.provinceId = new int?(int.Parse(region.ParentNode.ParentNode.Attributes["id"].Value));
                    }
                    else
                    {
                        if (region.Name == "city")
                        {
                            this.cityId     = new int?(this.currentRegionId.Value);
                            this.provinceId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value));
                        }
                        else
                        {
                            if (region.Name == "province")
                            {
                                this.provinceId = new int?(this.currentRegionId.Value);
                            }
                        }
                    }
                }
            }
            this.Controls.Add(RegionSelector.CreateTitleControl(this.ProvinceTitle));
            this.ddlProvinces = this.CreateDropDownList("ddlRegions1");
            RegionSelector.FillDropDownList(this.ddlProvinces, RegionHelper.GetAllProvinces(), this.provinceId);
            this.Controls.Add(RegionSelector.CreateTag("<span>"));
            this.Controls.Add(this.ddlProvinces);
            this.Controls.Add(RegionSelector.CreateTag("</span>"));
            this.Controls.Add(RegionSelector.CreateTitleControl(this.CityTitle));
            this.ddlCitys = this.CreateDropDownList("ddlRegions2");
            if (this.provinceId.HasValue)
            {
                RegionSelector.FillDropDownList(this.ddlCitys, RegionHelper.GetCitys(this.provinceId.Value), this.cityId);
            }
            this.Controls.Add(RegionSelector.CreateTag("<span>"));
            this.Controls.Add(this.ddlCitys);
            this.Controls.Add(RegionSelector.CreateTag("</span>"));

            Dictionary <int, string> dtCountys = new Dictionary <int, string>();

            if (this.cityId.HasValue)
            {
                dtCountys = RegionHelper.GetCountys(this.cityId.Value);
            }

            Label countyTitle = RegionSelector.CreateTitleControl(this.CountyTitle);

            if (dtCountys.Count <= 0)
            {
                countyTitle.Style.Add("display", "none");
            }
            else
            {
                countyTitle.Style.Add("display", "block");
            }
            this.Controls.Add(countyTitle);
            this.ddlCountys = this.CreateDropDownList("ddlRegions3");
            if (this.cityId.HasValue)
            {
                RegionSelector.FillDropDownList(this.ddlCountys, dtCountys, this.countyId);
            }

            if (dtCountys.Count <= 0)
            {
                this.ddlCountys.Style.Add("display", "none");
            }
            else
            {
                this.ddlCountys.Style.Add("display", "block");
            }
            this.Controls.Add(RegionSelector.CreateTag("<span>"));
            this.Controls.Add(this.ddlCountys);
            this.Controls.Add(RegionSelector.CreateTag("</span>"));
        }