📄 ajaxmethod.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication1
{
/// <summary>
/// Summary description for AjaxMethod.
/// </summary>
public class AjaxMethod
{
#region GetDataSet
public static DataSet GetDataSet(string sql)
{
string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
#region GetPovinceList
public static DataSet GetPovinceList()
{
string sql="select * from povince";
return GetDataSet(sql);
}
#endregion
#region GetCityList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public static string GetCityList(int povinceid)
{
string sql="select * from city where father="+povinceid;
DataSet ds=GetDataSet(sql);
string str="";
for(int m=0;m<ds.Tables[0].Rows.Count;m++)
{
str+=","+ds.Tables[0].Rows[m]["cityID"].ToString()+"|"+ds.Tables[0].Rows[m]["city"].ToString();
}
str=str.Substring(1,str.Length-1);
return str;
}
#endregion
#region GetAreaList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public static string GetAreaList(int cityid)
{
string sql="select * from area where father="+cityid;
DataSet ds=GetDataSet(sql);
string str="";
for(int m=0;m<ds.Tables[0].Rows.Count;m++)
{
str+=","+ds.Tables[0].Rows[m]["areaID"].ToString()+"|"+ds.Tables[0].Rows[m]["area"].ToString();
}
str=str.Substring(1,str.Length-1);
return str;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -