<%@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>
<div id="content">
  <div id="right">
    <div class="right_body"><br />
    </div>
    <div class="right_body"></div>
  </div>
  <div class="clear">
    <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">
                <%
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 action="news_category.asp?update=ok" method="post" name="news_category" id="news_category">
                  <tr>
                    <td class="td"><input name="id" type="hidden" value="<%=rs("id")%>" />
                        <input name="title2" type="text" class="input" id="title2" value="<%=rs("title")%>" size="30" /></td>
                    <td class="td"><input name="order_id2" 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="修改分类" />
                        </td>
                  </tr>
                </form>
                <%rs.movenext
Next
%>
                <%
End If
%>
              </table>
                <span class="right_body">
                <%'以下显示分页
Call PageControl(iCount, maxpage, page, "border=0 align=center", "<p align=center>")
rs.Close
Set rs = Nothing
%>
              </span></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>
    <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="title" type="text" class="input" size="30" /></td>
                  </tr>
                  <tr>
                    <th class="td">排序：</th>
                    <td class="td"><input name="order_id" 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="submit" 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>
  </div>
</div>
<div id="footer" class="layout"></div>
</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("title2")
    order_id = request.Form("order_id2")
    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"-->
