复制代码 代码如下:
<%@codepage=65001%>
<%
optionexplicit
%>
<%Response.Charset="utf-8"%>
<%Session.CodePage=65001%>
<>
<>
<>
<>
<>
<%
Dimmybll
DimmyList
Setmybll=newBLL_Guest
SelectCaseRequest("tCMD")
Case"SAVE"
mybll.Insert()
Case"DEL"
mybll.Delete()
EndSelect
myList=mybll.FindByPage()
%>
<h2>客户留言</h2>
<p>
<formname="subForm"id="subForm">
<textareaid="con"name="con"cols="56"rows="6"wrap="VIRTUAL"></textarea>
<inputtype="button"name="submit"value="提交留言"onclick="$('guest/index.asp?tCMD=SAVE&content='+escape(this.form.con.value))"/>
</form>
</p>
<%=myList%>
BLL_Guest.asp
<%
'///<summary>
'///摘要说明。
'///</summary>
ClassBLL_Guest
Privatemycom,mymod,mydal
PrivateLI,UL
PrivateDEL
'获取信息
PublicSubGetGuest()
mydal.GetGuest(Id)
EndSub
'新增信息
PublicSubInsert()
mymod.Content=Request("content")
mymod.re=Request("Re")
mymod.Addtime=Now()
mymod.Ip=request.servervariables("HTTP_X_FORWARDED_FOR")
Iflen(mymod.Ip)<=0Thenmymod.Ip=request.servervariables("REMOTE_ADDR")
Callmydal.Insert(mymod)
EndSub
'更新信息
PublicSubUpdate()
Callmydal.Update(mymod)
EndSub
'删除信息
PublicSubDelete()
mydal.Delete(Request("Id"))
EndSub
'查找信息
PublicFunctionFindByPage()
DimPageSize,CurrentPage,WhereValue,OrderValue,RecordCount
DimobjRS
Dimtmp1,tmp2,tmp3,parms,i
DimtCMD
tCMD=Request("tCMD")
PageSize="8"
CurrentPage=Request("PageNo")
IfLen(CurrentPage)<=0Then
CurrentPage=1
EndIf
WhereValue=""
OrderValue="Id"
SetobjRS=mydal.FindByPage(PageSize,CurrentPage-1,WhereValue,OrderValue)
i=1
RecordCount=mydal.Count(WhereValue)
DoWhileNotobjRS.EOF
IftCMD="DEL"Then
DEL="<ahref=""?tCMD=DEL&Id="&objRS("Id")&""">删除</a>"
Else
DEL=""
EndIf
parms=Array(i,objRS("content"),objRS("ip"),objRS("addtime"),DEL)
tmp1=tmp1&mycom.Format(LI,parms)
objRs.Movenext
i=i+1
Loop
tmp3=mycom.Page(PageSize,CurrentPage,RecordCount,"guest/index.asp?tCMD=LIST")
parms=Array(tmp1,tmp3)
tmp2=tmp2&mycom.Format(UL,parms)
FindByPage=tmp2
EndFunction
PrivateSubClass_Initialize()
LI="<li><span>{0}</span><span>{1}</span><br/><span>作者:{2}</span><span>{3}</span><span>{4}</span></li>"&vbCrLf
UL="<UL>{0}<li>{1}</li></UL>"
DEL=""
Setmycom=newCommon
setmymod=newMOD_Guest
setmydal=newDAL_Guest
EndSub
PrivateSubClass_Terminate()
Setmycom=Nothing
Setmymod=Nothing
setmydal=Nothing
EndSub
EndClass
%>
DAL_Guest.asp
<%
'///<summary>
'///摘要说明。
'///</summary>
ClassDAL_Guest
PrivateSQL_01
PrivateSQL_02
PrivateSQL_03
PrivateSQL_04
PrivateSQL_05
PrivateSQL_06
PrivateSQL_07
Privatemycom,myacc,mymod
'///<summary>
'///获得信息
'///</summary>
'///<paramname="Id">判断字段</param>
'///<returns>信息体</returns>
PublicFunctionGetGuest(Id)
Dimparms,SQL,objRS
parms=Array(Id)
SQL=mycom.Format(SQL_01,parms)
SetobjRS=myacc.ExecuteReader(myacc.CONN_STRING,SQL)
IfNotobjRS.EOFthen
Callmymod.SetVar(objRs("Id"),objRs("Content"),objRs("Re"),objRs("Addtime"),objRs("Ip"))
SetGetGuest=mymod
Else
GetGuest=Null
EndIf
EndFunction
'///<summary>
'///插入信息
'///</summary>
'///<paramname="">信息体</param>
PublicSubInsert(vmod)
Dimparms,SQL
parms=Array(vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL=mycom.Format(SQL_02,parms)
Callmyacc.ExecuteReader(myacc.CONN_STRING,SQL)
EndSub
'///<summary>
'///更新信息
'///</summary>
'///<paramname="">信息体</param>
PublicSubUpdate(vmod)
Dimparms,SQL
parms=Array(vmod.Id,vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL=mycom.Format(SQL_03,parms)
Callmyacc.ExecuteReader(myacc.CONN_STRING,SQL)
EndSub
'///<summary>
'///删除信息
'///</summary>
'///<paramname="">信息体</param>
PublicSubDelete(Id)
Dimparms,SQL
parms=Array(Id)
SQL=mycom.Format(SQL_04,parms)
Callmyacc.ExecuteNonQuery(myacc.CONN_STRING,SQL)
EndSub
'///<summary>
'///统计信息
'///</summary>
'///<paramname="">信息体</param>
PublicFunctionCount(WhereValue)
Dimparms,SQL,objRS
parms=Array(WhereValue)
SQL=mycom.Format(SQL_07,parms)
SetobjRS=myacc.Recordset(myacc.CONN_STRING,SQL)
Count=objRS.RecordCount
EndFunction
'///<summary>
'///根据条件列出所有信息(带有分页)
'///</summary>
'///<paramname="PageSize">每页记录数</param>
'///<paramname="CurrentPage">页码</param>
'///<paramname="WhereValue">判断值</param>
'///<paramname="OrderValue">排序</param>
'///<returns>返回objRS</returns>
PublicFunctionFindByPage(PageSize,CurrentPage,WhereValue,OrderValue)
Dimparms,SQL,objRS
Dims1
IfCurrentPage="0"Then
s1=PageSize&"|"+OrderValue&"|"&WhereValue
parms=Split(s1,"|")
SQL=mycom.Format(SQL_05,parms)
Else
s1=PageSize&"|"&OrderValue&"|"+WhereValue&"|"&CurrentPage*PageSize
parms=Split(s1,"|")
SQL=mycom.Format(SQL_06,parms)
EndIf
SetobjRS=myacc.ExecuteReader(myacc.CONN_STRING,SQL)
SetFindByPage=objRS
EndFunction
PrivateSubClass_Initialize()
SQL_01="Select*From[Guest]WhereId={0}"
SQL_02="Insertinto[Guest]([Content],[Re],[Addtime],[Ip])values('{0}','{1}','{2}','{3}')"
SQL_03="Update[Guest]Set[Content]='{1}',[Re]='{2}',[Addtime]='{3}',[Ip]='{4}'WhereId={0}"
SQL_04="DeleteFrom[Guest]WhereIdIn({0})"
SQL_05="SelectTop{0}*From[Guest]WhereContentLike'%{2}%'OrderBy{1}Desc,IdDesc"
SQL_06="SelectTop{0}*From[Guest]WhereContentLike'%{2}%'AndIdNotIN(SelectTop{3}IdFrom[Guest]WhereContentLike'%{2}%'OrderBy{1}Desc,IdDesc)OrderBy{1}Desc,IdDesc"
SQL_07="Select*From[Guest]WhereContentLike'%{0}%'"
Setmycom=newCommon
Setmyacc=newAccHelper
Setmymod=newMOD_Guest
EndSub
PrivateSubClass_Terminate()
Setmycom=Nothing
Setmyacc=Nothing
Setmymod=Nothing
EndSub
EndClass
%>
MOD_Guest.asp
<%
'///<summary>
'///摘要说明。
'///</summary>
ClassMOD_Guest
PublicId
PublicContent
PublicRe
PublicAddtime
PublicIp
PublicSubSetVar(vId,vContent,vRe,vAddtime,vIp)
Id=vId
Content=vContent
Re=vContent
Addtime=vAddtime
Ip=vIp
EndSub
EndClass
%>
Common.asp
<%
'///<summary>
'///摘要说明
'///</summary>
ClassCommon
'///<summary>
'///获得信息
'///</summary>
'///<paramname="Id">需要内容</param>
'///<paramname="Id">替换关键字</param>
'///<returns>格式化后内容</returns>
PublicFunctionFormat(str,arr)
Dimr,i
r=str
Fori=0ToUBound(arr)
r=Replace(r,"{"&i&"}",arr(i))
Next
Format=r
EndFunction
PublicFunctionPage(PageSize,CurrentPage,RecordCount,PageUrl)
constC_RECORDCOUNT="合计<STRONG><FONTcolor=""red"">{0}</FONT></STRONG>篇|"
constC_FIRSTPAGE1="<ahref=""#""onclick=""$('{0}&PageNo={1}')"">首页</a>"
constC_FIRSTPAGE2="首页"
constC_PREVPAGE1="<ahref=""#""onclick=""$('{0}&PageNo={1}')"">上一页</a>"
constC_PREVPAGE2="上一页"
constC_NEXTPAGE1="<ahref=""#""onclick=""$('{0}&PageNo={1}')"">下一页</a>"
constC_NEXTPAGE2="下一页"
constC_LASTPAGE1="<ahref=""#""onclick=""$('{0}&PageNo={1}')"">尾页</a>"
constC_LASTPAGE2="尾页"
constC_CURRENTPAGE="页次:<STRONG><FONTcolor=""red"">{0}</FONT>/{1}</STRONG>页"
constC_PAGESIZE="<STRONG>{0}</STRONG>篇/页"
constC_GOTOPAGE="跳转:<inputtype=""text""name=""goto""value=""{1}""onchange=""$('{0}&PageNo='+this.value)""style=""width:20px;border:1px""/>"
DimPageCount,pages
DimlRecordCount,lFirstpage,lPrevpage,lNextpage,lLastpage,lCurrentpage,lPagesize,lGotopage
Dimp,parms
IfRecordCountModPageSize<>0Then
pages=1
else
pages=0
EndIf
PageCount=CInt(RecordCount/PageSize+pages)
parms=Array(RecordCount)
lRecordCount=Format(C_RECORDCOUNT,parms)
ifCInt(CurrentPage)>1Then
parms=Array(Pageurl,1)
lFirstpage=Format(C_FIRSTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)-1)
lPrevpage=Format(C_PREVPAGE1,parms)
Else
lFirstpage=C_FIRSTPAGE2
lPrevpage=C_PREVPAGE2
EndIf
ifCInt(CurrentPage)<PageCountThen
parms=Array(Pageurl,CInt(CurrentPage)+1)
lNextpage=Format(C_NEXTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)+1)
lLastpage=Format(C_LASTPAGE1,parms)
Else
lNextpage=C_NEXTPAGE2
lLastpage=C_LASTPAGE2
EndIf
parms=Array(CurrentPage,PageCount)
lCurrentpage=Format(C_CURRENTPAGE,parms)
parms=Array(PageSize)
lPagesize=Format(C_PAGESIZE,parms)
parms=Array(Pageurl,CurrentPage)
lGotopage=Format(C_GOTOPAGE,parms)
p=lRecordCount&lFirstpage&lPrevpage&lNextpage&lLastpage&lCurrentpage&lPagesize&lGotopage
Page=p
EndFunction
EndClass
%>
AccHelper.asp
<%
'///<summary>
'///AccHelper的摘要说明。
'///</summary>
ClassAccHelper
PublicCONN_STRING
'///<summary>
'///执行ExecuteNonQuery
'///</summary>
'///<paramname="connString">连接字符</param>
'///<paramname="cmdText">sql命令</param>
PublicFunctionExecuteNonQuery(connString,cmdText)
DimobjConn
SetobjConn=Server.CreateObject("ADODB.Connection")
objConn.OpenconnString
objConn.Execute(cmdText)
EndFunction
'///<summary>
'///执行ExecuteReader
'///</summary>
'///<paramname="connString">连接字符</param>
'///<paramname="cmdText">sql命令</param>
'///<returns>RS</returns>
PublicFunctionExecuteReader(connString,cmdText)
DimobjConn,objRS
SetobjConn=Server.CreateObject("ADODB.Connection")
objConn.OpenconnString
SetobjRS=objConn.Execute(cmdText)
SetExecuteReader=objRS
EndFunction
'///<summary>
'///执行Recordset
'///</summary>
'///<paramname="connString">连接字符</param>
'///<paramname="cmdText">sql命令</param>
'///<returns>RS</returns>
PublicFunctionRecordset(connString,cmdText)
DimobjConn,objRS
SetobjConn=Server.CreateObject("ADODB.Connection")
objConn.OpenconnString
SetobjRS=Server.CreateObject("ADODB.RecordSet")
objRS.OpencmdText,objConn,1,3
SetRecordset=objRS
EndFunction
PrivateSubClass_Initialize()
CONN_STRING="provider=microsoft.jet.oledb.4.0;datasource="&Server.Mappath("db.mdb")
EndSub
EndClass
%>