if request("id")"del" then
err=0
title=request("title")
if title="" then
err=1
error=error+"标题不能为空\n"
end if
a=0
for i=1 to request("xz").count
if request("xz")(i)="" then
exit for
end if
a=a+1
next
if a=0 then
err=1
error=error+"选择内容不能为空\n"
end if
if err=1 then
response.write "alert('"&error&"');"
response.write "history.back(1);"
response.end
end if
end if
if request("id")="xg" then
conn.execute("update class set title='"&title&"',style='"&request("style")&"' where id="&request("classid"))
conn.execute("delete from vote where class="&request("classid"))
for i=1 to request("xz").count
if request("xz")(i)"" then
conn.execute("insert into vote (vote,color,class) values ('"&request("xz")(i)&"','"&request("color")(i)&"',"&request("classid")&")")
else
exit for
end if
next
response.write "alert('修改投票成功');"
response.write "location.href='votelist.asp';"
elseif request("id")="del" then
conn.execute("delete from vote where class="&request("classid"))
conn.execute("delete from class where id="&request("classid"))
response.write "alert('删除投票成功');"
response.write "location.href='votelist.asp';"
else
conn.execute("insert into class (title,style,ren) values ('"&title&"','"&request("style")&"','"&request.cookies("admin")&"')")
set rs=server.createobject("adodb.recordset")
sql="select top 1 * from class where title='"&title&"' order by id desc"
rs.open sql,conn,3,1
classid=rs("id")
rs.close
set rs=nothing
for i=1 to request("xz").count
if request("xz")(i)"" then
conn.execute("insert into vote (vote,color,class) values ('"&request("xz")(i)&"','"&request("color")(i)&"',"&classid&")")
else
exit for
end if
next
response.write "alert('添加投票成功');"
response.write "location.href='step1.asp';"
end if
conn.close
set conn=nothing
%>