示例#1
0
        public static string GetDataList(string Name, string GradeTerm, string Subject, string Syllabus, string Test_Category, int PageIndex, int PageSize)
        {
            try
            {
                BLL_S_TestingPoint bll        = new BLL_S_TestingPoint();
                DataTable          dt         = new DataTable();
                List <object>      listReturn = new List <object>();
                string             strWhere   = " Parent_Id='0' ";//考点
                if (!string.IsNullOrEmpty(Name))
                {
                    strWhere += " and (TPName like '%" + Name.Filter() + "%' or TPCode like '%" + Name.Filter() + "%') ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and GradeTerm='" + GradeTerm.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Subject='" + Subject.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Syllabus='" + Syllabus.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Test_Category='" + Test_Category.Filter() + "' ";
                }

                dt = bll.GetListByPageJoinDict(strWhere, "TPCode", ((PageIndex - 1) * PageSize + 1), (PageIndex * PageSize)).Tables[0];
                int       rCount = bll.GetRecordCount(strWhere);
                DataTable dtAll  = bll.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow[] drSub = dtAll.Select("Parent_Id='" + dt.Rows[i]["S_TestingPoint_Id"].ToString() + "'");
                    listReturn.Add(new
                    {
                        S_KnowledgePoint_Id = dt.Rows[i]["S_TestingPoint_Id"].ToString(),
                        Parent_Id           = dt.Rows[i]["Parent_Id"].ToString().Trim(),
                        KPName      = string.IsNullOrEmpty(dt.Rows[i]["TPNameBasic"].ToString()) ? dt.Rows[i]["TPName"].ToString() : dt.Rows[i]["TPNameBasic"].ToString(),
                        KPCode      = dt.Rows[i]["TPCode"].ToString(),
                        KPLevel     = dt.Rows[i]["TPLevel"].ToString(),
                        KPLevelName = dt.Rows[i]["TPLevelName"].ToString(),
                        parentIdStr = "",
                        paddingLeft = "",
                        hasChildren = drSub.Length,
                        IsLast      = dt.Rows[i]["IsLast"].ToString(),
                    });
                }

                if (dt.Rows.Count > 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 = ex.Message.ToString()
                }));
            }
        }