public string LoadAddress(int level, int strNo) { Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(); DataTable dt; string TableName = "Sys_Address1"; if (level == 1) TableName = "Sys_Address2"; else if (level == 2) TableName = "Sys_Address3"; dt = dal.GetAddress(TableName, strNo).Tables[0]; return Js.Com.JsonHelper.Dtb2Json(dt); }
public void GetAddress(int level, int strNo) { Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(); StringBuilder sb = new StringBuilder(); DataTable dt; string TableName = "Sys_Address1"; if (level == 1) TableName = "Sys_Address2"; else TableName = "Sys_Address3"; dt = dal.GetAddress(TableName, strNo).Tables[0]; sb.Append("["); for (int i = 0; i < dt.Rows.Count; i++) { sb.Append("{"); sb.AppendFormat(@"""c_name"":""{0}"",", dt.Rows[i]["Name"]); if(level==1) sb.AppendFormat(@"""c_zipno"":""{0}"",", dt.Rows[i]["ZipNo"]); sb.AppendFormat(@"""c_code"":""{0}""", dt.Rows[i]["SerNo"]); sb.Append("}"); if (i < dt.Rows.Count - 1) { sb.Append(","); } } sb.Append("]"); System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); System.Web.HttpContext.Current.Response.Write(sb.ToString()); }