<%
if session("admin")<>"on" then
Response.Redirect"login.asp"
end if
%>
<!--#include file="mdb/conn.asp" -->
<!--#include file="info.asp" -->
<%

if Request.Form("cz")="" then
cz=Request.QueryString("cz")
else
cz=Request.Form("cz")
end if

if cz="addtype" or cz="editclass" then

if Request.Form("classname")="" then
Response.Redirect"info.asp?info=请填写分类名称"
end if
Set rs = Server.CreateObject("ADODB.Recordset")
if cz="editclass" then
sql = "SELECT * FROM type where id="&Request.Form("classid") 
rs.OPEN sql,Conn,1,3
else
sql = "SELECT * FROM type where (id is null)" 
rs.OPEN sql,Conn,1,3
rs.addnew
end if
rs("name")=Request.Form("classname")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.Redirect"admin.asp"

elseif cz="addtype" or cz="edittype" then

founderr=false
if trim(Request.Form("typename"))="" then
founderr=true
info=info+"<li>请填写分类名称</li>"
end if

if founderr=false then

Set rs = Server.CreateObject("ADODB.Recordset")
if cz<>"edittype" then
sql = "SELECT * FROM type where (id is null)" 
rs.OPEN sql,Conn,1,3
rs.addnew
else
sql = "SELECT * FROM type where id="&Request.Form("typeid") 
rs.OPEN sql,Conn,1,3
end if
rs("name")=Request.Form("typename")
if Request.Form("minipic")<>"" then
rs("minipic")=Request.Form("minipic")
else
rs("minipic")="images/nominipic.gif"
end if
rs("typeid")=Request.Form("typeid")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.Redirect"admin.asp"
else
call infom()
end if

elseif cz="delclass" then

conn.execute "delete from type where id="&Request.Form("classid")
conn.execute "delete from desktop where typeid="&Request.Form("classid")
conn.close
Set conn=Nothing
Response.Redirect"admin.asp"

elseif cz="deltype" then

conn.execute "delete from type where id="&Request.Form("typeid")
conn.execute "delete from desktop where typeid="&Request.Form("typeid")
conn.close
Set conn=Nothing
Response.Redirect"admin.asp"

end if
%>