<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权管理商品大类！');history.go(-1);</script>"
response.End
end if
%>
<% dim action,categoryid
categoryid=SafeRequest("id",1)
action=FormatSQL(SafeRequest("action",0))
select case action

case "add" 
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from category",conn,1,3
rs.AddNew
rs("category")=trim(request.form("category2"))
rs("categoryorder")=int(request.form("categoryorder2"))
rs("first")=int(request.form("first2"))
rs.Update
rs.Close
set rs=nothing
response.Redirect "bclass.asp"

case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from category where categoryid="&categoryid,conn,1,3
rs("category")=trim(request.form("category"))
rs("catpic")=trim(request.form("catpic"))
rs("caturl")=trim(request.form("caturl"))
rs("categoryorder")=int(request.form("categoryorder"))
rs("first")=int(request.form("first"))
rs.Update
rs.Close
set rs=nothing
response.Redirect "bclass.asp"

case "del"
conn.execute ("delete from category where categoryid="&categoryid)
conn.execute ("delete from sorts where categoryid="&categoryid)
conn.execute ("delete from product where categoryid="&categoryid)
response.Redirect "bclass.asp"
end select
%>