コード例 #1
0
ファイル: country_ajax.ashx.cs プロジェクト: mychun/youcheng
        private void SearchCountry(HttpContext context)
        {
            string condition = DTRequest.GetParamString("condition");
            string value     = string.Empty;

            if (!string.IsNullOrWhiteSpace(condition) && !string.IsNullOrEmpty(siteConfig.countrypath))
            {
                string strCountryPath = HttpContext.Current.Server.MapPath(siteConfig.countrypath);
                if (File.Exists(strCountryPath))
                {
                    DataTable dt = new DataTable("Table");
                    dt.Columns.Add("country_code");
                    dt.Columns.Add("country_cnname");
                    dt.Columns.Add("country_enname");
                    dt.ReadXml(strCountryPath);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        DataTable dtNew = dt.Select(string.Format("country_code='{0}' or country_cnname like '%{0}%' or country_enname like '%{0}%'", Utils.WildEscapes(condition))).CopyToDataTable();
                        value = JsonHelper.DataTableToJSON(dtNew);
                    }
                }
            }
            context.Response.Write(value);
            context.Response.End();
        }
コード例 #2
0
ファイル: country_ajax.ashx.cs プロジェクト: mychun/youcheng
        Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //系统配置信息

        public void ProcessRequest(HttpContext context)
        {
            //取得处事类型
            string action = DTRequest.GetParamString("action");

            switch (action)
            {
            case "GetCountry":     //加载国家
                GetCountry(context);
                break;

            case "SearchCountry":     //查询国家
                SearchCountry(context);
                break;
            }
        }