<% @ Page Language = "C #" %>
<% @ Import namespace = "system. Data" %>
<% @ Import namespace = "system. Data. sqlclient" %>
<SCRIPT runat = "server">
Protected void page_load (Object sender, eventargs E)
{
Int intpageno, intpagesize, intpagecount;
Intpagesize = 25;
If (request ["currentpage"] = NULL)
{
Intpageno = 1;
}
Else
{
Intpageno = int32.parse (request ["currentpage"]);
}
Sqlconnection mysqlconnection = new sqlconnection ("Server = (local); database = test; user id = sa; Password ="
Sqlcommand mysqlcommand = new sqlcommand ("up_gettopiclist", mysqlconnection );
Mysqlcommand. commandtype = commandtype. storedprocedure;
Sqlparameter workparm;
// Search for table fields separated ","
Workparm = mysqlcommand. Parameters. Add ("@ a_tablelist", sqldbtype. varchar, 200 );
Mysqlcommand. Parameters ["@ a_tablelist"]. value = "offerid, type, offertime ";
// Search for the table name
Workparm = mysqlcommand. Parameters. Add ("@ a_tablename", sqldbtype. varchar, 30 );
Mysqlcommand. Parameters ["@ a_tablename"]. value = "Offer ";
// Search criteria, for example, "select * from AA where a = 1 and B = 2 and C = 3", the condition is "where a = 1 and B = 2 and C = 3"
Workparm = mysqlcommand. Parameters. Add ("@ a_selectwhere", sqldbtype. varchar, 500 );
Mysqlcommand. Parameters ["@ a_selectwhere"]. value = "where type = 'idl '";
// Table primary key field name, which must be int type
Workparm = mysqlcommand. Parameters. Add ("@ a_selectorderid", sqldbtype. varchar, 50 );
Mysqlcommand. Parameters ["@ a_selectorderid"]. value = "offerid ";
// Sorting, multi-field sorting can be used, but the primary key field must be at the beginning
Workparm = mysqlcommand. Parameters. Add ("@ a_selectorder", sqldbtype. varchar, 50 );
Mysqlcommand. Parameters ["@ a_selectorder"]. value = "order by offerid DESC ";
// Page number
Workparm = mysqlcommand. Parameters. Add ("@ a_intpageno", sqldbtype. INT );
Mysqlcommand. Parameters ["@ a_intpageno"]. value = intpageno;
// Number of entries displayed on each page
Workparm = mysqlcommand. Parameters. Add ("@ a_intpagesize", sqldbtype. INT );
Mysqlcommand. Parameters ["@ a_intpagesize"]. value = intpagesize;
// Total number of records (Stored Procedure output parameters)
Workparm = mysqlcommand. Parameters. Add ("@ recordcount", sqldbtype. INT );
Workparm. Direction = parameterdirection. output;
// Number of records on the current page (Stored Procedure return value)
Workparm = mysqlcommand. Parameters. Add ("rowcount", sqldbtype. INT );
Workparm. Direction = parameterdirection. returnvalue;
Mysqlconnection. open ();
Repeater. datasource = mysqlcommand. executereader ();
Repeater. databind ();
Mysqlconnection. Close ();
Int32 recordcount = (int32) mysqlcommand. Parameters ["@ recordcount"]. value;
Int32 rowcount = (int32) mysqlcommand. Parameters ["rowcount"]. value;
Labelrecord. Text = recordcount. tostring ();
Labelrow. Text = intpageno. tostring ();
Intpagecount = recordcount/intpagesize;
If (recordcount % intpagesize)> 0)
Intpagecount + = 1;
Labelpage. Text = intpagecount. tostring ();
If (intpageno> 1)
{
Hlfistpage. navigateurl = "Select. aspx? Currentpage = 1 ";
Hlprevpage. navigateurl = string. Concat ("Select. aspx? Currentpage = "," ", intPageNo-1 );
}
Else
{
Hlfistpage. navigateurl = "";
Hlprevpage. navigateurl = "";
// Hlfistpage. Enabled = false;
// Hlprevpage. Enabled = false;
}
If (intpageno <intpagecount)
{
Hlnextpage. navigateurl = string. Concat ("Select. aspx? Currentpage = "," ", intpageno + 1 );
Hlendpage. navigateurl = string. Concat ("Select. aspx? Currentpage = "," ", intpagecount );
}
Else
{
Hlnextpage. navigateurl = "";
Hlendpage. navigateurl = "";
// Hlnextpage. Enabled = false;
// Hlendpage. Enabled = false;
}
}
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Link href = "/style.css" rel = "stylesheet"/>
<Style type = "text/CSS">
. High {font-family: ""; font-size: 9pt; line-Height: 140%}
. Mid {font-size: 9pt; line-Height: 12pt}
. Small {font-size: 9pt; line-Height: normal}
. Tp10_5 {
Font-size: 14px;
Line-Height: 140%;
}
</Style>
<Style type = "text/CSS"> A: link {
Color: # cc6666
}
</Style>
<Form runat = "server">
<SPAN class = "high"> NO. <font color = "# cc0000"> <asp: label id = "labelrow" runat = "server"/> </font> page | Total <asp: Label id = "labelpage" runat = "server"/> pages
| <Asp: Label id = "labelrecord" runat = "server"/> information |
<Asp: hyperlink id = "hlfistpage" text = "Homepage" runat = "server"/>
| <Asp: hyperlink id = "hlprevpage" text = "Previous Page" runat = "server"/>
| <Asp: hyperlink id = "hlnextpage" text = "next page" runat = "server"/>
| <Asp: hyperlink id = "hlendpage" text = "last page" runat = "server"/> </span> <br>
<Asp: repeater id = repeater runat = "server">
<Headertemplate>
<Table width = "583" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD bgcolor = "#000000"> <Table width = "100%" border = "0" cellpadding = "4" cellspacing = "1" class = "tp10_5">
<Tr bgcolor = "#999999" type = "codeph" text = "/codeph">
<TD align = "center"> <strong> <font color = "# ffffff"> Order No. </font> </strong> </TD>
<TD align = "center"> <strong> <font color = "# ffffff"> service project </font> </strong> </TD>
<TD align = "center"> <strong> <font color = "# ffffff"> reservation date </font> </strong> </TD>
<TD align = "center"> <strong> <font color = "# ffffff"> operator </font> </strong> </TD>
<TD align = "center"> <strong> <font color = "# ffffff"> allocation status </font> </strong> </TD>
<TD> <Div align = "center"> </div> </TD>
</Tr>
</Headertemplate>
<Itemtemplate>
<Tr align = "center" bgcolor = "# ffffff" class = "small" onmouseover = 'this. style. background = "# cccccc" 'onmouseout = 'this. style. background = "# ffffff" '>
<TD> <% # databinder. eval (container. dataitem, "offerid" %> </TD>
<TD> <% # databinder. eval (container. dataitem, "type" %> </TD>
<TD> <% # databinder. eval (container. dataitem, "offertime" %> </TD>
<TD> </TD>
<TD> </TD>
<TD> <a href = "javascript: void (window. Open ('info. asp? Id = <% # databinder. eval (container. dataitem, "offerid" %> ', 'order allocation', 'height = 600, width = 1000') "> order details </a> </TD>
</Tr>
</Itemtemplate>
<Footertemplate>
</Table> </TD>
</Tr>
</Table>
</Footertemplate>
</ASP: repeater>
</Form>
--------------------------------------------------------------------------------
Up_gettopiclist. SQL
--------------------------------------------------------------------------------
Create proc up_gettopiclist
@ A_tablelist varchar (200 ),
@ A_tablename varchar (30 ),
@ A_selectwhere varchar (500 ),
@ A_selectorderid varchar (20 ),
@ A_selectorder varchar (50 ),
@ A_intpageno int,
@ A_intpagesize int,
@ Recordcount int output
As
/* Define local variables */
Declare @ intbeginid int
Declare @ intendid int
Declare @ introotrecordcount int
Declare @ introwcount int
Declare @ tmpselect nvarchar (600)
/* Disable counting */
Set nocount on
/* Calculate the total number of root stickers */
Select @ tmpselect = 'set nocount on; select @ spintrootrecordcount = count (*) from '+ @ a_tablename + ''+ @ a_selectwhere
Execute sp_executesql
@ Tmpselect,
N' @ spintrootrecordcount int output ',
@ Spintrootrecordcount = @ introotrecordcount output
Select @ recordcount = @ introotrecordcount
If (@ introotrecordcount = 0) -- if there is no post, zero is returned.
Return 0
/* Determine whether the page number is correct */
If (@ a_intpageno-1) * @ a_intpagesize> @ introotrecordcount
Return (-1)
/* Start the rootid */
Set @ introwcount = (@ a_intpageno-1) * @ a_intpagesize + 1
/* Limit the number of entries */
Select @ tmpselect = 'set nocount on; Set rowcount @ spintrowcount; select @ spintbeginid = '+ @ a_selectorderid + 'from' + @ a_tablename + ''+ @ a_selectwhere +'' + @ a_selectorder
Execute sp_executesql
@ Tmpselect,
N' @ spintrowcount int, @ spintbeginid int output ',
@ Spintrowcount = @ introwcount, @ spintbeginid = @ intbeginid output
/* End the rootid */
Set @ introwcount = @ a_intpageno * @ a_intpagesize
/* Limit the number of entries */
Select @ tmpselect = 'set nocount on; Set rowcount @ spintrowcount; select @ spintendid = '+ @ a_selectorderid + 'from' + @ a_tablename + ''+ @ a_selectwhere +'' + @ a_selectorder
Execute sp_executesql
@ Tmpselect,
N' @ spintrowcount int, @ spintendid int output ',
@ Spintrowcount = @ introwcount, @ spintendid = @ intendid output
If @ a_selectwhere = 'or @ a_selectwhere is null
Select @ tmpselect = 'set nocount off; Set rowcount 0; select '+ @ a_tablelist + 'from' + @ a_tablename + 'where' + @ a_selectorderid + 'between'
Else
Select @ tmpselect = 'set nocount off; Set rowcount 0; select '+ @ a_tablelist + 'from' + @ a_tablename + ''+ @ a_selectwhere +' and '+ @ a_selectorderid + 'between'
If @ intendid> @ intbeginid
Select @ tmpselect = @ tmpselect + '@ spintbeginid and @ spintendid' + ''+ @ a_selectorder
Else
Select @ tmpselect = @ tmpselect + '@ spintendid and @ spintbeginid' + ''+ @ a_selectorder
Execute sp_executesql
@ Tmpselect,
N'@ spintendid int, @ spintbeginid int ',
@ Spintendid = @ intendid, @ spintbeginid = @ intbeginid
Return (@ rowcount)
-- Select @ rowcount
Go