<!--#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,url,i,abc,categoryid,category,id
category=FormatSQL(SafeRequest("category",0))
categoryid=SafeRequest("categoryid",1)
url="http://" & Request.ServerVariables("http_host") & finddir(Request.ServerVariables("url"))
action=FormatSQL(SafeRequest("action",0))
id=SafeRequest("id",1)

select case action
case "add"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from sorts",conn,1,3
rs.AddNew
rs("sorts")=trim(request.form("sorts2"))
rs("sortsorder")=request.form("sortsorder2")
rs("categoryid")=request.form("categoryid")
rs("first")=request.form("first2")
rs.Update
rs.Close
set rs=nothing
response.redirect url&"sclass.asp?id="&categoryid&"&category="&category

case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from sorts where sortsid="&id,conn,1,3
rs("sorts")=trim(request.form("sorts"))
rs("sortsorder")=int(request.form("sortsorder"))
rs("first")=int(request.form("first"))
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('修改成功！');history.go(-1);</script>"
response.End

case "del"
conn.execute ("delete from sorts where sortsid="&id)
conn.execute ("delete from product where sortsid="&id)
response.redirect url&"sclass.asp?id="&categoryid&"&category="&category
end select
%>
<%
Function finddir(filepath)
	finddir=""
	for i=1 to len(filepath)
	if left(right(filepath,i),1)="/" or left(right(filepath,i),1)="\" then
	  abc=i
	  exit for
	end if
	next
	if abc <> 1 then
	finddir=left(filepath,len(filepath)-abc+1)
	end if
end Function
%>