<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn.asp"-->
<!--#include file="../seeion.asp"-->
<!--#include file="../page.asp"-->
<!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><%=site_info("title")%>-后台管理系统</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
</head>
<body>
      <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
        <%
Set rs = server.CreateObject("adodb.recordset")
exec = "select * from news_category order by order_id asc"
rs.Open exec, conn, 1, 1
If rs.EOF Then
    response.Write "&nbsp;暂无新闻分类！"
Else
    rs.PageSize = 10 '每页记录条数
    iCount = rs.RecordCount '记录总数
    iPageSize = rs.PageSize
    maxpage = rs.PageCount
    page = request("page")
    If Not IsNumeric(page) Or page = "" Then
        page = 1
    Else
        page = CInt(page)
    End If
    If page<1 Then
        page = 1
    ElseIf page>maxpage Then
        page = maxpage
    End If
    rs.AbsolutePage = Page
    If page = maxpage Then
        x = iCount - (maxpage -1) * iPageSize
    Else
        x = iPageSize
    End If
%>
        <tr>
          <th width="200" class="td2">新闻分类</th>
          <th width="40" class="td2">排序</th>
          <th class="td2">链接地址</th>
          <th width="140" class="td2">修改操作</th>
        </tr>
        <%For i=1 To x%>
        <form name="news_category" method="post" action="news_category.asp?update=ok">
          <tr>
            <td class="td"><input name="id" type="hidden" value="<%=rs("id")%>" />
            <input name="title" type="text" class="input" value="<%=rs("title")%>" size="30" /></td>
            <td class="td"><input name="order_id" type="text" class="input" value="<%=rs("order_id")%>" size="4"></td>
            <td class="td">news_category.asp?id=<%=rs("id")%> <a href="../../news_category.asp?id=<%=rs("id")%>">[访问]</a></td>
            <td class="td"><input name="update" type="submit" class="button" value="修改分类" />
            <input name="delete" type="button" class="button" onClick="javascript:if(confirm('确定要删除此导航栏吗？删除后不可恢复!')){window.location.href='news_category.asp?act=del&id=<%=rs("id")%>';}else{history.go(0);}" value="删除" /></td>
          </tr>
        </form>
        <%rs.movenext
Next
%>
        <%
End If
%>
</table>
      <%'以下显示分页
Call PageControl(iCount, maxpage, page, "border=0 align=center", "<p align=center>")
rs.Close
Set rs = Nothing
%>
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="52"><img src="../images/main_1.jpg" width="52" height="55" /></td>
        <td background="../images/main_2.jpg" class="title1">添加新闻分类</td>
        <td width="52"><img src="../images/main_3.jpg" width="52" height="55" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" background="../images/main_4.gif">&nbsp;</td>
        <td background="../images/main_9.gif"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
          <form action="news_category.asp?add=ok" method="post" name="news_category_add" id="news_category_add">
            <tr>
              <th width="80" class="td">分类名称：</th>
              <td class="td"><input name="title2" type="text" class="input" size="30" /></td>
            </tr>
            <tr>
              <th class="td">排序：</th>
              <td class="td"><input name="order_id2" type="text" class="input" size="5" /></td>
            </tr>
            <tr>
              <td class="td"><p class="submit">&nbsp;</p></td>
              <td class="td"><span class="submit">
                <input name="submit2" type="submit" class="button" value="添加分类" />
              </span></td>
            </tr>
          </form>
        </table></td>
        <td width="15" background="../images/main_5.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="52"><img src="../images/main_6.gif" width="52" height="16" /></td>
        <td background="../images/main_7.gif" width="100%"></td>
        <td width="52"><img src="../images/main_8.gif" width="52" height="16" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<%
If Request.QueryString("update") = "ok" Then
    id = request("id")
    sql = "select * from news_category where id="&id
    Set rs = server.CreateObject("adodb.recordset")
    rs.Open sql, conn, 1, 3
    title = request.Form("title")
    order_id = request.Form("order_id")
    If title = "" Then
        response.Write("<script language=javascript>alert('单页标题不能为空!');history.go(-1)</script>")
        response.End
    End If
    If order_id = "" Then
        response.Write("<script language=javascript>alert('排序数字不能为空!');history.go(-1)</script>")
        response.End
    End If
    If Not IsNumeric(request("order_id")) Then
        response.Write("<script language=javascript>alert('排序字符必须为数字!'); history.go(-1);</script>")
        response.End
    End If
    rs("title") = title
    rs("order_id") = order_id
    rs.update
    rs.Close
    response.Write("<script language=""javascript"">alert('修改成功！');window.location.href='news_category.asp';</script>")
End If
%>
<%
If Request.QueryString("add") = "ok" Then
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from news_category"
    rs.Open sql, conn, 1, 3
    title = request.Form("title")
    order_id = request.Form("order_id")
    If title = "" Then
        response.Write("<script language=javascript>alert('分类名称不能为空！');history.go(-1)</script>")
        response.End
    End If
    If order_id = "" Then
        response.Write("<script language=javascript>alert('排序数字不能为空！');history.go(-1)</script>")
        response.End
    End If
    If Not IsNumeric(request("order_id")) Then
        response.Write("<script language=javascript>alert('排序字符必须为数字！'); history.go(-1);</script>")
        response.End
    End If
    rs.addnew
    rs("title") = title
    rs("order_id") = order_id
    rs.update
    rs.Close
    Set rs = Nothing
    conn.Close
    Set rs = Nothing
    Response.Write "<script language=javascript>alert('添加成功！');window.location.href='news_category.asp';</script>"
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, 2, 3
    rs.Delete
    rs.update
    Response.Write "<script>alert('刪除成功！');window.location.href='news_category.asp';</script>"
End If
%>
<!--#include file="../close.asp"-->
