<!--#include file="../inc/conn1.asp"-->
<%
	'判断是否正常登录
	if session("admin_name")="" then
		response.redirect "admin_login.asp"
		response.end
	end if
	'删除新闻
	if request.querystring("action")="del" then
		news_id=request.querystring("newsid")
		set rs=server.createobject("adodb.recordset")
		sql="select * from news where news_id="&news_id
		rs.open sql,conn,1,3
		rs.delete
		response.write "<SCRIPT language=JavaScript>alert('新闻删除成功! ');"
		response.write "location.href='news_list.asp'</SCRIPT>"
		rs.close
		set rs=nothing
	end if
	
	'判断页码是否是数字
	dim founder
	founder=false
	if request.querystring("page")<>"" then
		if not IsNumeric(request("page")) then
		founder=true
		end if
	end if

if founder=true then
response.write "<script language=JavaScript>" & "alert('页码参数传递错误！');" & "history.back()" & "</script>"
else
	sql="select * from news order by news_id desc"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
%>
<html>
<head>
<link href="css.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#3399FF">
  <tr>
    <td width="760" height="460" align="center" valign="top" bgcolor="#FFFFFF"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="730">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" background="images/daohang.jpg" style="padding-left:20px;"><b>新闻信息管理</b></td>
      </tr>
      <tr>
        <td height="300" align="center" valign="top" style="padding-top:10px; "><table border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#FFFFFF">
            <td colspan="2"><a href="news_admin.asp?action=add"><img src="images/xzjl.jpg" width="142" height="47" border="0"></a></td>
            </tr>
          <tr align="center" bgcolor="#FFFFFF">
            <td width="420" height="20"><B>新闻标题</B></td>
            <td width="120"><B>操作</B></td>
          </tr>
	<%
		if not rs.eof then
		rs.pagesize=16
			if Trim(request("page"))<>"" then
				page=clng(request("page"))
					if page<1 or page>rs.pagecount then
					response.write "<script language=JavaScript>" & "alert('超过页码范围！');" & "history.back()" & "</script>"
					end if
			 else
					 page=1
			 end if 
			 i=0
			 rs.absolutepage=page
			 do while not rs.eof and i<16
	%>	
          <tr align="center" bgcolor="#FFFFFF">
            <td height="20"><a href="../shownews.asp?id=<%=rs("news_id")%>" target="_blank"><%=rs("news_name")%></a></td>
            <td><a href="news_admin.asp?action=edit&newsid=<%=rs("news_id")%>">修改</a> <a href="news_list.asp?action=del&newsid=<%=rs("news_id")%>">删除</a></td>
          </tr>
<%
			i=i+1
			rs.movenext
			loop
	else
		if rs.bof and rs.eof then
		response.write "<tr><td height=20 colspan=2 align=center><font color=#FF0000>暂无新闻内容</font></td></tr>"
		end if
	end if
%>
          <tr align="center" bgcolor="#FFFFFF">
            <td height="20" colspan="2">
			<%if page<>1 then%>
			<a href="news_list.asp?page=1">首页</a> 
			<a href="news_list.asp?page=<%=page-1%>">上页</a> 
			<%else%>
			首页 上页
			<%end if%>
			第<font color="#ff0000"><%=page%></font>页 
			<%if page<>rs.pagecount then%>
			<a href="news_list.asp?page=<%=page+1%>">下页</a> 
			<a href="news_list.asp?page=<%=rs.pagecount%>">尾页</a>
			<%else%>
			下页 尾页
			<%end if%>
			 共 <font color=#ff0000><%=rs.pagecount%></font> 页
			 </td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<%
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
