
<!--#include file = "Startup.asp"-->
<!-- #include file="Function.asp" -->
<%

' ======================
' 功能：新闻列表
' ======================
call adminer()
Call Header()
Call ComeUrl()

%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled==false)
       e.checked = form.chkAll.checked;
    }
  }
  
function ConfirmDel()
{
	if(document.myform.Action.value=="ConfirmDel")
	{
		if(confirm("确定要彻底删除选中的文章吗？一旦删除将不能恢复！"))
			return true;
		else
			return false;
	}
	else if(document.myform.Action.value=="ClearRecyclebin")
	{
		if(confirm("确定要清空回收站？一旦清空将不能恢复！"))
			return true;
		else
			return false;
	}
	else if(document.myform.Action.value=="Restore")
	{
		if(confirm("确定要还原您选择的新闻！"))
			return true;
		else
			return false;
	}
	else if(document.myform.Action.value=="RestoreAll")
	{
		if(confirm("确定要还原回收站里的所有的新闻！"))
			return true;
		else
			return false;
	}
}
</SCRIPT>


<%
Dim z_sql,z_rs
sSql="Select d_id,d_title,d_classid,D_RecycleTime,d_editor From NewsData Where d_recycle=True ORDER BY D_RecycleTime DESC,D_ID DESC"
oRs.Open sSql,oConn,1,1

Dim FileName
FileName="News_recycle.asp"
Session("FileName")=FileName

const MaxPerPage=15   '单独页最大记录数 const 用来申明常量
dim totalPut   '总记录
dim CurrentPage  '当前页次
dim TotalPages   '总页数
dim i



'!-- 分页功能代码块,可独立使用
if not ors.eof then
  ors.MoveFirst  '注意放到前面来,否则到任何页总是在第一个记录上
  end if
  ors.pagesize=MaxPerPage  '设置每页最多显示多少条记录
  If trim(Request("Page"))<>"" then  '如果请求的页次不为空
	CurrentPage= CLng(request("Page"))   'clng是转换成长整型数据类型,并赋值到当前页次上
	If CurrentPage> ors.PageCount then  '如果当前页次大于总页数,则将最大页次赋值到当前页次上
		CurrentPage = ors.PageCount 
	End If 
Else 
	CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If 

 totalPut=ors.recordcount '将总记录赋值于TOTALPUT
	if CurrentPage<>1 then '如果当前页数不等于第一页
		if (currentPage-1)*MaxPerPage<totalPut then  '如果当前页减一乘以每页最大的记录数小于总记录的话
			ors.move(currentPage-1)*MaxPerPage  '相对当前记录数向后移动
			dim bookmark  '定义书签变量
			bookmark=ors.bookmark '将当前记录的标签赋于变量BOOKMARK上
		end if 
	end if

	dim n,k
	if (totalPut mod MaxPerPage)=0 then  '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
		n= totalPut \ MaxPerPage
	else  
		n= totalPut \ MaxPerPage + 1  
	end if

%>

<table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
<form name="myform" method="Post" action="News_Del.asp" onsubmit="return ConfirmDel();">
<input name="FileName" type="hidden" value="<%=FileName%>">
  <tr bgcolor="#F7F7F7">
    <td width="40"><div align="center"><STRONG>选中</STRONG></div></td>
    <td><div align="center"><STRONG>文章标题</STRONG></div></td>
    <td><div align="center"><strong>栏目分类</strong></div></td>
    <td><div align="center"><STRONG>录入</STRONG></div></td>
    <td width="130" bgcolor="#F7F7F7"><div align="center"><strong>删除时间</strong></div></td>
    <td width="40" bgcolor="#F7F7F7"><div align="center"><strong>修改</strong></div></td>
    <td width="40" bgcolor="#F7F7F7"><div align="center"><strong>删除</strong></div></td>
    </tr>

<%
If oRs.Eof Then
Response.Write "<tr><td bgcolor='#ffffff' colspan='7'><div align='center'>暂无新闻信息！！</div></td></tr>"

