public static string GetDataList(string UserGroup_ParentId, string GradeId, string GroupName, int PageSize, int PageIndex) { try { BLL_UserGroup_Member bll = new BLL_UserGroup_Member(); UserGroup_ParentId = UserGroup_ParentId.Filter(); GradeId = GradeId.Filter(); GroupName = GroupName.Filter(); DataTable dt = new DataTable(); List <object> listReturn = new List <object>(); string strWhere = " User_ApplicationStatus='passed' "; if (!string.IsNullOrEmpty(UserGroup_ParentId)) { strWhere += " and UserGroup_Id='" + UserGroup_ParentId + "' "; } if (!string.IsNullOrEmpty(GradeId)) { strWhere += " and UserGroup_Id='" + GradeId + "' "; } if (!string.IsNullOrEmpty(GroupName)) { strWhere += " and ClassName like '%" + GroupName + "%' "; } string orderBy = string.Format("charindex(MembershipEnum,'{0},{1},{2}'),ClassName,UserStatus,User_ApplicationPassTime desc" , MembershipEnum.gradedirector, MembershipEnum.GroupLeader, MembershipEnum.classrc); dt = bll.GetGradeMemberListByPageForSys(strWhere, orderBy, ((PageIndex - 1) * PageSize + 1), (PageIndex * PageSize)).Tables[0]; int rCount = bll.GetGradeMemberRecordCountForSys(strWhere); int inum = 0; for (int i = 0; i < dt.Rows.Count; i++) { string userName = dt.Rows[i]["ClassName"].ToString(); if (string.IsNullOrEmpty(userName)) { userName = dt.Rows[i]["UserName"].ToString(); } if (dt.Rows[i]["MembershipEnum"].ToString() != MembershipEnum.classrc.ToString()) { userName += "(" + dt.Rows[i]["UserName"].ToString() + ")"; } inum++; string strMemberCount = dt.Rows[i]["MemberCount"].ToString(); if (strMemberCount == "0") { strMemberCount = "-"; } listReturn.Add(new { inum = (i + 1), ParentUserGroup_Name = dt.Rows[i]["ParentUserGroup_Name"].ToString(), UserGroup_Id = dt.Rows[i]["User_Id"].ToString(), UserGroup_Name = userName, ClassUser = dt.Rows[i]["ClassUser"].ToString(), UserGroup_BriefIntroduction = dt.Rows[i]["UserGroup_BriefIntroduction"].ToString(), ClassCreateTime = pfunction.ConvertToLongDateTime(dt.Rows[i]["ClassCreateTime"].ToString()), GroupMemberCount = strMemberCount, MembershipEnum = dt.Rows[i]["MembershipEnum"], PostName = dt.Rows[i]["PostName"] }); } if (inum > 0) { return(JsonConvert.SerializeObject(new { err = "null", PageIndex = PageIndex, PageSize = PageSize, TotalCount = rCount, list = listReturn })); } else { return(JsonConvert.SerializeObject(new { err = "暂无数据" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { err = "error"//ex.Message.ToString() })); } }