<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<%
	useflag=4
%>
<!--#include file="flag.asp"-->
<!--#include file="../inc/char.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	end if
	action=Trim(Request.QueryString("action"))
	if action="tj" then
		conn.Execute("update companynews set tj=1 where id="&Trim(Request.QueryString("id")))
		response.write"<script language=JavaScript>alert('该新闻推荐成功,现在为您返回');"    
		response.write"this.location.href='managenews.asp';</script>"
		response.End
	end if
	if action="notj" then
		conn.Execute("update companynews set tj=0 where id="&Trim(Request.QueryString("id")))
		response.write"<script language=JavaScript>alert('该新闻已经转换为非推荐状态,现在为您返回');"    
		response.write"this.location.href='managenews.asp';</script>"
		response.End
	end if
	if action="thot" then
		conn.Execute("update companynews set thot=1 where id="&Trim(Request.QueryString("id")))
		response.write"<script language=JavaScript>alert('该新闻已转换为热点新闻状态,现在为您返回');"    
		response.write"this.location.href='managenews.asp';</script>"
		response.End
	end if
	if action="nothot" then
		conn.Execute("update companynews set thot=0 where id="&Trim(Request.QueryString("id")))
		response.write"<script language=JavaScript>alert('该新闻已转换为非热点新闻状态,现在为您返回');"    
		response.write"this.location.href='managenews.asp';</script>"
		response.End
	end if
	
	if action="del" then
	
		conn.Execute("delete from companynews where id="&Trim(Request.QueryString("id")))
		
		response.write"<script language=JavaScript>alert('新闻删除成功,现在为您返回');"    
		response.write"this.location.href='managenews.asp';</script>"
		response.End
		
	end if
%>
<HTML>
<HEAD>
<TITLE>新闻管理</TITLE>
<META http-equiv=Content-Type content="text/html; chaRSet=gb2312">
<LINK href="Include/Admin_Style.css" type=text/css rel=stylesheet>
</HEAD>
<BODY leftMargin=0 topMargin=0 >
<TABLE class=sortbutton cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<FORM name="form1" method="get">
<input name="action" type="hidden" value="search">
<input name="key" type="hidden" value="<%=Trim(Request.QueryString("key"))%>">
<TR>
  <TD width="21%" align="right"><a href="addnews.asp?id=<%=Trim(Request.QueryString("key"))%>"><font color="#FF0000">添加新闻</font></a></TD>
  <TD width="24%" align="center"><a href="managenews.asp"><font color="#FF0000">浏览所有新闻</font></a></TD>
  <TD width="26%" align="left">&nbsp;</TD>
  <TD width="29%" valign="middle"><Input maxLength=30 name="Keyword" value="请输入标题关键字" onMouseOver="if(this.value=='请输入标题关键字'){this.value=''}" title="请输入标题关键字">
      <Input class='button' type=submit value=" 查 询 "></TD>
  </TR>
  </FORM>
<tr><td colspan="3"></TBODY>
</TABLE>
<TABLE width="100%" height=25 border=0 align="center" cellPadding=0 cellSpacing=1>
  <TBODY>
  <TR>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR align=middle>
          <TD width=99 height=23 align="center" class=sort>新闻ID</TD>
          <TD width=476 align="center" class=sort>新闻标题</TD>
          <TD width=105 align="center" class=sort>所属类别</TD>
          <TD width=99 align="center" class=sort>发布日期</TD>
          <TD width=100 align="center" class=sort>新闻状态</TD>
          <TD width=114 align="center" class=sort>修改与删除</TD>
		  </TR>