Else
Do While Not oRs.Eof and i<maxperpage
%> 
  
  <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#F7F8F8'">
    <td width="40"><div align="center">
        <input name='NewsID' type='checkbox' onClick="unselectall()" id="NewsID" value="<%=oRs("d_id")%>">
    </div></td>
    <td><%=gotTopic(oRs("d_title"),50)%></td>
    <td><div align="center">
	<%
	Set z_rs=Server.CreateObject("ADODB.Recordset")
	z_sql="Select ClassName From NewsClass Where ClassID="&oRs("d_classid")
	z_rs.Open z_sql,oConn,1,1
	If Not z_rs.Eof Then
	Response.Write z_rs("ClassName")
	Else
	Response.Write "无此栏目分类"
	End If
	z_rs.Close
	%>
	</div></td>
    <td><div align="center"><%=oRs("d_editor")%></div></td>
    <td width="130"><div align="center"><%=oRs("D_RecycleTime")%></div></td>
    <td width="40"><div align="center">[<a href="News_Del.asp?NewsID=<%=oRs("d_id")%>&Action=Restore">还原</a>]</div></td>
    <td width="40"><div align="center">[<a href="News_Del.asp?NewsID=<%=oRs("d_id")%>&Action=ConfirmDel" onclick="return ConfirmDel();">删除</a>]</div></td>
    </tr>
  
<%
oRs.MoveNext
i=i+1
Loop

%>  
  <tr bgcolor="#FFFFFF">
    <td colspan="7"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40"><div align="center">
      <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
    </div></td>
    <td>选中本页显示的所有文章</td>
    <td>	<div align='right'><input name='Action' type='hidden' id='Action2' value='ConfirmDel'>
        <input name='Submit3' type='submit' id='Submit3' onClick="document.myform.Action.value='Restore'" value='还原选定的文章' class='input_submit'>&nbsp;&nbsp;
       <input name='Submit4' type='submit' id='Submit4' onClick="document.myform.Action.value='RestoreAll'" value='还原所有文章' class='input_submit'>&nbsp;&nbsp;
		<%If session("userclass")=1 Then%>
		<input type='submit' name='Submit2' value='清空回收站' onClick="document.myform.Action.value='ClearRecyclebin'" class='input_submit'>&nbsp;&nbsp;
		<input type='submit' name='Submit1' value='彻底删除' onClick="document.myform.Action.value='ConfirmDel'" class='input_submit'>&nbsp;&nbsp;</div>
		<%End If%></div></td>
  </tr>
</table>
</td>
    </tr>
</form>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30"><div align="center">
        <%
	Response.Write "共 <font color='#FF0000'>"&totalPut&"</font> 篇新闻　" 
          k=currentPage
		if k<>1 then
			response.write "[<b>"+"<a href='News_Recycle.asp?page=1'>首页</a></b>] "
			response.write "[<b>"+"<a href='News_Recycle.asp?page="&cstr(k-1)&"'>上一页</a></b>] "
		else
			Response.Write "[首页] [上一页]"
		end if
		if k<>n then
			response.write "[<b>"+"<a href='News_Recycle.asp?page="&cstr(k+1)&"'>下一页</a></b>] "
			response.write "[<b>"+"<a href='News_Recycle.asp?page="&cstr(n)&"'>尾页</a></b>] "
		else
			Response.Write "[下一页] [尾页]"
		end if	
		Response.Write "　页次：<font color='#ff0000'>"&currentpage&"</font>/"&n&"页　15篇新闻/页"
		%>
        　转到：
        <select name="select" onChange="javascript:window.location='News_Recycle.asp?page='+this.options[this.selectedIndex].value;">
<option>跳转页</option>
<%
Dim z
For z=1 To n%>
          <option value="<%=z%>">第<%=z%>页</option>
          <%
Next
%>
        </select>
    </div></td>
  </tr>
  <%
End If
oRs.Close
%>
</table>
 
