<!--#include file="sys_top.asp"-->
<!--#include file="inc/class_news.asp" -->
<% action=request("action")
   
   if action="del" then
      id=clng(request("id"))
      dRsOpen rs,"select * from news where id="&id,conn,1,3
	  if not rs.eof then
	     deleteFile "../"&rs("picture")
		 rs.delete
		 rs.update
	  end if
	  dRsClose rs
	  BoxAlert "删除成功！",""
   elseif action="delsel" then
      selID=trim(request("selID")) 
	  if selID<>"" then
	     dRsOpen rs,"select * from news where id in("&selID&")",conn,1,3
		 while not rs.eof
		     deleteFile "../"&rs("picture")
		     rs.delete
		     rs.movenext
		 wend
		 dRsClose rs
      end if
	  BoxAlert "删除成功！",""
   elseif action="iscommend" then
      selID=trim(request("selID")) 
	  if selID<>"" then
	      conn.execute("update news set iscommend=True where id in("&selID&")")
      end if
	  BoxAlert "推荐所选成功！",""
   elseif action="uncommend" then
      selID=trim(request("selID")) 
	  if selID<>"" then
	      conn.execute("update news set iscommend=False where id in("&selID&")")
      end if
	  BoxAlert "取消推荐所选成功！",""
   elseif action="isshow" then
	  selID=trim(request("selID")) 
	  if selID<>"" then
	      conn.execute("update news set isshow=True where id in("&selID&")")
      end if
	  BoxAlert "发布所选成功！",""
   elseif action="unshow" then
	  selID=trim(request("selID")) 
	  if selID<>"" then
	      conn.execute("update news set isshow=False where id in("&selID&")")
      end if
	  BoxAlert "取消所选成功！",""
   elseif action="update" then
      id=request("id")
      ArrIDList=split(id,",")
	  for i= Lbound(ArrIDList) to Ubound(ArrIDList)
	      newsid=trim(ArrIDList(i))
	      orderid=request("orderid"&newsid)
		  if not isInteger(orderid) then
		     orderid=999999
		  end if
		  conn.execute("update news set orderid="&orderid&" where id="&newsid)
	  next
	  BoxAlert "更新排序成功！",""
   end if
   classid=0
   
   if request("classid")<>"" then
      classid=clng(request("classid"))
   end if
   keywords=request("keywords")
   pagenum=DefaultPageSize
   if request("pagenum")<>"" then
      pagenum=request("pagenum")
   end if
   orderby=1
   if request("orderby")<>"" then
      orderby=request("orderby")
   end if
%>
<script type="text/javascript">
function clickAction()
{
	var action=document.getElementById("selaction").value;
	if(action=="")
	{
		document.getElementById("selaction").focus();
		alert("请选择操作！");
		return;
	}
	else
	{
		document.getElementById("action").value=action;
		document.myform.submit();
	}
 }
  function updateOrder()
 {
	 document.getElementById("action").value="update";
	 document.myform.submit();
 }
</script>
<div class="nav">新闻列表 | <a href="class_news_add.asp">类别管理</a> | <a href="news_add.asp">添加新闻</a></div>
  <form name="myform" id="myform" method="post" action="news_list.asp" />
