欢迎光临爱时尚女性网
 

asp简单的ajax留言板

2012-6-24 编辑:knwz 来源:爱时尚女性网 阅读次数:830
  导读: index.asp 客户留言 BLL_Guest.asp DAL_Guest.asp MOD_Guest.asp 1 Then parms=Array(Pageurl,1) lFirstpage = Format(C_FIRSTPAGE1,parms) parms=Array(Pageurl,CInt(CurrentPage)-1) lPrevpage = ...

index.asp
<%@ codepage=65001%>
<%
option explicit
%>
<% Response.Charset="utf-8"%>
<% session.CodePage=65001 %>





<%
燚im mybll
燚im myList
燬et mybll = new BLL_Guest
燬elect Case Request("tCMD")
Case "SAVE"
爉ybll.Insert()
Case "DEL"
爉ybll.Delete()
燛nd Select
爉yList = mybll.FindByPage()
%>

客户留言








<%=myList%>


BLL_Guest.asp
<%
'///
'/// 摘要说明。
'///

燙lass BLL_Guest
燩Rivate mycom,mymod,mydal

Private LI,UL

Private DEL

'获取信息
Public Sub GetGuest()

爉ydal.GetGuest(Id)

End Sub

'新增信息
Public Sub Insert()

爉ymod.Content = Request("content")
爉ymod.re = Request("Re")
爉ymod.Addtime = Now()
爉ymod.ip = request.servervariables("HTTP_X_FORWARDED_FOR")
營f len(mymod.Ip)<=0 Then mymod.Ip = request.servervariables("REMOTE_ADDR")

燙all mydal.Insert(mymod)

End Sub

'更新信息
Public Sub Update()

燙all mydal.Update(mymod)

End Sub

'删除信息
Public Sub Delete()

爉ydal.Delete(Request("Id"))

End Sub

'查找信息
Public Function FindByPage()

燚im PageSize,CurrentPage,WhereValue,OrderValue,RecordCount
燚im objRS
燚im tmp1,tmp2,tmp3,parms,i
燚im tCMD
爐CMD = Request("tCMD")
燩ageSize = "8"
燙urrentPage = Request("PageNo")
營f Len(CurrentPage)<=0 Then
CurrentPage=1
燛nd If
燱hereValue = ""
燨rderValue = "Id"
燬et objRS = mydal.FindByPage(PageSize,CurrentPage-1,WhereValue,OrderValue)
爄 = 1
燫ecordCount = mydal.Count(WhereValue)
燚o While Not objRS.EOF
If tCMD="DEL" Then
燚EL = "删除"
Else
燚EL = ""
End If
parms=Array(i,objRS("content"),objRS("ip"),objRS("addtime"),DEL)
tmp1 = tmp1 & mycom.Format(LI,parms)
objRs.Movenext
i = i + 1
燣oop
爐mp3 = mycom.Page(PageSize,CurrentPage,RecordCount,"guest/index.asp?tCMD=LIST")
爌arms=Array(tmp1,tmp3)
爐mp2 = tmp2 & mycom.Format(UL,parms)

燜indByPage = tmp2

End Function

Private Sub Class_Initialize()

