Esempio n. 1
0
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columns">要取的列名(逗号分开)</param>
        /// <param name="order">排序</param>
        /// <param name="pageSize">每页大小</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="where">查询条件</param>
        /// <param name="totalCount">总记录数</param>
        public string GetPager(string tableName, string columns, string order, int pageSize, int pageIndex, string where, out int totalCount)
        {
            DataTable dt = SqlPagerHelper.GetPager(tableName, columns, order, pageSize, pageIndex, where, out totalCount);

            dt.Columns.Add(new DataColumn("UserRoleId"));
            dt.Columns.Add(new DataColumn("UserRole"));
            dt.Columns.Add(new DataColumn("UserDepartmentId"));
            dt.Columns.Add(new DataColumn("UserDepartment"));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataTable dtrole       = new RoleBLL().GetRoleByUserId(Convert.ToInt32(dt.Rows[i]["ID"]));
                DataTable dtdepartment = new DepartmentBLL().GetDepartmentByUserId(Convert.ToInt32(dt.Rows[i]["ID"]));
                dt.Rows[i]["UserRoleId"]       = JsonHelper.ColumnToJson(dtrole, 0);
                dt.Rows[i]["UserRole"]         = JsonHelper.ColumnToJson(dtrole, 1);
                dt.Rows[i]["UserDepartmentId"] = JsonHelper.ColumnToJson(dtdepartment, 0);
                dt.Rows[i]["UserDepartment"]   = JsonHelper.ColumnToJson(dtdepartment, 1);
            }
            return(JsonHelper.ToJson(dt));
        }