<table class="tableStyle1 width1">
     <tr class="title"><td colspan="7">新闻管理</td></tr>
      <tr><td colspan="7" style="text-align:left;">
       <select name="pagenum" id="pagenum" >
          <option value="10">每页显示10条</option>
          <option value="20">每页显示20条</option>
          <option value="50">每页显示50条</option>
          <option value="100">每页显示100条</option>
       </select>
       <select name="orderby" id="orderby" >
          <option  value="1">按顺序编号升序</option>
          <option  value="2">按顺序编号降序</option>
          <option  value="3">按发布时间升序</option>
          <option  value="4">按发布时间降序</option>
       </select>
       关键词：<input type="text" value="<%=keywords%>" name="keywords"  id="keywords" />&nbsp;
       类别：<select name="classid" id="classid"> 
        <option value="0">所有类别</option>
       <%=getAllOption(5,"┣",0) %>
     </select><script type="text/javascript">
           document.getElementById("classid").value='<%=classid%>';
		   document.getElementById("pagenum").value='<%=pagenum%>';
		   document.getElementById("orderby").value='<%=orderby%>';
       </script>&nbsp;<input type="submit"  value="搜索"  class="loginbutton" /></td></tr>
   
     <tr class="header"><td width="32">选择</td><td width="60">顺序编号</td><td width="400">新闻标题</td><td width="40">推荐</td><td width="40">发布</td><td width="80">发布时间</td><td width="80">操作管理</td></tr>
    
      
     <% sql="select id,title,orderid,iscommend,isshow,ctime from news where 1=1 "
	    url="news_list.asp?pagenum="&pagenum&"&orderby="&orderby&"&"
	    if classid > 0 then
		   sql=sql&"and instr(pathid,',"&classid&",')>0 "
		   url=url&"classid="&classid&"&"
		end if
		if keywords<>"" then
		   sql=sql&"and title like '%"&keywords&"%'"
		   url=url&"keywords="&Server.URLEncode(keywords)&"&"
		end if
		if orderby="2" then
	       sql=sql&"order by orderid desc,id desc"
		elseif orderby="3" then
		    sql=sql&"order by id asc"
		elseif orderby="4" then
		    sql=sql&"order by id desc"
	    else
		    sql=sql&"order by orderid asc,id desc"
		end if
	    dRsOpen rs,sql,conn,1,1
	    totalrecords=rs.recordcount
		rs.pagesize=pagenum
		totalpages=rs.pagecount
		cpage=getCPage(totalpages)
		if totalpages>1 then
		   rs.absolutepage=cpage
		end if
	    for i=1 to rs.pagesize
		  if rs.eof then exit for
		 %>
     <tr><td><input type="checkbox" name="selID" value="<%=rs("id")%>" /><input type="hidden" name="id" value="<%=rs("id")%>" /></td>
         <td><input type="text" name="orderid<%=rs("id")%>" size="4" value="<%=rs("orderid")%>" /></td>
         <td style=" text-align:left"><%=rs("title")%></td>
         <td><img src="theme/default/images/<% if rs("iscommend")=True then response.Write("yes") else response.Write("no")  %>.gif" /></td>
         <td><img src="theme/default/images/<% if rs("isshow")=True then response.Write("yes") else response.Write("no")  %>.gif" /></td>
        
         <td><%=rs("ctime")%></td>
         <td><a href="news_edit.asp?id=<%=rs("id")%>">修改</a> | <a href="?id=<%=rs("id")%>&action=del" onClick="return confirm('确定删除吗？')">删除</a></td></tr>
     <% rs.movenext
		next
		dRsClose rs%>
        
     <tr class="footer"><td colspan="7" style="text-align:left;"><input type="checkbox" name="chkAll" onClick="checkAll(this.form,this)" >全选&nbsp;&nbsp;<a href="Javascript:checkFan()">反选</a>&nbsp;&nbsp; <input type="hidden" name="action" value="" id="action" /> <select name="selaction" id="selaction">
               <option value="">选择操作</option>
               <option value="delsel">删除所选</option>
               <option value="iscommend">推荐所选</option>
               <option value="uncommend">取消推荐</option>
               <option value="isshow">发布所选</option>
               <option value="unshow">取消发布</option>
            </select>
     <input type="button"  value="执行操作"  onClick="clickAction()" class="loginbutton" />&nbsp;&nbsp; <input type="button"  value="更新排序"  onClick="updateOrder();" class="loginbutton" /></td></tr>
		<tr class="footer"><td colspan="7">	
        <input type="hidden" name="page" value="<%=cpage%>" id="action" />   
			   <% showPages1 totalrecords,totalpages,cpage,url%></td></tr>
</table>
</form>
<!--#include file="sys_foot.asp"-->
