<%
action=RequestSafeStr("action")
Select Case action
Case "add"
Call add()
Case "save"
Call save()
Case "edit"
Call edit()
Case "editsave"
Call editSave()
Case "del"
Call del()
Case "delall"
Call delall()
Case "top"
Call top()
Case else
Call show()
End Select
%>
<%
Sub save()
title=RequestFormStr("title")
categoryid=RequestFormNum("categoryid")
content=RequestFormStr("content")
password=RequestFormStr("password")
If title="" Then
Call MessageBox("请输入标题!","")
Response.End
End If
If content="" Then
Call MessageBox("请输入内容!","")
Response.End
End If
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from comment"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("categoryid")=categoryid
rs("content")=content
rs("password")=password
rs.update
rs.close
Call MessageBox("添加评论成功!","comment.asp")
End Sub
Sub editSave()
id=RequestFormNum("id")
If id<>0 then
title=RequestFormStr("title")
content=RequestFormStr("content")
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from comment Where id="& id &""
rs.open sql,conn,2,3
If Not rs.eof then
rs("title")=title
rs("content")=content
rs.update
End If
rs.close
Call MessageBox("修改评论成功!","comment.asp")
End If
End Sub
'del
Sub del()
id=RequestQueryNum("id")
If id<>0 Then
conn.Execute("delete From comment Where id="& id &"")
Call MessageBox("删除成功!","comment.asp")
End If
End Sub
'delall
Sub delall()
id=RequestFormStr("id")
If id="" Then
Call MessageBox("请选择一项!","")
Response.end
End If
'response.write id
'response.end
conn.Execute("delete From comment Where id in ("& id &")")
Call MessageBox("删除成功!","comment.asp")
End Sub
'top
Sub top()
id=RequestQueryNum("id")
intTop=RequestQueryNum("top")
If id<>0 Then
conn.Execute("Update comment set [top]="& intTop &",toptime=Now() Where id="& id &"")
If intTop=1 Then
strMsg="置顶成功!"
Else
strMsg="取消置顶成功!"
End If
Call MessageBox(strMsg,"comment.asp")
End If
End Sub
Sub show()
rid=RequestQueryNum("rid")
If rid<>0 Then
sql="Select * From comment Where reid="& rid &"by order id desc"
Else
sql="Select * From comment order by id desc"
End If
Set mypage=new xdownpage '创建对象
mypage.getconn=conn '得到数据库连接
mypage.getsql=sql
mypage.pagesize=20 '设置每一页的记录条数据为5条
set rs=mypage.getrs() '返回Recordset
%>
<%
End Sub
Sub add()
%>
<%
End Sub
Sub edit()
id=RequestQueryNum("id")
Set rs=conn.Execute("Select * From comment Where id="& id &"")
If Not rs.eof Then
%>