<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限！</b></font></div>"
response.End
end if
end if

dim id,title,act,DateAndTime,Content,sql,i
ID=request.QueryString("id")
Title=trim(request.form("Title"))
act=request("act")
if DateAndTime="" then DateAndTime=now()
Content=trim(request.form("Content"))
if Title="" then
response.write "<meta http-equiv=""refresh"" content=""2;url=javascript:history.go(-1)"">"
response.write("<table width=400 border=0 cellspacing=0 cellpadding=0 align=center>")
response.write("<tr><td>对不起，投票主题不能为空！</td></tr>")
response.write(" <tr><td><a href=vbscript:history.back()>回去重来</a>,2秒钟后自动返回</td></tr>")
response.write("</table>")
response.end
	Response.End 
end if

	set rs=server.createobject("adodb.recordset")
	if act="edit" then
		sql="select * From shop_toupiao where ID="&ID
	elseif act="add" then
		sql="select * From shop_toupiao"
	end if
	rs.open sql,conn,1,3
	if act="add" or act="edit" then
		if act="edit" then
			if rs.eof then
response.write "<meta http-equiv=""refresh"" content=""2;url=javascript:history.go(-1)"">"
response.write("<table width=400 border=0 cellspacing=0 cellpadding=0 align=center>")
response.write("<tr><td>操作错误！</td></tr>")
response.write(" <tr><td><a href=vbscript:history.back()>回去重来</a>,2秒钟后自动返回</td></tr>")
response.write("</table>")
				Response.End 
			end if
		end if
		if act="add" then rs.addnew
		rs("Title")=Title
		'rs("depid")=session("UserDepID")
		for i=1 to 8
			if request("select"&i)<>"" then
				rs("select"&i)=request("select"&i)
				if request("answer"&i)="" then
					rs("answer"&i)=0
				else
					rs("answer"&i)=request("answer"&i)
				end if
			end if
		next
		rs("dateandtime")=now()
		rs.update
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
	Response.Redirect "voteManage.asp"
%></body></html>