/// <summary> /// 根据参数分页取数据 /// </summary> /// <param name="option">参数模型</param> /// <returns>一个DataSet对象</returns> public DataSet GetPageList(Models.PaginModel option) { DataSet ds = new DataSet(); ds = Helper.GetPaginList(option, "[MS_NAV]"); return(ds); }
/// <summary> /// 取得分页的数据 /// </summary> /// <param name="option"></param> /// <param name="table"></param> /// <returns></returns> public static DataSet GetPaginList(Models.PaginModel option, string table) { StringBuilder sql = new StringBuilder(); if (string.IsNullOrWhiteSpace(option.sortStr)) { option.sortStr = "Id desc"; } //默认排序为插入时间 string sqlWhere = " (1=1) "; sql.Append($" select * from ( "); sql.Append($" select ROW_NUMBER() OVER(ORDER BY {option.sortStr}) AS pos,* from ( "); sql.Append($" select * FROM ( "); sql.Append($" select * from ({table}) as x0 "); sql.Append($" ) AS x1 "); if (option.hs != null) //遍历查询条件 { foreach (DictionaryEntry a in option.hs) { sqlWhere += $" and {a.Key} = '{a.Value}' "; } } sql.Append($" ) as x2 where {sqlWhere} "); sql.Append($" ) as x3 where pos between {(option.NowPage - 1) * option.PageSize + 1} and {option.NowPage * option.PageSize} "); return(ExecuteSql(sql.ToString())); }
//此控制器只用于数据请求交互 /// <summary> /// 取得数据字典列表 /// </summary> /// <returns></returns> //[HttpPost] public ActionResult GetClassList(Models.PaginModel option, string name, string code, string type, string state) { if (!string.IsNullOrEmpty(name)) { option.hs.Add("CLASS_NAME", name); } if (!string.IsNullOrEmpty(name)) { option.hs.Add("CLASS_NO", code); } if (!string.IsNullOrEmpty(name)) { option.hs.Add("type", type); } if (!string.IsNullOrEmpty(name)) { option.hs.Add("STATE", state); } if (string.IsNullOrWhiteSpace(option.sortStr)) { option.sortStr = " id desc "; } int count = 0; DataSet ds = BLL.ClassBLL.GetClassList(option, out count); var pagins = new{ count = count, pageSize = option.PageSize, nowPage = option.NowPage, totlePage = (count / option.PageSize) + 1 }; return(Success(ds.Tables[0], pagins)); }
/// <summary> /// 取出所有导航数据 /// </summary> /// <returns></returns> public static DataSet GetClassList(Models.PaginModel option, out int number) { try { return(dal.GetList(option, out number)); } catch (Exception ex) { Error_msg = ex.Message; BaseBLL.ErrorLog("获取导航数据失败", "BLL->ClassBLL->GetClassList", ex); number = 0; return(null); } }
/// <summary> /// 查询数据字典列表 /// </summary> /// <param name="option"></param> /// <param name="number"></param> /// <returns></returns> public DataSet GetList(Models.PaginModel option, out int number) { StringBuilder tableSql = new StringBuilder(); tableSql.Append($" select CONVERT(varchar(20),t1.CREATE_TIME,23) as time,t1.*, "); tableSql.Append($" t2.CLASS_NAME as type,t2.CLASS_CODE ,t2.SORT as big_sort "); tableSql.Append($" ,(case t1.state when 0 then '正常' "); //------状态设置 tableSql.Append($" when 1 then '未启用' "); tableSql.Append($" end) as statusCn "); //---------------// tableSql.Append($" from MS_Class as t1 left join MS_BigClass as t2 on t1.CLASS_ID = t2.ID "); DataSet ds = Helper.GetPaginList(option, tableSql.ToString()); number = Helper.GetCount(option.hs, tableSql.ToString()); return(ds); }