ASP鑒앴돎꾸鱗잚

2018-09-06 13:11

阅读:794

  <%

ProgrammingBySmartpig

ClassTBGrid
publicDataSource鑒앴都
publicstyle깊목悧루목
publicHeadStyle깊庫루목
publicHeadItemStyle깊庫데뗌루목
publicitemStyle데禱목뗌접貢쭹
publicHeadSort깊庫角뤠鞫刻탤埼묘콘
publicColumns矜狼鞫刻돨죗禱羹
publicAlternate角뤠슥競루목
publicAlternateStyle탉鑒契루목
publicNormalStyle攣끽루목
publicDefaultStyle칵훰루목닢
publicPageSize女댕鬼
publicAllowPageing角뤠롸女
publicPageingStyle女鑒루목

PrivateTemplates菱땍屢데禱淃
privateCurPage뎠품女
privatePageStart女충역迦頓契珂쇌

코휭裂쇌돨밑溝
Columns.addField,HeadText
AddTemplate(HeadText,Template)
itemStyle.addField,style:adsasd
HeadSort.addField,True
DataSource(Columns.Keys(i))

PrivateSubClass_Initialize?阮?nbsp;Initialize慤숭。
SetitemStyle=CreateObject(Scripting.Dictionary)
SetHeadSort=CreateObject(Scripting.Dictionary)
SetHeadItemStyle=CreateObject(Scripting.Dictionary)
SetColumns=CreateObject(Scripting.Dictionary)
SetTemplates=CreateObject(Scripting.Dictionary)
SetDataSource=CreateObject(ADODB.Recordset)
Alternate=0
PageStart=Timer
EndSub

PrivateSubClass_Terminate?阮?nbsp;Terminate慤숭。
SetitemStyle=Nothing
SetHeadSort=Nothing
SetHeadItemStyle=Nothing
SetColumns=Nothing
SetDataSource=Nothing
EndSub

PrivateSubInitTable()
SetRowsNum=DataSource.RecordCount
ifColumns.Count=0then
Fori=0toDataSource.Fields.Count-1
response.Write(DataSource.Fields(i).Name)
Next
endif

ifIsEmpty(Style)andIsEmpty(NormalStyle)then
DefaultStyle=1
Else
DefaultStyle=Style
endif

CurPage=CInt(Request.QueryString(page))
ifCurPage=then
CurPage=1
EndIf

ifPageSize=Emptythen
PageSize=10
endif

selectCaseDefaultStyle
Case1
Style=align=centerborder=0cellpadding=4cellspacing=1bgcolor=#cccccc
Alternate=1
HeadStyle=Height=25style=background-color:#006699;color:#ffffff
AlternateStyle=bgColor=#ffffffheight=25
NormalStyle=height=25bgcolor=#f5f5f5
AllowPageing=true
tbGrid1.PageingStyle=bgcolor=#f5f5f5align=right
Case2
Style=align=centerborder=0cellpadding=4cellspacing=1bgcolor=#cccccc
Alternate=0
HeadStyle=Height=25style=background-color:#ffffff
AlternateStyle=bgColor=#ffffffheight=25
NormalStyle=height=25bgcolor=#ffffff
CaseElse
EndSelect
Endsub

publicSubAddTemplate(ByValColumnName,ByValTemplate)
Columns.addColumnName,ColumnName
Templates.addColumnName,Template
EndSub

publicSubShow()
InitTable()
DimtableStr
DimtdStart,tdEnd,tbStyle,tbContent
DimcurRow
Dimclm
DimregEx,Match,Matches
tableStr=<table&style&>&vbCrLF
DrawTableHead
Response.Write(tableStr)
Response.Write(<tr>)
forEachclminColumns.Keys()
tbStyle=HeadStyle&&HeadItemStyle(clm)
tdStart=<th&tbStyle&>
tdEnd=</th>&vbCrLf

Response.Write(tdStart)
속흙깊庫탤埼묘콘
CodebyRedsun
Date:2005-1-17
IfHeadSort(clm)Then
Response.WriteSort(clm,Columns(clm))
Else
Response.Write(Columns(clm))
EndIf
Response.Write(tdEnd)
Next
Response.Write(</tr>&vbCrLF)

DrawTableitems
curRow=1
ifAllowPageing<>Emptythen
DataSource.PageSize=PageSize
else
DataSource.PageSize=DataSource.RecordCount
endif

ifCurPage<1then
DataSource.AbsolutePage=1
endif

ifCurPage>=DataSource.PageCountthen
DataSource.AbsolutePage=DataSource.PageCount
endif

ifCurPage>=1andCurPage<=DataSource.PageCountthen
DataSource.AbsolutePage=CurPage
endif

forcurRow=1toDataSource.PageSize
ifDataSource.EOFthen
ExitFor
endif

Response.Write(<tr>)
forEachclminColumns.Keys()
ifAlternate=0then
tbStyle=NormalStyle&&ItemStyle(clm)
else
ifcurRowmod2=0then
tbStyle=AlternateStyle&&ItemStyle(clm)
else
tbStyle=NormalStyle&&ItemStyle(clm)
endif
endif

tdStart=<td&tbStyle&>
tdEnd=</td>&vbCrLf

