<%@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>
<%
Sub close_conn
    conn.Close
    Set conn = Nothing
End Sub


Sub infoback(info)
    response.Write "<script language=javascript>alert('"&info&"');window.history.back();</script>"
    response.End
End Sub

Sub infohref(info, url)
    response.Write "<script language=javascript>alert('"&info&"');window.location.href='"&url&"'</script>"
    response.End
End Sub


If request.Form("submit") = "删除选中" Then
    If Request("id") = "" Then
        Call infoback("请选中要删除的新闻！")
    End If
    sql = "delete from news where ID in ("&Request("ID")&")"
    conn.Execute ( sql )
	Call close_conn
    Call infohref("成功删除选中的新闻！", "news.asp")
	
End If
%>
<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" height="30" background="../images/main_4.gif">&nbsp;</td>
                <td height="30" background="../images/main_9.gif"><table height="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
				  <%

Set rsc= server.CreateObject("adodb.recordset")
rsc.Open "select * from news_category", conn, 1, 1
While Not rsc.EOF
   %>
   	 <td width="100" align="center" ><a href="news.asp?main_id=<%=rsc("ID")%>" ><span class="text2">【<%=rsc("title")%>】</span></a></td>
   <%
    rsc.movenext
Wend
rsc.Close
Set rsc = Nothing

%>
                  </tr>
                </table></td>
                <td width="15" height="30" 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="15" background="../images/main_4.gif">&nbsp;</td>
        <td background="../images/main_9.gif">
		<form method="post" name="news" id="news" >
		<table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
          <%
Set rs = server.CreateObject("adodb.recordset")
if request("main_id")="" or request("main_id")=null then
exec = "select * from news order by id desc"
else
exec = "select * from news where category="&request("main_id")&" order by id desc"
end if
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="80" class="td2">选择</th>
            <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%>
          
            <tr>
			 <td width="80" class="td" align="center"><input type="checkbox" name="ID" id="ID" value="<%=rs("ID")%>" /></td>
              <td class="td"><%
Dim rsc
Set rsc = server.CreateObject("adodb.recordset")
rsc.Open "select * from news_category", 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="修改内容"/>
                  </td>
            </tr>
          
          <%rs.movenext
Next
%>
          <%
End If
%><tr >
						<td class="td" align="center">
							<input name="ID" type="checkbox" onclick="check_all(this,'ID')"> 全选
						
						<script type="text/javascript">
						function check_all(obj,cName)
						{
						var checkboxs = document.getElementsByName(cName);
						for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
						}
						</script></td>
						<td colspan="5"  class="td" align="center">
					     <input class="button" type="submit" name="submit"  value="删除选中" onclick="return confirm('确定要删除选中的新闻吗？删除后将不可恢复！')" />
						</td>
					</tr>
        </table></form>
          <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>


<!--#include file="../close.asp"-->
