Using System.Data;
Using System.Data.SqlClient;
Using Microsoft.ApplicationBlocks.Data;
Using System.Web;
Using System.Web.UI;
Namespace Rsslayer.pagehelper
{
/**////<summary>
A summary description of the paging class Pagerhelper.
</summary>
public class Pagerhelper
{
private string connectionString;
Public Pagerhelper (String tblname,string sortname,bool docount,string connectionString)
{
This.tblname = tblname;
This.fldname = Sortname;
this.connectionstring = connectionString;
This.docount = Docount;
}
Public Pagerhelper (String Tblname,bool docount,
String Strgetfields, String Fldname,int pagesize,
int Pageindex,bool ordertype,string strwhere,string connectionString
)
{
This.tblname = tblname;
This.docount = Docount;
This.strgetfields = Strgetfields;
This.fldname = Fldname;
This.pagesize = pagesize;
This.pageindex = pageindex;
This.ordertype = OrderType;
This.strwhere = strwhere;
this.connectionstring = connectionString;
}
/**////<summary>
Get the constructor of the recordset
</summary>
<param name= "Tblname" ></param>
<param name= "Strwhere" ></param>
<param name= "ConnectionString" ></param>
Public Pagerhelper (String tblname,string strwhere,string connectionString)
{
This.tblname = tblname;
This.strwhere = strwhere;
This.docount = true;
this.connectionstring = connectionString;
}
private string tblname;
public string Tblname
{
Get{return Tblname;}
Set{tblname =value;}
}
private String strgetfields= "*";
public string Strgetfields
{
Get{return Strgetfields;}
Set{strgetfields =value;}
}
private string fldname=string. Empty;
public string Fldname
{
Get{return Fldname;}
Set{fldname =value;}
}
private int pagesize = 10;
public int PageSize
{
Get{return pagesize;}
Set{pagesize =value;}
}
private int pageindex = 1;
public int PageIndex
{
Get{return pageindex;}
Set{pageindex =value;}
}
private bool Docount=false;
public bool Docount
{
Get{return Docount;}
Set{docount =value;}
}
private bool Ordertype=false;
public bool OrderType
{
Get{return OrderType;}
Set{ordertype =value;}
}
private string strwhere=string. Empty;
public string strwhere
{
Get{return strwhere;}
Set{strwhere =value;}
}
Public IDataReader Getdatareader ()
{
if (This.docount)
{
throw new ArgumentException ("To return the Recordset, the Docount property must be false");
}
System.Web.HttpContext.Current.Response.Write (pageindex);
Return Sqlhelper.executereader (connectionstring,commandtype.storedprocedure, "pagination",
New SqlParameter ("@tblName", This.tblname),
New SqlParameter ("@strGetFields", This.strgetfields),
New SqlParameter ("@fldName", This.fldname),
New SqlParameter ("@PageSize", This.pagesize),
New SqlParameter ("@PageIndex", This.pageindex),
New SqlParameter ("@doCount", This.docount),
New SqlParameter ("@OrderType", This.ordertype),
New SqlParameter ("@strWhere", This.strwhere)
);
}
Public DataSet GetDataSet ()
{
if (This.docount)
{
throw new ArgumentException ("To return the Recordset, the Docount property must be false");
}
Return SqlHelper.ExecuteDataset (connectionstring,commandtype.storedprocedure, "pagination",
New SqlParameter ("@tblName", This.tblname),
New SqlParameter ("@strGetFields", This.strgetfields),
New SqlParameter ("@fldName", This.fldname),
New SqlParameter ("@PageSize", This.pagesize),
New SqlParameter ("@PageIndex", This.pageindex),
New SqlParameter ("@doCount", This.docount),
New SqlParameter ("@OrderType", This.ordertype),
New SqlParameter ("@strWhere", This.strwhere)
);
}
public int GetCount ()
{
if (!this.docount)
{
throw new ArgumentException ("to return the total count, the Docount attribute must be true");
}
return (int) sqlhelper.executescalar (connectionstring,commandtype.storedprocedure, "pagination",
New SqlParameter ("@tblName", This.tblname),
New SqlParameter ("@strGetFields", This.strgetfields),
New SqlParameter ("@fldName", This.fldname),
New SqlParameter ("@PageSize", This.pagesize),
New SqlParameter ("@PageIndex", This.pageindex),
New SqlParameter ("@doCount", This.docount),
New SqlParameter ("@OrderType", This.ordertype),
New SqlParameter ("@strWhere", This.strwhere)
);
}
}
}
|