📄 pagination.cs
字号:
//频道管理
protected string[] manage_channel_class_list ={ "id", "id,ChID,ParentID,OrderID,classCName,classEName,isPage,isLock,isDelPoint", "sys_channelclass where ParentID=@ParentID and ChID=@ChID", "order by OrderID desc,id DESC" };
protected string[] manage_channel_Special_list ={ "id", "id,ChID,ParentID,OrderID,specialCName,specialEName,isRec,isLock", "sys_channelspecial where ParentID=@ParentID and ChID=@ChID", "order by OrderID desc,id DESC" };
//自定义表单管理
protected string[] manage_sys_customform ={ "id", "id,formname,formtablename,memo", "customform", "order by id DESC" };
//自定义表单字段
protected string[] manage_sys_customform_item ={ "id", "id,formid,seriesnumber,fieldname,itemname,itemtype,case isnotnull when 1 then '是' else '否' end as notnull", "customform_item where formid=@formid", "order by seriesnumber" };
/// <summary>
/// 获取SQL语句
/// </summary>
/// <param name="PageName"></param>
/// <returns></returns>
protected string[] GetSqlSentence(string PageName)
{
string PageType = PageName.Substring(0, PageName.Length - 5);
FieldInfo fi = this.GetType().GetField(PageType, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);
if (fi == null)
throw new Exception("没有找到SQL");
return (string[])fi.GetValue(this);
}
/// <summary>
/// 执行分页
/// </summary>
/// <param name="PageName"></param>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <param name="RecordCount"></param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition"></param>
/// <returns></returns>
public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
try
{
string[] Sql = GetSqlSentence(PageName);
string IndexField = Sql[0];
string AllFields = Sql[1];
string Condition = Sql[2];
string OrderFields = Sql[3];
Condition = Pre + Condition;
if (Condition.ToLower().IndexOf(" join ") > 0)
Condition = Condition.Replace(" join ", " join " + Pre);
List<SqlParameter> param = new List<SqlParameter>();
if (SqlCondition != null && SqlCondition.Length > 0)
{
int n = SqlCondition.Length;
for (int i = 0; i < n; i++)
{
if (SqlCondition[i].name != null && SqlCondition[i].name != string.Empty)
{
SqlParameter p = new SqlParameter(SqlCondition[i].name, SqlDbType.Variant);
p.Value = SqlCondition[i].value;
param.Add(p);
}
}
}
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param.ToArray());
}
catch (SqlException e)
{
throw e;
}
catch (Exception e)
{
throw new Exception("用于分页的SQL语句无效:" + e.Message);
}
}
/// <summary>
/// 以附加SQL语句分页
/// </summary>
/// <param name="PageName"></param>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <param name="RecordCount"></param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition"></param>
/// <param name="blur"></param>
/// <returns></returns>
public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount,bool blur, params SQLConditionInfo[] SqlCondition)
{
try
{
string[] Sql = GetSqlSentence(PageName);
string IndexField = Sql[0];
string AllFields = Sql[1];
string Condition = Sql[2];
string OrderFields = Sql[3];
Condition = Pre + Condition;
if (Condition.ToLower().IndexOf(" join ") > 0)
Condition = Condition.Replace(" join ", " join " + Pre);
List<SqlParameter> param = new List<SqlParameter>();
if (SqlCondition != null && SqlCondition.Length > 0)
{
int n = SqlCondition.Length;
for (int i = 0; i < n; i++)
{
if (SqlCondition[i].name != null && SqlCondition[i].name != string.Empty)
{
SqlParameter p = new SqlParameter(SqlCondition[i].name, SqlDbType.Variant);
p.Value = SqlCondition[i].value;
param.Add(p);
}
}
}
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param.ToArray());
}
catch (SqlException e)
{
throw e;
}
catch (Exception e)
{
throw new Exception("用于分页的SQL语句无效:" + e.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -