<!--#include file="system_manage.asp"-->
<%
Dim sid,stitle,scontent,sauthor

   Call DBConnBegin()
	  Set rs = server.createobject("adodb.recordset")
Select Case Request("action")
Case "del"
id=tx_common.checkstr(request.querystring("id"),1)
sql="delete from tx_announce where id="&id
tx_common.execute sql
 Call tx_common.message("·网站公告删除成功<br>·如果你的浏览器不支持跳转，<a href='admin_announce.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_announce.asp'>",1)
  Case "addsave"
	stitle=request.Form("title")
	sauthor=request.Form("author")
	scontent=request.Form("content")
        If stitle="" Or scontent = "" Then Call tx_common.message("·标题或者内容不能为空<meta http-equiv=refresh content='1;URL=admin_announce.asp'>",0)
      'Save
	 rs.open "select tx_title,tx_author,tx_content,tx_time from tx_announce",conn,1,3
	  rs.AddNew
   rs(0) = stitle
   rs(1) = sauthor
   rs(2) = scontent 
   rs(3) = Now()
	  rs.update
	  rs.close
	  Call tx_common.message("·网站公告添加成功<br>·如果你的浏览器不支持跳转，<a href='admin_announce.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_announce.asp'>",1)
  Case "editsave"
  sid=request.Form("id")
stitle=request.Form("title")
	sauthor=request.Form("author")
	scontent=request.Form("content")
        If stitle="" Or scontent = "" Then Call tx_common.message("·标题或者内容不能为空<meta http-equiv=refresh content='1;URL=admin_announce.asp'>",0)
      'Save
	 rs.open "select tx_title,tx_author,tx_content,tx_time from tx_announce where id="&sid,conn,1,3
   rs(0) = stitle
   rs(1) = sauthor
   rs(2) = scontent 
   rs(3) = Now()
	  rs.update
	  rs.close
	  Call tx_common.message("·网站公告更改成功<br>·如果你的浏览器不支持跳转，<a href='admin_announce.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_announce.asp'>",1)
Case "add"
content=tx_tables.formtop("?action=addsave","添加公告")
content =content & tx_tables.inputs("标题","title","text","")
content =content & tx_tables.inputs("作者","author","text","")
content =content & tx_tables.textarea("内容","content","")
content =content & tx_tables.formfoot
Case "edit"
	 rs.open "select id,tx_title,tx_author,tx_content,tx_time from tx_announce where id="&tx_common.checkstr(request.querystring("id"),1),conn,1,3
content = tx_tables.formtop("?action=editsave","更改公告")
content =content & tx_tables.inputhidden("id",rs(0))
content =content & tx_tables.inputs("标题","title","text",rs(1))
content =content & tx_tables.inputs("作者","author","text",rs(2))
content =content & tx_tables.textarea("内容","content",rs(3))
content = content & tx_tables.formfoot
  Case Else

content =  "<table width='100%' cellpadding=3 cellspacing=1 class=td1>"
content = content & "<tr class=td4><td colspan=5><strong>公告列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HRef='?action=add'>发布公告</a></strong></td></tr>"
content =content & "<tr class=td2><td nowap>ID</td><td width='40%'>名称</td><td width='20%'>作者</td><td width='20%'>发布时间</td><td width='10%'>操作</td></tr>"
Set rso=conn.execute("select id,tx_title,tx_author,tx_time from tx_announce order by id desc")
If Not rso.bof And Not rso.eof Then
Do While Not rso.bof And Not rso.eof 
content =content & "<tr class=td2><td>"&rso(0)&"</td><td>"&rso(1)&"</td><td>"&rso(2)&"</td><td>"&rso(3)&"</td><td><a href=?action=edit&id="&rso(0)&">编辑</a> | <a href=?action=del&id="&rso(0)&">删除</a></td></tr>"
rso.movenext
Loop
Else 
content = content & "<tr class=td2><td colspan=5>暂时没有任何公告，请添加！</td></tr>"
End If 
content = content & tx_tables.tablesfoot
rso.close 
End Select
Call ClassEnd()
Call DBConnEnd()
response.write content
Call GetBottom()
%>
