/// <summary> /// 获取国家下拉列表 /// </summary> /// <param name="countryName"></param> /// <param name="Country"></param> /// <returns></returns> public string GetCountrylist(string countryName, string Country) { string s = string.Empty; DataTable dt = new DataTable(); model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext(); s += "<option value=''>请选择</option>"; if (countryName != "") { //var q = from c in context.customsCountry where c.countryName.Contains(countryName) || c.countryNo.Contains(countryName) select c; var q = from c in context.customsCountry where c.countryName.Contains(countryName) || c.countryNo.Contains(countryName) || context.fun_getPY(c.countryName).Contains(countryName) select c; dt = LinqToDataTable.LINQToDataTable(q.OrderBy(a => a.countryNo)); for (int i = 0; i < dt.Rows.Count; i++) { s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>"; } } else { dt = DbHelperSQL.Query(@"select * from customsCountry order by countryNo").Tables[0]; if (Country == "") { for (int i = 0; i < dt.Rows.Count; i++) { s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>"; } } else { for (int i = 0; i < dt.Rows.Count; i++) { if (Country.Contains(dt.Rows[i]["countryNo"].ToString())) { s += "<option value='" + dt.Rows[i]["countryNo"] + "' selected='selected'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>"; } else { s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>"; } } } } return(s); }