<!--#include file="conn.asp"-->
<%
'-------------------------------------
'V1.5新增页面
'功能：管理员管理网站分类(添加、修改、删除)
'更新：2004-12-27 11:55
'作者：未知-部落忍者
'演示：http://www.0cc.cn/link/
'-------------------------------------

if session("cutelink_admin")<>"OK" then
    response.redirect("admin_login.asp")
end if

dim action
action = request("action")
select case action
case "Mod"
    Call Modify
case "Add"
    Call Add
case "Del"
    Call Del
end select

sub Add
    dim TypeName,Addid
    TypeName = hx.checkstr(request("TypeName"),16)    
    dim rs
    set rs = hx.execute("select id from CL_WebType order by id desc")
    if rs.eof then
        set rs = nothing
        Addid = 1
    else
        Addid = rs(0)+1
        set rs = nothing
        hx.execute("insert into CL_WebType (id,name) values(" & Addid &",'" & TypeName & "')")
        Call AlertMsg("添加分类成功！")   
    end if
end sub

sub Del
    dim id
    id = request("id")
    if id="" or not isnumeric(id) then
        Call AlertMsg("分类ID有误！")
    else
        hx.execute("delete from CL_WebType where id=" & id)
    end if
    Call AlertMsg("删除成功！")
end sub

sub Modify
    dim id
    id = request("id")
    if id="" or not isnumeric(id) then
        Call AlertMsg("分类ID有误！")
    else
        dim TypeName
        TypeName = hx.checkstr(request("TypeName"),16)
        hx.execute("Update CL_WebType Set name='" & TypeName & "' where id=" & id)
    end if
    Call AlertMsg("修改分类名称成功！")
end sub

sub AlertMsg(strmsg)
    response.write "<script>alert('"&strmsg&"');document.location.href='admin_type.asp';</script>"
end sub
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理网站分类_<%=WebName & ChannelName%></title>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
	function del_type(thisform)
	{
	if (confirm("您确定要删除吗?")) 
	    {
	    thisform.action="?action=Del";
	    thisform.submit();
	    }
    }
</script>
</head>
<body leftmargin="0" topmargin="0">
<table border="0" align="center" cellpadding="0" cellspacing="0" class="main_title1">
  <tr> 
    <td align="center"><a href="admin_manage.asp">管理首页</a> | <a href="admin_manage.asp?action=ListSite">列出所有网站</a> | <a href="admin_manage.asp?action=ShowLog">查看点击记录</a> | 
      <font color="#0000FF">修改网站信息</font></a> | <a href="admin_manage.asp?action=BatchDelform">批量删除</a> | <a href="admin_login.asp?action=exit">退出管理</a></td>
  </tr>
</table>
<table width="768" border="0" align="center" cellpadding="3" cellspacing="0" class="main_tdbg">
  <tr> 
    <td height="30">您的位置:<a href="<%=WebUrl%>">首页</a> 
      -- <a href="admin_manage.asp">管理首页</a> -- 管理网站分类</td>
  </tr>
</table>
<table width="768" border="0" align="center" cellpadding="0" cellspacing="0" class="main_tdbg">
  <tr> 
    <td>
<%
Call ShowForm
sub ShowForm
response.write "<table>"
dim rs
set rs = hx.execute("select * from CL_WebType Order By id")
do while not rs.eof 
response.write "<tr><form action=?action=Mod method=post name=form"&rs("id")&"><td>"
response.write "<input type='text' name='TypeName' value=""" & server.htmlencode(rs("name")) &""" size='12' maxlength='16'>"
response.write "<input type='hidden' name='id' value='" & rs("id") &"'>"
response.write "</td><td>"
response.write "<input type='submit' value='修改'>"
'response.write "<input type='button' onclick='if (confirm(""您确定要删除吗?"")){this.form.action=admin_type.asp?action=Del;this.form.submit();}' value='删除'>"
response.write "<input type='button' onclick='del_type(this.form)' value='删除'>"

response.write "</td></form></tr>"
rs.movenext
loop
set rs = nothing
response.write "<tr><form action=?action=Add method=post><td>"
response.write "<input type='text' name='TypeName' value='' size='12' maxlength='16'>"
response.write "</td><td>"
response.write "<input type='submit' value='添加'>"
response.write "</td></form></tr>" 
response.write "</table>"
end sub
%>
	  </td>
  </tr>
</table>
<!--#include file="under.asp"-->
<%Closedatabase%>
</body>
</html>