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

   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_main where id="&id
tx_common.execute sql
 Call tx_common.message("·文章删除成功<br>·如果你的浏览器不支持跳转，<a href='admin_mainindex.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_mainindex.asp'>",1)
  Case "addsave"
  postid=request("id")
	smainindex=request.Form("mainindex")
	ssortid=request.Form("sortid")
	scontent=request.Form("content")
        If  scontent = "" Then Call tx_common.message("·内容不能为空<meta http-equiv=refresh content='1;URL=admin_mainindex.asp'>",0)
      'Save
	  If postid<>"" Then 
	   rs.open "select mainindex,content,sortid from tx_main where id="&postid,conn,1,3
	 else
	 rs.open "select mainindex,content,sortid from tx_main",conn,1,3
	  rs.AddNew
	  End If 
   rs(0) = smainindex
   rs(1) = scontent
   rs(2) = ssortid 
	  rs.update
	  rs.close
	  Call tx_common.message("·文章内容添加/修改成功<br>·如果你的浏览器不支持跳转，<a href='admin_mainindex.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_mainindex.asp'>",1)
Case "add"
content=tx_tables.formtop("?action=addsave","添加文章")
content = content & tx_master.sortselect("所属分类","sortlist=1","sortid",0)
content =content & tx_tables.ewebtext("内容简介","mainindex","","550","200")
content =content & tx_tables.ewebtext("内容","content","","550","350")
content =content & tx_tables.formfoot
Case "edit"
	 rs.open "select * from tx_main where id="&tx_common.checkstr(request.querystring("id"),1),conn,1,3
content=tx_tables.formtop("?action=addsave&id="&rs("id"),"添加文章")
content = content & tx_master.sortselect("所属分类","sortlist=1","sortid",rs("sortid"))
content =content & tx_tables.ewebtext("内容简介","mainindex",rs("mainindex"),"550","200")
content =content & tx_tables.ewebtext("内容","content",rs("content"),"550","350")
content =content & tx_tables.formfoot
  Case Else

content =  "<table width='100%' cellpadding=3 cellspacing=1 class=td1>"
content = content & "<tr class=td4><td colspan=4><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='10%'>操作</td></tr>"
Set rso=conn.execute("select * from tx_main order by id desc")

If Not rso.bof And Not rso.eof Then
Do While Not rso.bof And Not rso.eof 
sql="select title from tx_catasort where id="&rso("sortid")
temps=tx_common.query(sql)
If IsArray(temps) Then
sortid=temps(0,0)
End If 
content =content & "<tr class=td2><td>"&rso("id")&"</td><td>&nbsp;</td><td>"&sortid&"</td><td><a href=?action=edit&id="&rso("id")&">编辑</a> | <a href=?action=del&id="&rso("id")&">删除</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()
%>
