<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<%
	useflag=4
%>
<!--#include file="flag.asp"-->
<!--#include file="../inc/setup.asp"-->
<%
	action=Trim(Request.QueryString("action"))

	if action="del" then
	id=Trim(Request("id"))
		if id="" then
			response.write"<script language=JavaScript>alert('参数为空，请选择您要删除的新闻类别');"    
			response.write"this.location.href='newstype.asp';</script>"
		end if
		conn.Execute "delete from newstype where id="&id&""
		response.write"<script language=JavaScript>alert('新闻类别删除成功！');"    
		response.write"this.location.href='newstype.asp';</script>"
		response.End
	end if
	
	if action="save" then
	id=Trim(Request.Form("id"))
		if id="" then
			response.write"<script language=JavaScript>alert('参数为空，请确认后再试');"    
			response.write"this.location.href='newstype.asp';</script>"
		end if
		conn.Execute "update newstype set type='"&Trim(Request.Form("type"))&"' where id="&id&""
		conn.Execute "update newstype set show="&Trim(Request.Form("show"))&" where id="&id&""
		response.write"<script language=JavaScript>alert('新闻类别修改成功！');"    
		response.write"this.location.href='newstype.asp';</script>"
		response.End
	end if
	
	if action="add" then
		conn.Execute "insert into newstype(type,show) values('"&Trim(Request.Form("type"))&"',"&Trim(Request.Form("show"))&")"
		response.write"<script language=JavaScript>alert('新闻类别增加成功！');"    
		response.write"this.location.href='newstype.asp';</script>"
		response.End
	end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href='Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>
<script src='Include/Common.js'></script>
</head>
<form name="selform" method="post" action="?action=del">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sortbutton">
<tr>    
<td height="23" align="center">网站新闻类别管理</tr>
</table>
<table width="100%" border="0" align="center" cellspacing="1" cellpadding="1"  class="Border">
<tr height="25" align="center" class='title'>
	<td width="12%" nowrap>I D </td>
	<td width="54%" nowrap>类别名称</td>
	<td width="19%" nowrap>显示状态</td>
	<td width="15%" nowrap>修改与删除</td>
</tr>
<%
	set rs_user = server.CreateObject("adodb.recordset")'创建对象
	sql="select * from [newstype] order by id desc" '定义SQL语句
	rs_user.Open sql,conn,1,1 '这里执行你查询SQL并获得结果记录集
	if rs_user.eof then
		response.Write "<tr><td colspan=6><div align=center><font size=3 color=red><b>暂没有新闻类别</b></font></div></tr></td>"
		response.End
	else
	do while not rs_user.eof
%>
<tr height="25" align=center class='tdbg' onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
	<td><%= rs_user("id") %></td>
	<td><%= rs_user("type") %></td>
	<td><% If rs_user("show")=1 Then Response.Write("显  示") else Response.Write("不显示")%></td>
	<td><a href="?action=edit&id=<%=rs_user("id")%>"><font color="#FF0000">修改</font></a> <a href="?action=del&id=<%=rs_user("id")%>" onclick='{if(confirm("删除后将无法恢复，您真的要删除么？")){return true;}return false;}'><font color="#FF0000">删除</font></a></td>
</tr>
<%
	rs_user.movenext
	loop
	End If
%>
</table>
</form>

<%
	if action="edit" then
%>
<form name="form1" method="post" action="?action=save">
<table width="100%" style="MARGIN-TOP: 3px" border="0" align="center" cellspacing="1" cellpadding="1"  class="Border">
  <tr height="25" align="center" class='title'>
    <td width="12%" nowrap>I D </td>
    <td width="54%" nowrap>类别名称</td>
    <td width="19%" nowrap>显示状态</td>
    <td width="15%" nowrap>修改与删除</td>
  </tr>
<%
		set rs_user = server.CreateObject("adodb.recordset")'创建对象
		sql="select * from [newstype] where id="&Trim(Request.QueryString("id"))&"" '定义SQL语句
		rs_user.Open sql,conn,1,1 '这里执行你查询SQL并获得结果记录集
		if rs_user.eof then
			response.Write "<tr><td colspan=6><div align=center><font size=3 color=red><b>暂没有友情链接</b></font></div></tr></td>"
			response.End
		else
%>
  <tr height="25" align=center class='tdbg' onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
    <td><%= rs_user("id") %></td>
	<input name="id" type="hidden" value="<%= Trim(Request.QueryString("id")) %>">
    <td><input type="text" name="type" value="<%= rs_user("type") %>"></td>
    <td><select name="show" id="show">
      <option value="1" <% If rs_user("show")=1 Then Response.Write("selected")%>>显  示</option>
      <option value="0" <% If rs_user("show")=0 Then Response.Write("selected")%>>不显示</option>
    </select></td>
    <td><input type="submit" name="Submit" value="修改"></td>
  </tr>
<%
		End If
%>
</table>
</form>
<%
	else
%>
<form name="form1" method="post" action="?action=add">
<table width="100%" style="MARGIN-TOP: 3px" border="0" align="center" cellspacing="1" cellpadding="1"  class="Border">
  <tr height="25" align="center" class='title'>
    <td width="66%" nowrap>新增类别名称</td>
    <td width="19%" nowrap>显示状态</td>
    <td width="15%" nowrap>增加</td>
  </tr>
  <tr height="25" align=center class='tdbg' onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
    <td><input type="text" name="type"></td>
    <td><select name="show" id="show">
      <option value="1" selected>显  示</option>
      <option value="0">不显示</option>
        </select></td>
    <td><input type="submit" name="Submit" value="增加"></td>
  </tr>
</table>
</form>
<% End If %>
<table width="100%" style="MARGIN-TOP: 3px" border="0" align="center" cellspacing="1" cellpadding="1"  class="Border">
  <tr height="25" align="center" class='title'>
    <td colspan="3" nowrap>注：显示状态中的“显示”指的是 该类别的新闻将会在“资讯中心”内列表出来，否则将不会在该页内列表</td>
  </tr>
</table>
</body>
</html>
<% call closeconn() %>
