<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="seeion.asp"-->
<!--#include file="page.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=site_info("title")%>-后台管理系统</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="content">
  <div id="right">
    <div class="right_body"><br />
    </div>
  </div>
  <div class="clear"></div>
</div>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="52"><img src="images/main_1.jpg" width="52" height="55" /></td>
        <td background="images/main_2.jpg" class="title1">管理新闻</td>
        <td width="52"><img src="images/main_3.jpg" width="52" height="55" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" background="images/main_4.gif">&nbsp;</td>
        <td background="images/main_9.gif"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
          <%
Set rs = server.CreateObject("adodb.recordset")
exec = "select * from news order by id asc"
rs.Open exec, conn, 1, 1
If rs.EOF Then
    response.Write "&nbsp;暂无新闻！"
Else
    rs.PageSize = 10 '每页记录条数
    iCount = rs.RecordCount '记录总数
    iPageSize = rs.PageSize
    maxpage = rs.PageCount
    page = request("page")
    If Not IsNumeric(page) Or page = "" Then
        page = 1
    Else
        page = CInt(page)
    End If
    If page<1 Then
        page = 1
    ElseIf page>maxpage Then
        page = maxpage
    End If
    rs.AbsolutePage = Page
    If page = maxpage Then
        x = iCount - (maxpage -1) * iPageSize
    Else
        x = iPageSize
    End If
%>
          <tr>
            <th width="120" class="td2">所属分类</th>
            <th class="td2">新闻标题</th>
            <th width="120" class="td2">发布时间</th>
            <th width="60" class="td2">是否要闻</th>
            <th width="140" class="td2">修改操作</th>
          </tr>
          <%For i=1 To x%>
          <form method="post" name="news" id="news" >
            <tr>
              <td class="td"><%
Dim rsc
Set rsc = server.CreateObject("adodb.recordset")
rsc.Open "select * from news_class", conn, 1, 1
While Not rsc.EOF
    If rs("category") = rsc("id") Then
        response.Write("【" & rsc("title") & "】")
    End If
    rsc.movenext
Wend
rsc.Close
Set rsc = Nothing

%></td>
              <td class="td"><%=rs("title")%></td>
              <td class="td"><%=rs("data")%></td>
              <td class="td"><%
If rs("recommendatory") = 1 Then
    response.Write("是")
Else
    response.Write("否")
End If

%></td>
              <td class="td"><input name="update" type="button" class="button" onclick="window.location.href='news_update.asp?id=<%=rs("id")%>' " value="修改内容"/>
                  <input name="delete" type="button" class="button" onclick="javascript:if(confirm('确定要删除此条新闻吗？删除后不可恢复!')){window.location.href='news.asp?act=del&amp;id=<%=rs("id")%>';}else{history.go(0);}" value="删除" /></td>
            </tr>
          </form>
          <%rs.movenext
Next
%>
          <%
End If
%>
        </table>
          <span class="right_body">
          <%'以下显示分页
Call PageControl(iCount, maxpage, page, "border=0 align=center", "<p align=center>")
rs.Close
Set rs = Nothing
%>
          </span></td>
        <td width="15" background="images/main_5.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="52"><img src="images/main_6.gif" width="52" height="16" /></td>
        <td background="images/main_7.gif" width="100%"></td>
        <td width="52"><img src="images/main_8.gif" width="52" height="16" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<%
If request("act") = "del" Then
    Set rs = server.CreateObject("adodb.recordset")
    id = Request.QueryString("id")
    sql = "select * from news where id="&id
    rs.Open sql, conn, 2, 3
    rs.Delete
    rs.update
    Response.Write "<script>alert('刪除成功！');window.location.href='news.asp';</script>"
End If
%>


