<!--#include file="conn.asp"-->
<!--#include file="seeion.asp"-->
<%
id = request("id")
If request.Form("update") = "yes" Then
    If Not IsNumeric(request("order_id")) Then
        response.Write("<script>alert(""排序字符必须为数字！""); history.back(1);</script>")
        response.End
    End If
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from news_category where id="&id
    rs.Open sql, conn, 1, 3
    rs("title") = request.Form("title")
    rs("order_id") = request.Form("order_id")
    rs.update
End If
If request.Form("submit") = "修改新闻分类" Then
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from news_category where id="&id
    rs.Open sql, conn, 1, 3
    rs("title") = request.Form("title")
    rs.update
	response.Write "<script language=javascript>alert(""新闻修改成功！"");window.location.href=""news_category.asp""</script>"
	response.End()
End If
If request("act") = "del" Then
    Set rs = server.CreateObject("adodb.recordset")
    id = Request.QueryString("id")
    sql = "select * from news_category where id="&id
    rs.Open sql, conn, 1, 3
    rs.Delete
    rs.update
    Response.Write "<script>alert('成功刪除分类！');window.location.href='news_category.asp';</script>"
End If
If request.Form("submit") = "添加新闻" Then
    title = request.Form("title")
    order_id = request.Form("order_id")
    If title = "" Then
        response.Write("<script language=javascript>alert('标题不能为空!');history.back(1)</script>")
        response.End()
    End If
    If order_id = "" Or IsNumeric(order_id) = false Then
        response.Write("<script>alert(""排序字符必须为数字！""); history.back(1);</script>")
        response.End
    End If
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select * from news_category"
    rs.Open sql, conn, 1, 3
    rs.addnew
    rs("title") = title
    rs("order_id") = order_id
    rs.update
    rs.Close
    Set rs = Nothing
    conn.Close
    Set conn = Nothing
    response.Write "<script language=javascript>alert(""新闻添加成功！"");window.location.href=""news_category.asp""</script>"
    response.End
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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" />
</head>
<body>
<!--#include file="header.asp"-->
<div id="top_banner" class="layout"></div>
<div id="content" class="layout">
  <!--#include file="left.asp"-->
  <div id="right">
    <div class="right_title">
      <h2>新闻分类调整</h2>
    </div>
    <div class="right_body">
      <table align="center" class="table">
        <%
Set rs = server.CreateObject("adodb.recordset")
exec = "select * from news_category order by order_id"
rs.Open exec, conn, 1, 1
Do While Not rs.EOF
%>
        <form method="post" >
          <tr>
            <td width="286" align="center"><input name="id" type="hidden" value="<%=rs("id")%>" />
              <input name="title" class="ce" type="text" value="<%=rs("title")%>" size="30" /></td>
            <td width="208" align="center">排序：
              <input name="order_id" type="text" class="ce" value="<%=rs("order_id")%>" size="8"></td>
            <td width="276" align="center"><input name="submit" type="submit" value="修改新闻分类" />
            <input name="delete" type="button" value="删除" onClick="javascript:if(confirm('确定要删除此新闻分类吗？删除后不可恢复!')){window.location.href='news_category.asp?act=del&id=<%=rs("id")%>';}else{history.go(0);}" /></td>
          </tr>
        </form>
        <%
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>
      </table>
    </div>
    <div class="right_title">
      <h2>添加新闻分类</h2>
    </div>
    <div class="right_body">
      <table width="98%" border="0" cellpadding="0" cellspacing="0" class="table">
        <form  method="post" >
          <tr>
            <td width="38%" height="22" align="center">分类名称：
              <input name="title" type="text" size="30"/></td>
            <td width="23%" align="center">排序：
            <input name="order_id" type="text" size="10"/></td>
            <td width="39%" align="center"><input type="submit" name="submit" value="添加分类" /></td>
          </tr>
        </form>
      </table>
    </div>
  </div>
  <div class="clear"></div>
</div>
<!--#include file="footer.asp"-->
