<!--#include file="../common/conn.asp"-->
<%
'检查用户权限
call checkuser(GetQueryString("WindowName"))
%>
<%
if GetVariable("action")="dele" then
	strIDs=GetVariable("id")
	strSQL="Delete From web_news Where id in(" & strIDs & ",0)"
	conn.execute strSQL
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=GetQueryString("WindowName")%>管理</title>
<STYLE type="text/css">
td			{font-size:9pt;line-height:140%}
A:active	{COLOR: #FFFFFF;}
A:visited	{COLOR: #333333; TEXT-DECORATION: none}
A:hover		{COLOR: #000033;TEXT-DECORATION: none}
A:link		{COLOR: #333333; TEXT-DECORATION: none}
</STYLE>
<script language="JavaScript" src="../../common/JS_CheckForm.js"></script>
<script language="JavaScript">
function init(){
	SelectValue(newform.selClass,'<%=GetQueryString("class")%>');
	//初始化编辑框
}
</script>
</head>
<%
strQueryString="&mnid=" & GetQueryString("mnid") & "&class=" & GetQueryString("class") & "&WindowName=" & GetQueryString("WindowName")
strQuery=" Where mn_id=" & GetQueryString("mnid")
strClass=GetQueryString("class")
if strClass<>"" then
	SourCode=conn.execute("Select c_code From web_news_class Where mn_id=" & GetQueryString("mnid") & " and id="&strClass)(0)
	strQuery=strQuery & " And c_code Like '" & SourCode &"%'"
end if

'从这开始读数据
strSQL="Select * From v_web_news " & strQuery &" Order By ID Desc"
rs.open strSQL,conn,1,1
'分页显示初始化
page=GetVariable("page")
if page="" then
	page=1
else
	page=Cint(page)
end if

Section=GetVariable("section")
if Section="" then
	Section=1
else
	Section=Cint(Section)
end if
'变量赋值
intPageSize=10		'每页显示记录数
intSectionSize=5		'多少页为一段，像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>"		'上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>"		'下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>"			'上页的链接文字	
NextPageText="<FONT face=webdings>4</FONT>"			'下页的链接文字

strPageUrl="?t=" & strQueryString

rs.pagesize=intPageSize
intCount=rs.RecordCount 
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
if intCount>0 then
	rs.AbsolutePage=page  
end if
%>
<body leftmargin="0" topmargin="0" onLoad="init()">
<form name="newform" method="post" action="?action=dele<%=strQueryString%>">
  <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#336600">
    <tr> 
      <td width="100%" bgcolor="#669900"><strong><font color="#FFFFFF"><%=GetQueryString("WindowName")%>管理</font></strong></td>
    </tr>
    <tr align="center" bgcolor="#F9F9F9"> 
      <td> <table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr> 
            <td height="40" colspan="5"> 　 选择分类 
              <select name="selClass" id="selClass" onChange="location='?<%="mnid=" & GetQueryString("mnid") & "&WindowName=" & GetQueryString("WindowName")%>&class=' + this.value">
                <option value="">所有分类</option>
                <%Sql="select id,c_name,c_code from web_news_class where mn_id="&GetVariable("mnid")&" order by c_code"
        set rsclass=conn.execute(sql)
        Do While Not rsclass.eof
			Level=(Len(rsclass(2))/4-1)*3
			Response.Write "<option value="""&rsclass(0)&""""
			Response.Write ">"
			If Len(rsclass(2))>4 Then Response.Write "├"
			Response.Write String(Level,"-")
			Response.Write rsclass(1)&"</option>"
			rsclass.movenext
		Loop
		rsclass.close%>
              </select></td>
          </tr>
          <tr bgcolor="#669900"> 
            <td align="right"><font color="#FFFFFF">&nbsp;</font></td>
            <td><font color="#FFFFFF"><strong>标题</strong></font></td>
            <td align="center"><strong><font color="#FFFFFF">发表人</font></strong></td>
            <td align="center"><font color="#FFFFFF"><strong>发布时间</strong></font></td>
            <td width="15%" align="center"><font color="#FFFFFF"><strong>操作</strong></font></td>
          </tr>
          <%
		 '循环输出
		 for i=1 to intPageSize
			if rs.eof then exit for
			if i mod 2=0 then
				strColor="#eeeeee"
			else
				strColor="#f9f9f9"
			end if
		 %>
          <tr bgcolor="<%=strColor%>"> 
            <td width="5%" align="center" bgcolor="<%=strColor%>"><input name="id" type="checkbox" id="id" value="<%=trim(rs("id"))%>"></td>
            <td width="53%"><%=trim(rs("nTitle"))%></td>
            <td width="10%" align="center"><%=trim(rs("nAuthor"))%></td>
            <td width="17%" align="center"><%=trim(rs("nTime"))%></td>
            <td align="center">[<a href="?id=<%=trim(rs("id"))%>&action=dele<%=strQueryString%>">删除</a>][<a href="javascript:" onClick="window.open('edit.asp?id=<%=trim(rs("id"))%><%=strQueryString%>','','toolbar=yes,resizable=yes')">修改</a>]</td>
          </tr>
          <%
			 rs.movenext
		  next
		  %>
          <tr> 
            <td colspan="5">　 
              <input type="button" name="Submit22" value=" 发布<%=GetQueryString("WindowName")%> " onClick="window.open('edit.asp?t=<%=strQueryString%>','','scrollbars=yes,toolbar=yes,resizable=yes')"> 
              <input type="submit" name="Submit3" value=" 删除所选 "></td>
          </tr>
          <tr> 
            <td colspan="5" align="center"> <hr width="95%" style="color:#669900"></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td bgcolor="#669900"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td align="right"> <font color="#FFFFFF">共有<%=intCount%>记录，分<%=intPageCount%>页，当前页<%=Page%>，每页显示<%=intPageSize%>条记录 
              <%
			'计算每一段的开始页
			intStarPage=(Section-2) * intSectionSize + 1
			'前一段
			if Section<=1 then
				response.Write(PrevSectionText & " ")
			else
				response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
			end if 
			
			'显示页码列表
			response.Write("第")
			intStarPage=(Section-1) * intSectionSize + 1
		    for p=intStarPage to intStarPage + intSectionSize - 1
				if p > intPageCount then exit for
				if p=page then
		    		response.Write("<strong>[" & p & "]</strong> ")
				else
		    		response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
				end if	
		    next
			response.Write("页")
			'后一段
			intStarPage=(Section) * intSectionSize + 1
			if Section>=intSectionCount then
				response.Write(" " & NextSectionText)
			else
				response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
			end if 
		  %>
              <select name="page" size="1" onchange="window.location='<%=strPageUrl & "&section="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
                <option value="<%=page%>" selected>第<%=page%>页</option>
                <%
							for i=1 to rs.pagecount
					%>
                <option value="<%=i%>" >第<%=i%>页</option>
                <%
							next
					 %>
              </select>
              </font> 　 </td>
          </tr>
        </table></td>
    </tr>
  </table>
  <iframe name="BackFrame" width="0" height="0" src="about:blank"></iframe>
</form>
</body>
</html>
