<!--#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 <> "" Then
	Response.Redirect("News_List.asp?NewsTitle="& Qsite.chgStr(Trim(Request.Form("NewsTitle"))))
	Response.End()
End If

Dim iRs,CurrentPage,FileName
Dim NewsTitle,NewsTypeId,NewsId
Dim Act

Set Rs = server.createobject("ADODB.Recordset")
Set iRs = server.createobject("ADODB.Recordset")

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="../skins/css/main.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>
</form>
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" colspan="4" class="td_title">资讯列表 -- [<a href="News_List.asp">所有资讯</a>
			<%
			Rs.Open "select * from NewsTypeTbl where NewsTypeKey = 0 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>")
				
				iRs.Open "select * from NewsTypeTbl where NewsTypeKey = "& Rs("NewsTypeId") &" order by Px asc" , Conn , 1 , 1
				Do While Not iRs.Eof
					Response.Write(" | <a href=""News_List.asp?NewsTypeId="& iRs("NewsTypeId") &""">"& iRs("NewsTypeName") &"</a>")
				iRs.MoveNext
				Loop
				iRs.Close
				
			Rs.MoveNext
			Loop
			Rs.Close
			%>] </td>
		</tr>
		<tr>
			<td width="52%" height="23" class="td_content"><strong>资讯标题</strong></td>
			<td width="15%" class="td_content"><strong>所属分类</strong></td>
			<td width="19%" class="td_content"><strong>发布时间</strong></td>
			<td width="14%" class="td_content"><strong>操作</strong></td>
		</tr>
<%
Rs.Open Sql , Conn , 1 , 1
If Rs.Eof Then
%>
		<tr>
			<td height="23" colspan="4" 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 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 class="td_content"><%=Rs("AddDate")%></td>
			<td class="td_content"><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="4" class="td_content">
<%
	Qsite.Page_Cn CurrentPage , Rs.PageCount , Rs.RecordCount , FileName
%>			</td>
		</tr>
<%
End If
Rs.Close
%>
</table>
</body>
</html>