ifTemplates(clm)=Emptythen
tbContent=DataSource(clm)
else
tbContent=Templates(clm)
SetregEx=NewRegExp
regEx.Pattern={[A-Za-z0-9_-]+}
regEx.IgnoreCase=True
regEx.Global=True
SetMatches=regEx.Execute(Templates(clm))
Foreachmatchinmatches
OnErrorResumeNext
tbContent=Replace(tbContent,Match.Value,DataSource(Mid(Match.Value,2,Len(Match.Value)-2)),1)
Next

endif

Response.Write(tdStart)
Response.Write(tbContent)
Response.Write(tdEnd)
Next
Response.Write(</tr>&vbCrLF)

DataSource.MoveNext
Next

DrawPageingRow
ifDataSource.PageCount>1andLCase(pageingStyle)<>nonethen
Dimi,EndPage,StartPage
response.write(<tr>)
response.write(<tdcolspan=&Columns.Count&&PageingStyle&>)
맣쏵롸女묘콘
CodebyRedsun
Date:2005-1-17
IfCurPage>4Then
IfCurPage+2<DataSource.PageCountThen
StartPage=CurPage-2
EndPage=CurPage+2
Else
StartPage=DataSource.PageCount-4
EndPage=DataSource.PageCount
EndIf
Else
StartPage=1
IfDataSource.PageCount>5Then
EndPage=5
Else
EndPage=DataSource.PageCount
EndIf
EndIf
IfCurPage>1Then
Response.Write<atitle=看女href=&GetUrl(page)&page=1><fontface=webdings>9</font></a>
Response.Write<atitle=?菊?href=&GetUrl(page)&page=&CurPage-1&><fontface=webdings>3</font></a>
Else
Response.Write<fontface=webdings>9</font>
Response.Write<fontface=webdings>3</font>
EndIf
Fori=StartPagetoEndPage
ifi<>CurPagethen
response.write(<atitle=뒤&i&女href=&GetUrl(page)&page=&i&>&i&</a>)
Else
response.write(<b>&i&</b>)
Endif
next
IfCurPage<DataSource.PageCountThen
Response.Write<atitle=苟女href=&GetUrl(&page&)&page=&CurPage+1&><fontface=webdings>4</font></a>
Response.Write<atitle=棺女href=&GetUrl(&page&)&page=&DataSource.PageCount&><fontface=webdings>:</font></a>
Else
Response.Write<fontface=webdings>4</font>
Response.Write<fontface=webdings>:</font>
EndIf
Response.Write[묾&DataSource.RecordCount&係][&PageSize&係/女][묾&DataSource.PageCount&女]
Response.WritePageExecute:&Round((Timer-PageStart)*1000,2)&MS
response.write(</td></tr>&vbCrLf)
Endif
DrawTableend
Response.Write(</table>)
Endsub

====================================================================
삿혤뎠품Url꽝鑒돨변鑒
CodeingbyRedsun
====================================================================
PrivateFunctionGetUrl(RemoveList)
DimScriptAddress,M_ItemUrl,M_item
ScriptAddress=CStr(Request.ServerVariables(SCRIPT_NAME))&?혤돤뎠품뒈囹
M_ItemUrl=
ForEachM_itemInRequest.QueryString
IfInStr(RemoveList,M_Item)=0Then
M_ItemUrl=M_ItemUrl&M_Item&=&Server.URLEncode(Request.QueryString(&M_Item&))&&
EndIf
Next
GetUrl=ScriptAddress&M_ItemUrl
EndFunction


=============================
茄君죗깊탤埼
럿쀼Url꽝鑒깻땡檄맣긴탤埼렘駕
꽝鑒:矜狼쏵契탤埼돨俚뙈츰,鞫刻돨츰냔
=============================
PrivateFunctionSort(SortStr,DispName)
IfSortStr=OrDispName=ThenExitFunction
Sort=GetUrl(SOrder,SSort)
SSort=UCase(Request.QueryString(SSort))
IfSSort=DESCThen
SSort=ASC
Else
SSort=DESC
EndIf
Sort=<aclass=headhrefhref=&Sort&SOrder=&SortStr&&SSort=&SSort&>&DispName&SortType(SortStr)&</a>
EndFunction

-----------------------------------------------
깃街탤埼죗槨?虧蜘믐퓰둔脂십?
꽝鑒:탤埼죗俚뙈츰냔
-----------------------------------------------
PrivateFunctionSortType(FieldName)
DimSOrderName
SOrderName=Request.QueryString(SOrder)
IfSOrderName<>FieldNameThenExitFunction
DimSSortImg
SSortImg=Request.QueryString(SSort)
SortType=<imgsrc=/OrderFormSystem/images/&SSortImg&.gifborder=0>
EndFunction

EndClass


usersLike{UserID,LoginName,Password,RealName,Age,Gender,}
initDB
Rs.OpenSelect*fromusers,Cn
DimtbGrid1
SettbGrid1=NewTBGrid
SettbGrid1.DataSource=Rs
tbGrid1.Columns.addLoginName,痰빵츰
tbGrid1.HeadSort.addLoginName,True
tbGrid1.Columns.addPassword,쵱쯤
tbGrid1.AddTemplate錦맣,<ahref=aaa.asp?id={UserID}><fontcolor=red>{RealName}</font></a>
tbGrid1.ItemStyle.addPassword,align=right
tbGrid1.ItemStyle.add錦맣,width=100
tbGrid1.PageSize=5
tbGrid1.AllowPageing=true
tbGrid1.PageingStyle=align=right
tbGrid1.Show()
CloseDB
%>



评论


亲,登录后才可以留言!