<!--#include file="../../Conn.asp" -->
<!--#include file="../../Comm/Site_Class.asp" -->
<!--#include file="../../Comm/Function.asp" -->
<%
PagePath = "../../"

Set Qsite = New Site_Class

Qsite.SiteConfig_Master()
%>
<!--#include file="../Check_Login.asp" -->
<%
Qsite.Check_AdminFlag(arrAdminFlag(4 , 2))

If request.Form("submit") = "批量删除" Then
    If Request("id") = "" Then
        Call infoback("请选中要删除的记录！")
    End If
    sql = "delete * from NewsTbl where NewsId in ("&Request("Id")&")"
    conn.Execute ( sql )
		
    Call infohref("成功删除选中的记录！", "News_list.asp")
	Call close_conn
End If

If Request.Form <> "" Then
	Response.Redirect("News_List.asp?NewsTitle="& Qsite.chgStr(Trim(Request.Form("NewsTitle"))))
	Response.End()
End If

Dim Rs,iRs,Sql,i,CurrentPage,FileName
Dim NewsTitle,NewsTypeId,NewsId
Dim Act


NewsTitle = Qsite.chgStr(Trim(Request.QueryString("NewsTitle")))
NewsTypeId = Qsite.chgStr(Trim(Request.QueryString("NewsTypeId")))

If NewsTypeId = "" Or IsNull(NewsTypeId) Or Not IsNumeric(NewsTypeId) Then NewsTypeId = 0

If NewsTitle <> "" Then
	Sql = "select * from NewsTbl where NewsTitle like '%"& NewsTitle &"%' order by AddDate desc"
Else
	If NewsTypeId <> 0 Then
		Sql = "select * from NewsTbl where NewsTypeId = "& NewsTypeId &" order by AddDate desc"
	Else
		Sql = "select * from NewsTbl order by AddDate desc"
	End If
End If

FileName = "News_List.asp?NewsTitle="& NewsTitle &"&NewsTypeId="& NewsTypeId

Act = Qsite.chgStr(Trim(Request.QueryString("action")))

If Act = "del" Then
	NewsId = Qsite.chgStr(Trim(Request.QueryString("NewsId")))
	CurrentPage = Qsite.chgStr(Trim(Request.QueryString("Page")))
	If NewsId = "" Or Not IsNumeric(NewsId) Then NewsId = 0
	If CurrentPage = "" Or Not IsNumeric(CurrentPage) Then CurrentPage = 1
	
	Conn.Execute("delete * from NewsTbl where NewsId = "& NewsId)
	
	Response.Redirect(FileName & "&page="& CurrentPage)
	Response.End()
End If
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>资讯管理</title>
<link href="../style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function NewsDel(NewsId)
{
	var question = confirm("你确定要删除此条记录吗？");
	if (question !="0")
	{
		location.href = "News_List.asp?action=del&NewsId=" + NewsId;
	}
}
</script>
</head>

<body>
<form name="PosForm" method="post" action="News_List.asp" style="margin:0">
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" class="td_title">资讯信息搜索</td>
		</tr>
		<tr>
			<td height="23" class="td_content">新闻标题：
				<input name="NewsTitle" type="text" class="input_1" id="NewsTitle" size="50" value="<%=NewsTitle%>">
				<input name="Submit" type="submit" class="input_1" value="搜索"></td>
		</tr>
	</table>
	<br>

	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" colspan="6" class="td_title">资讯列表 -- <a href="News_List.asp">所有资讯</a>
			<%
			Set Rs = server.createobject("ADODB.Recordset")
			Rs.Open "select * from NewsTypeTbl order by Px asc" , Conn , 1 , 1
			Do While Not Rs.Eof
				Response.Write(" | <a href=""News_List.asp?NewsTypeId="& Rs("NewsTypeId") &""">"& Rs("NewsTypeName") &"</a>")
			Rs.MoveNext
			Loop
			Rs.Close
			%></td>
		</tr>
		<tr>
        	<td width="4%"class="td_content">选择</td>
			<td width="40%" height="23" class="td_content"><strong>资讯标题</strong></td>
			<td width="15%" class="td_content"><strong>所属分类</strong></td>
            <td width="8%" class="td_content"><strong>浏览次数</strong></td>
			<td width="19%" class="td_content"><strong>发布时间</strong></td>
			<td width="20%" class="td_content"><strong>操作</strong></td>
		</tr>
<%
Rs.Open Sql , Conn , 1 , 1
If Rs.Eof Then
%>
		<tr>
			<td height="23" colspan="6" class="td_content">暂无资讯信息</td>
		</tr>
<%
Else
	Rs.PageSize = 20
	CurrentPage = Clng(Request("page"))
	If CurrentPage < 1 Then CurrentPage = 1
	If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
	Rs.AbsolutePage = CurrentPage
	i = 0
	Do While Not Rs.Eof
%>
		<tr>
        	<td class="td_content"><input name="ID" type="checkbox" id="ID" value="<%=rs("NewsId")%>" /></td>
			<td height="23" class="td_content"><%=Rs("NewsTitle")%></td>
			<td height="23" class="td_content"><a href="News_List.asp?NewsTypeId=<%=Rs("NewsTypeId")%>"><%=NewsType_Name(Rs("NewsTypeId"))%></a></td>
            <td height="23" class="td_content"><%=rs("clicknum")%>
			<td class="td_content"><%=Rs("AddDate")%></td>
			<td class="td_content"><a href="../../news.asp?id=<%=rs("NewsTypeId")%>">查看</a> | <a href="News_Edit.asp?NewsId=<%=Rs("NewsId")%>&strNewsTitle=<%=NewsTitle%>&strNewsTypeId=<%=NewsTypeId%>&strPage=<%=CurrentPage%>">修改</a> | <a href="#" onClick="NewsDel('<%=Rs("NewsId")%>');return false;">删除</a></td>
		</tr>
<%
	i = i + 1
	Rs.MoveNext
	If i >= Rs.PageSize Then Exit Do
	Loop
%>
		<tr>
			<td height="23" colspan="6" class="td_content">
<%
	Qsite.Page_Cn CurrentPage , Rs.PageCount , Rs.RecordCount , FileName
%>			</td>
		</tr>
        <tr class="td_content" >
						<td>
							<input name="ID" type="checkbox" onClick="check_all(this,'ID')">
						</td >
						<script type="text/javascript">
function check_all(obj,cName)
{
var checkboxs = document.getElementsByName(cName);
for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
}
</script>
<td>
批量选中
</td>
						<td colspan="6" >
							<input type="submit" name="submit" class="submit_button" value="批量删除" onClick="return confirm('确定要删除选中的记录吗？删除后将不可恢复！')" />
						</td>
					</tr>
<%
End If
Rs.Close
set rs = nothing
%>
</table>
</form>
</body>
</html>
