<!--#include file="admin_chk.asp"-->
<!--#include file="admin_conn.asp"-->
<%dim id,title,act,DateAndTime,Content
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 vote where ID="&ID
	elseif act="add" then
		sql="select * from vote"
	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("select"&i)="" then
				rs("select"&i)=""
				rs("answer"&i)=""
				end if
				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> 