燣I = "
  • {0} {1}
    作者:{2} {3} {4}
  • " & vbCrLf
    燯L = "
      {0}
    • {1}
    "
    燚EL = ""

    燬et mycom = new Common
    爏et mymod = new MOD_Guest
    爏et mydal = new DAL_Guest

    End Sub

    Private Sub Class_Terminate()

    燬et mycom = Nothing
    燬et mymod = Nothing
    爏et mydal = Nothing

    End Sub

    燛nd Class
    %>

    DAL_Guest.asp
    <%
    '///
    '/// 摘要说明。
    '///

    燙lass DAL_Guest

    Private SQL_01
    Private SQL_02
    Private SQL_03
    Private SQL_04
    Private SQL_05
    Private SQL_06
    Private SQL_07

    Private mycom,myacc,mymod

    '///
    '/// 获得信息
    '///

    '/// 判断字段
    '/// 信息体
    Public Function GetGuest(Id)

    燚im parms,SQL,objRS
    爌arms = Array(Id)
    燬QL = mycom.Format(SQL_01,parms)
    燬et objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
    營f 燦ot objRS.EOF then
    Call mymod.SetVar(objRs("Id"),objRs("Content"),objRs("Re"),objRs("Addtime"),objRs("Ip"))
    Set GetGuest = mymod
    燛lse
    GetGuest = Null
    燛nd If

    End Function

    '///
    '/// 插入信息
    '///

    '/// 信息体
    Public Sub Insert(vmod)

    燚im parms,SQL
    爌arms = Array(vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
    燬QL = mycom.Format(SQL_02,parms)
    燙all myacc.ExecuteReader(myacc.CONN_STRING,SQL)

    End Sub

    '///
    '/// 更新信息
    '///

    '/// 信息体
    Public Sub Update(vmod)

    燚im parms,SQL
    爌arms = Array(vmod.Id,vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
    燬QL = mycom.Format(SQL_03,parms)
    燙all myacc.ExecuteReader(myacc.CONN_STRING,SQL)

    End Sub

    '///
    '/// 删除信息
    '///

    '/// 信息体
    Public Sub Delete(Id)

    燚im parms,SQL
    爌arms = Array(Id)
    燬QL = mycom.Format(SQL_04,parms)
    燙all myacc.ExecuteNonQuery(myacc.CONN_STRING,SQL)

    End Sub

    '///
    '/// 统计信息
    '///

    '/// 信息体
    Public Function Count(WhereValue)

    燚im parms,SQL,objRS
    爌arms = Array(WhereValue)
    燬QL = mycom.Format(SQL_07,parms)
    燬et objRS = myacc.Recordset(myacc.CONN_STRING,SQL)
    燙ount = objRS.RecordCount

    End Function

    '///
    '/// 根据条件列出所有信息(带有分页)
    '///

    '/// 每页记录数
    '/// 页码
    '/// 判断值
    '/// 排序
    '/// 返回objRS
    Public Function FindByPage(PageSize,CurrentPage,WhereValue,OrderValue)

    燚im parms,SQL,objRS
    燚im s1
    營f CurrentPage="0" Then 牋
    s1 = 燩ageSize & "|" + OrderValue & "|" & WhereValue
    parms = Split(s1,"|")
    SQL = mycom.Format(SQL_05,parms)
    燛lse
    s1 = PageSize & "|" & OrderValue & "|" + WhereValue & "|" & CurrentPage*PageSize
    parms = Split(s1,"|")
    SQL = mycom.Format(SQL_06,parms)
    燛nd If

    燬et objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
    燬et FindByPage = objRS

    End Function

    Private Sub Class_Initialize()

    燬QL_01 = "Select * From [Guest] Where Id = {0}"
    燬QL_02 = "Insert into [Guest] ([Content],[Re],[Addtime],[Ip]) values('{0}','{1}','{2}','{3}')"
    燬QL_03 = "Update [Guest] Set [Content]='{1}',[Re]='{2}',[Addtime]='{3}',[Ip]='{4}' Where Id = {0}"
    燬QL_04 = "Delete From [Guest] Where Id In ({0})"
    燬QL_05 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc"
    燬QL_06 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' And Id Not IN(Select Top {3} Id From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc) Order By {1} Desc,Id Desc"
    燬QL_07 = "Select * From [Guest] Where Content Like '%{0}%' "

    燬et mycom = new Common
    燬et myacc = new AccHelper
    燬et mymod = new MOD_Guest

    End Sub

    Private Sub Class_Terminate()

    燬et mycom = Nothing
    燬et myacc = Nothing
    燬et mymod = Nothing

    End Sub

    燛nd Class
    %>

    MOD_Guest.asp
    <%
    '///
    '/// 摘要说明。
    '///

    燙lass MOD_Guest

    Public Id
    Public Content
    Public Re
    Public Addtime
    Public Ip

    Public Sub SetVar(vId,vContent,vRe,vAddtime,vIp)
    營d=vId
    燙ontent=vContent
    燫e=vContent
    燗ddtime=vAddtime
    營p=vIp
    End Sub

    燛nd Class
    %>

    Common.asp
    <%
    '///
    '/// 摘要说明
    '///

    燙lass Common

    '///
    '/// 获得信息
    '///

    '/// 需要内容
    '/// 替换关键字
    '/// 格式化后内容
    Public Function Format(str,arr)

    燚im r,i
    爎 = str 牋
    燜or i = 0 To UBound(arr)
    r = Replace(r,"{"&i&"}",arr(i))
    燦ext
    燜ormat = r

    End Function

    Public Function Page(PageSize,CurrentPage,RecordCount,PageUrl)

    燾onst C_RECORDCOUNT = "合计{0}篇 |"
    燾onst C_FIRSTPAGE1 = " 首页"
    燾onst C_FIRSTPAGE2 = " 首页"
    燾onst C_PREVPAGE1 = " 上一页"
    燾onst C_PREVPAGE2 = " 上一页"
    燾onst C_NEXTPAGE1 = " 下一页"
    燾onst C_NEXTPAGE2 = " 下一页"
    燾onst C_LASTPAGE1 = " 尾页"
    燾onst C_LASTPAGE2 = " 尾页"
    燾onst C_CURRENTPAGE = " 页次:{0}/{1}页"
    燾onst C_PAGESIZE = " {0}篇/页  "
    燾onst C_GOTOPAGE = " 跳转:
    '/// AccHelper 的摘要说明。
    '///
    燙lass AccHelper

    Public CONN_STRING

    '///
    '/// 执行ExecuteNonQuery
    '///

    '/// 连接字符
    '/// sql命令
    Public Function ExecuteNonQuery(connString,cmdText)

    燚im objConn
    燬et objConn = Server.CreateObject("ADODB.Connection")
    爋bjConn.Open connString
    爋bjConn.Execute(cmdText)

    End Function

    '///
    '/// 执行ExecuteReader
    '///

    '/// 连接字符
    '/// sql命令
    '/// RS
    Public Function ExecuteReader(connString,cmdText)

    燚im objConn,objRS
    燬et objConn = Server.CreateObject("ADODB.Connection")
    爋bjConn.Open connString
    燬et objRS = objConn.Execute(cmdText)
    燬et ExecuteReader = objRS

    End Function


    '///
    '/// 执行Recordset
    '///

    '/// 连接字符
    '/// sql命令
    '/// RS
    Public Function Recordset(connString,cmdText)

    燚im objConn,objRS
    燬et objConn = Server.CreateObject("ADODB.Connection")
    爋bjConn.Open connString
    燬et objRS = Server.CreateObject("ADODB.RecordSet")
    爋bjRS.Open cmdText,objConn,1,3
    燬et Recordset = objRS

    End Function

    Private Sub Class_Initialize()
    燙ONN_STRING = "provider = microsoft.jet.oledb.4.0;data source=" & Server.Mappath("db.mdb")
    End Sub

    燛nd Class
    %>

    文章出自:爱时尚女性网www.aspjc.com,尊重版权是美德,转载请保留原地址,感谢合作!

     
     
    链接交换请联系:QQ:790646582 首页链接要求百度快照在一周以内,不符合以上要求的各站,我们将定期把友情连接转入内页,谢谢合作。
    Copyright @ 2012-2015 爱时尚女性网 保留所有权利吉ICP备14005127号-1 服务QQ:175529508 e-mail:zk8312@163.com
    本站部分资源来自网友上传,如果无意之中侵犯了您的版权,请联系本站,本站将在3个工作日内删除。