create procedure [dbo].[sp_systemquotationrevisionpaging]
(
@clientid nvarchar(255),
@clientmodel nvarchar(255),
@collection nvarchar(255),
@startindexpage int,
@endindexpage int,
@count int output
)
as
select
*
from
(select row_number() over(order by createddate desc) as row,* from quotationrevision
where
upper(clientid) like @clientid +'%'
and upper(clientmodel) like @clientmodel +'%'
and (upper([collection]) like '%'+@collection +'%'
or
(@collection = '' and [collection] is null))
) quotationrevision
where row between (@endindexpage-1)*@startindexpage+1 and @endindexpage*@startindexpage
set @count=(select count(*) from quotationrevision
where
upper(clientid) like @clientid+'%'
and upper(clientmodel) like @clientmodel+'%'
and (upper([collection]) like '%'+@collection +'%'
or
(@collection = '' and [collection] is null))
)
return
go
gridview ;
protected sub btnsearch_click(byval sender as object, byval e as eventargs) handles btnsearch.click
generatedata()
end sub
private sub generatedata()
dim currentpage as integer
if request.querystring("currentpage") is nothing then
currentpage = 1
else
currentpage = cint(request.querystring("currentpage"))
end if
dim strengcode as string = txtclientid.text.trim
dim strerpcode as string = txtclientmodel.text.trim
dim strdescription as string = txtcollection.text.trim
dim pengcode as new sqlclient.sqlparameter("@clientid", sqldbtype.nvarchar)
dim perpcode as new sqlclient.sqlparameter("@clientmodel", sqldbtype.nvarchar)
dim pdescription as new sqlclient.sqlparameter("@collection", sqldbtype.nvarchar)
dim ppagesize as new sqlclient.sqlparameter("@startindexpage", sqldbtype.int)
dim pcurrentpage as new sqlclient.sqlparameter("@endindexpage", sqldbtype.int)
dim pcount as new sqlclient.sqlparameter("@count", sqldbtype.int)
pengcode.value = strengcode.toupper()
perpcode.value = strerpcode.toupper()
pdescription.value = strdescription.toupper()
ppagesize.value = 10
pcurrentpage.value = currentpage
pcount.direction = parameterdirection.output
dim da as new wmo.appobjects.dataaccess
dim conn as sqlclient.sqlconnection = da.conn
dim cmd as new sqlclient.sqlcommand("sp_systemquotationrevisionpaging", conn)
cmd.commandtype = commandtype.storedprocedure
cmd.parameters.add(pengcode)
cmd.parameters.add(perpcode)
cmd.parameters.add(pdescription)
cmd.parameters.add(ppagesize)
cmd.parameters.add(pcurrentpage)
cmd.parameters.add(pcount)
conn.open()
dim reader as sqlclient.sqldatareader = cmd.executereader()
gv_quotationid.datasource = reader
gv_quotationid.databind()
reader.close()
conn.close()
dim count as integer = cint(cmd.parameters("@count").value)
generatepaging(currentpage, 10, 5, count)
end sub
private sub generatepaging(byval currentpage as integer, byval pagesize as integer, byval maxpage as integer, byval count as integer)
dim querystring as string
if request.querystring.count > 0 then
dim indexcurentpage as integer = request.url.absoluteuri.indexof("currentpage")
if indexcurentpage <> -1 then
querystring = request.url.absoluteuri.substring(0, indexcurentpage)
else
querystring = request.url.absoluteuri + "&"
end if
else
querystring = request.url.absoluteuri + "?"
end if
dim pagecount as integer
if count mod pagesize > 0 then
pagecount = math.floor(count / pagesize) + 1
else
pagecount = math.floor(count / pagesize)
end if
if pagecount > 1 then
dim scopenumber = math.floor((currentpage - 1) / maxpage)
dim startnumber as integer = scopenumber * maxpage + 1
dim endnumber as integer
if ((scopenumber + 1) * maxpage) < pagecount then
endnumber = (scopenumber + 1) * maxpage
else
endnumber = pagecount
end if
dim table as new table()
dim tr as new tablerow
'pre page
if currentpage > 1 then
dim td as new tablecell
dim href as new hyperlink
href.text = "上一頁www.111cn.net"
href.navigateurl = querystring + "currentpage=" + (currentpage - 1).tostring()
td.controls.add(href)
tr.controls.add(td)
end if
'pre more
if scopenumber > 0 then
dim td as new tablecell
dim href as new hyperlink
href.text = "..."
href.navigateurl = querystring + "currentpage=" + ((scopenumber - 1) * maxpage + 1).tostring()
td.controls.add(href)
tr.controls.add(td)
end if
'middle
for i as integer = startnumber to endnumber
dim td as new tablecell
dim href as new hyperlink
href.text = i
if i <> currentpage then
href.navigateurl = querystring + "currentpage=" + i.tostring()
else
href.css教程class = "currentpage"
end if
td.controls.add(href)
tr.controls.add(td)
next
'last more
if endnumber < pagecount then
dim td as new tablecell
dim href as new hyperlink
href.text = "..."
href.navigateurl = querystring + "currentpage=" + (endnumber + 1).tostring()
td.controls.add(href)
tr.controls.add(td)
end if
'last number
if endnumber <> pagecount then
dim td as new tablecell
dim href as new hyperlink
href.text = pagecount.tostring()
href.navigateurl = querystring + "currentpage=" + pagecount.tostring()
td.controls.add(href)
tr.controls.add(td)
end if
'last page
if currentpage < pagecount then
dim td as new tablecell
dim href as new hyperlink
href.text = "下一頁"
href.navigateurl = querystring + "currentpage=" + (currentpage + 1).tostring()
td.controls.add(href)
tr.controls.add(td)
end if
'go
dim html = "<a id='lnkpage' style='display:none;'></a>到第<input id='txtpageno' size='1' onblur='setpage()' />頁<input type='button' value='http://www.111cn.net確定' onclick='gopage()' />"
dim tdgo as new tablecell
tdgo.text = html
tr.controls.add(tdgo)
table.controls.add(tr)
divpaging.controls.add(table)
end if
end sub