<%
	key=Trim(Request.QueryString("key"))
	searchtype="where companynews.cate=newstype.id"
	
	if Trim(Request.QueryString("type"))<>"" then searchtype=searchtype&" and companynews.cate="&Trim(Request.QueryString("type"))&""
	
	if Trim(Request.QueryString("action"))="search" and Trim(Request.QueryString("Keyword"))<>"" and Trim(Request.QueryString("Keyword"))<>"请输入标题关键字" then
		title=Trim(Request.QueryString("Keyword"))
	
		searchtype=searchtype&" and title like '%"&title&"%'"
	
	end if

	dim i,intPage,page,pre,last,filepath'定义变量
	set rs_user = server.CreateObject("adodb.recordset")'创建对象
	sql="select companynews.id cid,companynews.tj,companynews.thot,companynews.title,companynews.text,companynews.cate,companynews.idate,newstype.id nid,newstype.type from companynews,newstype "&searchtype&" order by cid desc"'定义SQL语句
	rs_user.PageSize = 16 '这里设定每页显示的记录数
	rs_user.CursorLocation = 3
	rs_user.Open sql,conn,0,2,1 '这里执行你查询SQL并获得结果记录集
	pre = true
	last = true
	page = trim(Request.QueryString("page"))'变量是跳转页面时的值

	if len(page) = 0 then
		intpage = 1
		pre = false
	else
		if cint(page) =< 1 then
			intpage = 1
			pre = false
		else
			if cint(page) >= rs_user.PageCount then
				intpage = rs_user.PageCount
				last = false
			else
				intpage = cint(page)
			end if
		end if
	end if
	if not rs_user.eof then
		rs_user.AbsolutePage = intpage
	end if
	if rs_user.eof then
		response.Write "<div align=center><font size=3 color=red><b>没有该类别的新闻信息，请查询后再重试</b></font></div>"
		response.End
	else
	for i=1 to rs_user.PageSize
	if rs_user.EOF or rs_user.BOF then exit for
%>
        <TR>
          <TD height=25 align="center"><%=rs_user("cid")%></TD>
          <TD align=middle><a href="../view_news.asp?id=<%=rs_user("cid")%>" target="_blank" title="浏览该新闻"><%=rs_user("title")%></a></TD>
          <TD align=center><A href="?type=<%=rs_user("nid")%>"><%=rs_user("type")%></A></TD>
          <TD align=center><%=rs_user("idate")%></TD>
          <TD align=center><% If rs_user("tj")=0 Then Response.Write("<a href='?action=tj&id="&rs_user("cid")&"'>不推荐</a>") else Response.Write("<a href='?action=notj&id="&rs_user("cid")&"'><font color=red>推&nbsp;&nbsp;&nbsp;荐</font></a>")%> |
            <% If rs_user("thot")=0 Then Response.Write("<a href='?action=thot&id="&rs_user("cid")&"'>非热点</a>") else Response.Write("<a href='?action=nothot&id="&rs_user("cid")&"'><font color=red>热&nbsp;&nbsp;&nbsp;点</font></a>")%></TD>
          <TD align=center><A href="newsedit.asp?action1=edit&id=<%=rs_user("cid")%>">[修改]</A> <A href="?action=del&id=<%=rs_user("cid")%>&key=<%= key %>" onclick='{if(confirm("删除后将无法恢复，您真的要删除么？")){return true;}return false;}'>[删除]</A></TD>
 	 </TR>
<%
	rs_user.movenext
	next
	End If
%>
<table width="99%" border="0" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs_user.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs_user.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="?page=1&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>">首页</a>|
<%if pre then%>
<a href="?page=<%=intpage -1%>&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>">上页</a>| <%end if%>
<%if last then%>
<a href="?page=<%=intpage +1%>&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>">下页</a> |<%end if%>
<a href="?page=<%=rs_user.PageCount%>&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>">尾页</a>|转到第
<select name="sel_page" onchange=javascript:location.href=this.options[this.selectedIndex].value>
<%
	for i = 1 to rs_user.PageCount
	if i = intpage then
%>
<option value="?page=<%=i%>&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>" selected><%=i%></option>
<%else%> 
<option value="?page=<%=i%>&type=<%=Trim(Request.QueryString("type"))%>&action=<%= Trim(Request.QueryString("action")) %>&Keyword=<%= Trim(Request.QueryString("Keyword")) %>&key=<%=Trim(Request.QueryString("key"))%>"><%=i%></option>
<%
	end if
	next
	rs_user.close
	set rs_user=nothing
%>
</select>页</font></td>
</tr>
</table>
</TABLE>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
