private void GetInfo(string key, string pageIndex, string pageSize, string sortField, string sortOrder) { #region 初始化分页排序信息 SearchCondition cnd = new SearchCondition(); cnd.AllowPaging = true; int index = 1, size = 10; int.TryParse(pageIndex, out index); int.TryParse(pageSize, out size); cnd.CurrentPage = index; cnd.PageSize = size; if (!string.IsNullOrEmpty(sortField)) { cnd.AddSortSql(string.Format("{0} {1}", sortField, sortOrder)); } else { cnd.AddSort("ID"); } #endregion #region 初始化查询条件 if (!string.IsNullOrEmpty(key)) { cnd.AddSearchSql(string.Format("and (Title like '%{0}%' or Description like '%{0}%')", key.Replace("'", "''"))); } #endregion #region 查询数据 SQLHelper sh = SQLHelper.CreateSqlHelper(ConnEnum.Common.ToString()); string sql = string.Format("select * from BusinessUnit where IsDelete=0"); var dt = sh.ExecuteDataTable(SearchCondition.CreatePagerSql(sql, cnd)); var count = sh.ExecuteScalar(SearchCondition.CreateCountSql(sql, cnd)); ArrayList data = CommonTool.DataTable2ArrayList(dt); Hashtable result = new Hashtable(); result["data"] = data; result["total"] = Convert.ToInt32(count); #endregion Response.ContentType = "text/plain"; Response.Write(PluSoft.Utils.JSON.Encode(result)); Response.End(); }