<%@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>
<script language="javascript"> 
<!-- 
function CheckAll(){ 
  var CheckBoxAll = document.getElementById("allbox");
  var input = document.getElementsByName("ID");   
  for(var i=0;i<input.length;i++)
     {  
       input[i].checked = CheckBoxAll.checked;
     }    

 /*for (var i=0;i<eval(form1.elements.length);i++){ 
  var e=form1.elements[i]; 
  if (e.name!="allbox") e.checked=form1.allbox.checked; 
 } */
} 
--> 
</script> 
<link href="../css.css" rel="stylesheet" type="text/css" />
</head>
<body>

<form method="post" name="news" id="news" action="news.asp?del=checkbox">
<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">
		       <select name="ssfl" class="button" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
            <option>---分类查看---</option>
            <%
		  dim rsk
		  set rsk=server.CreateObject("adodb.recordset")
		  rsk.open "select * from news_category order by id asc",conn,1,1
		  response.Write("<option value=""?id="">全部新闻</option>")
		  while not rsk.eof
			response.Write("<option value=""?id=" & rsk("id") & """>" & rsk("title") & "</option>")
			rsk.movenext
		wend
		rsk.close
		set rsc=nothing
		  %>
          </select>
		<table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
          <%
		  id= request.QueryString("id") 
Set rs = server.CreateObject("adodb.recordset")
if id<>"" then
exec="select * from news where category="& id &"  order by id desc" 
else
exec = "select * from news 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 class="td2">&nbsp;</th>
            <th class="td2">所属分类</th>
            <th width="222" class="td2">新闻标题</th>
            <th width="114" class="td2">发布时间</th>
            <th width="73" class="td2">是否要闻</th>
            <th width="130" class="td2">修改操作</th>
          </tr>
          <%For i=1 To x%>
          
            <tr>
              <td width="53" class="td"><input name="ID" type="checkbox" id="ID" value="<%=rs("id")%>" /><%=rs("id")%>&nbsp;</td>
              <td width="124" 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="修改内容"/>
  <input type="button" name="delete" class="button" value="删除" onclick="javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='news.asp?id=<%=rs("id")%>&amp;del=ok';}else{history.go(0);}" />
</td>
            </tr>
          <%rs.movenext
Next
%>
          <%
End If
%>
		  
        </table>

          <span class="right_body">          </span>
          <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
            <tr>
              <td class="td2"><input type="checkbox" name="allbox" id="allbox" onclick="CheckAll()" />
          <select name="lx" class="button">
            <option selected="selected" value="">操作类型</option>
			<option value="1">加入推荐</option>
            <option value="2">取消推荐</option>
            <option value="3">批量删除</option>
          </select>
          <input type="submit" name="button" id="button" value="提交"  class="button"/></td>
            </tr>
          </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>
</form>
</body>
</html>
<%
if request("del")="ok" 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.update
Response.Write "<script>alert('免费版无此功能！');window.location.href='news.asp';</script>"
end if 
%>
<%
if Request.QueryString("del")="checkbox" then
if Request("id")="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');window.location.href='news.asp';</script>" 
response.end()
end if
dim sql
lx=request.Form("lx")
if lx="" then
Response.Write "<script>alert('错误!请选择操作类型!');window.location.href='news.asp';</script>" 
response.end
end if
if lx=1 then
sql="update news set recommendatory=1 where id in ("&Request("id")&")" 
conn.execute(sql) 
elseif lx=2 then 
sql="update news set recommendatory=0 where id in ("&Request("id")&")" 
conn.execute(sql) 
else
sql="delete from news where id in ("&Request("id")&")"
conn.Execute ( sql )
end if
conn.close
set conn=nothing
Response.Write "<script>alert('恭喜!操作成功!');window.location.href='news.asp';</script>" 

end if
%>