コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string        getType = Utils.GetQueryStringValue("get");
            StringBuilder sb      = new StringBuilder();
            int           pID     = Utils.GetInt(Utils.GetQueryStringValue("pid"));
            int           cID     = Utils.GetInt(Utils.GetQueryStringValue("cid"));

            switch (getType)
            {
            case "p":
                Eyousoft_yhq.BLL.AreaInfo bllAreaInfo         = new Eyousoft_yhq.BLL.AreaInfo();
                IList <Eyousoft_yhq.Model.MSysProvince> pList = bllAreaInfo.GetSysProvinceList(0, new Eyousoft_yhq.Model.MSysProvince {
                });

                if (pList != null && pList.Count > 0)
                {
                    sb.Append("{\"list\":[");
                    for (int i = 0; i < pList.Count; i++)
                    {
                        sb.Append("{\"id\":\"" + pList[i].ID.ToString() + "\",\"name\":\"" + pList[i].Name + "\"},");
                    }
                    if (sb.Length > 1)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }
                    sb.Append("]}");
                }
                else
                {
                    sb.Append("{\"list\":[]}");
                }

                break;

            case "c":
                Eyousoft_yhq.BLL.AreaInfo           bll   = new Eyousoft_yhq.BLL.AreaInfo();
                IList <Eyousoft_yhq.Model.MSysCity> cList = bll.GetSysCityList(0, new Eyousoft_yhq.Model.MSysCity {
                    ProvinceId = pID
                });
                if (cList != null && cList.Count > 0)
                {
                    sb.Append("{\"list\":[");
                    for (int i = 0; i < cList.Count; i++)
                    {
                        sb.Append("{\"id\":\"" + cList[i].Id.ToString() + "\",\"name\":\"" + cList[i].Name + "\"},");
                    }
                    if (sb.Length > 1)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }
                    sb.Append("]}");
                }
                else
                {
                    sb.Append("{\"list\":[]}");
                }
                break;

            case "x":
                Eyousoft_yhq.BLL.AreaInfo bllarea             = new Eyousoft_yhq.BLL.AreaInfo();
                IList <Eyousoft_yhq.Model.MSysDistrict> xlist = bllarea.GetSysDistrictList(0, new Eyousoft_yhq.Model.MSysDistrict {
                    CityId = cID
                });
                if (xlist != null && xlist.Count > 0)
                {
                    sb.Append("{\"list\":[");
                    for (int i = 0; i < xlist.Count; i++)
                    {
                        sb.Append("{\"id\":\"" + xlist[i].Id.ToString() + "\",\"name\":\"" + xlist[i].Name + "\"},");
                    }
                    if (sb.Length > 1)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }
                    sb.Append("]}");
                }
                else
                {
                    sb.Append("{\"list\":[]}");
                }
                break;
            }

            context.Response.Write(sb.ToString());
        }
コード例 #2
0
ファイル: GetProvinceAndCity.ashx.cs プロジェクト: uwitec/O2O
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string getType = Utils.GetQueryStringValue("get");
            StringBuilder sb = new StringBuilder();
            int pID = Utils.GetInt(Utils.GetQueryStringValue("pid"));
            int cID = Utils.GetInt(Utils.GetQueryStringValue("cid"));
            switch (getType)
            {
                case "p":
                    Eyousoft_yhq.BLL.AreaInfo bllAreaInfo = new Eyousoft_yhq.BLL.AreaInfo();
                    IList<Eyousoft_yhq.Model.MSysProvince> pList = bllAreaInfo.GetSysProvinceList(0, new Eyousoft_yhq.Model.MSysProvince { });

                    if (pList != null && pList.Count > 0)
                    {
                        sb.Append("{\"list\":[");
                        for (int i = 0; i < pList.Count; i++)
                        {
                            sb.Append("{\"id\":\"" + pList[i].ID.ToString() + "\",\"name\":\"" + pList[i].Name + "\"},");
                        }
                        if (sb.Length > 1)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                        sb.Append("]}");
                    }
                    else
                    {
                        sb.Append("{\"list\":[]}");
                    }

                    break;
                case "c":
                    Eyousoft_yhq.BLL.AreaInfo bll = new Eyousoft_yhq.BLL.AreaInfo();
                    IList<Eyousoft_yhq.Model.MSysCity> cList = bll.GetSysCityList(0, new Eyousoft_yhq.Model.MSysCity { ProvinceId = pID });
                    if (cList != null && cList.Count > 0)
                    {
                        sb.Append("{\"list\":[");
                        for (int i = 0; i < cList.Count; i++)
                        {
                            sb.Append("{\"id\":\"" + cList[i].Id.ToString() + "\",\"name\":\"" + cList[i].Name + "\"},");
                        }
                        if (sb.Length > 1)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                        sb.Append("]}");
                    }
                    else
                    {
                        sb.Append("{\"list\":[]}");
                    }
                    break;
                case "x":
                    Eyousoft_yhq.BLL.AreaInfo bllarea = new Eyousoft_yhq.BLL.AreaInfo();
                    IList<Eyousoft_yhq.Model.MSysDistrict> xlist = bllarea.GetSysDistrictList(0, new Eyousoft_yhq.Model.MSysDistrict { CityId = cID });
                    if (xlist != null && xlist.Count > 0)
                    {
                        sb.Append("{\"list\":[");
                        for (int i = 0; i < xlist.Count; i++)
                        {
                            sb.Append("{\"id\":\"" + xlist[i].Id.ToString() + "\",\"name\":\"" + xlist[i].Name + "\"},");
                        }
                        if (sb.Length > 1)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                        sb.Append("]}");
                    }
                    else
                    {
                        sb.Append("{\"list\":[]}");
                    }
                    break;
            }

            context.Response.Write(sb.ToString());
        }