<!--#include file="conn.asp"-->
<%if request.cookies("admin")("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
else
if request.cookies("admin")("flag")>2 then
response.Write "<p align=center><font color=red>您没有此项目管理权限！</font></p>"
response.End
end if
end if
%>
<html><head><title>投票管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../image/css.css" rel=stylesheet>
<head>
<body>
<%dim action
action=request.QueryString("action")
select case action

case "del"
id=request.QueryString("id")
set rs=server.createobject("adodb.recordset")
sql="delete from toupiao where ID="&id
rs.open sql,conn,1,3
response.write "<script language=javascript>alert('确定！');window.location.href='managevote.asp';</script>"

case ""
set rs=server.createobject("adodb.recordset")
rs.open "select * from toupiao order by id desc",conn,1,1%>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<form method="POST" action="">
<tr> 
<td colspan="5" class="managetop">投票管理</td>
</tr>
<tr class="tdcolor"> 
<td width="10%" align="center">选择</td>
<td width="10%" align="center">ID</td>
<td width="60%" align="center">主题</td>
<td width="10%" align="center">修改</td>
<td width="10%" align="center">删除</td>
</tr>
<%
do while not rs.eof
%>
<tr class="tdcolor"> 
<td width="10%" align="center"> 
<input type="radio" value=<%=rs("ID")%><%if rs("IsChecked")=1 then%> checked<%end if%> name="Checked"></td>
<td width="10%" align="center"><%=rs("ID")%>　</td>
<td width="60%"><a href="votelist.asp?id=<%=rs("id")%>"><%=rs("Title")%></a></td>
<td width="10%" align="center"> 
<input onClick="javascript:window.open('?action=edit&id=<%=rs("ID")%>','_self','')" type="button" value="修改" name="button1" style="font-family: 宋体; font-size: 9pt"></td>
<td width="10%" align="center"> 
<input onClick="javascript:window.open('?action=del&id=<%=rs("ID")%>','_self','')" type="button" value="删除" name="button2" style="font-family: 宋体; font-size: 9pt"></td>
</tr>
<%rs.movenext
loop
rs.close
set rs=nothing%>
<tr class="tdcolor"> 
<td colspan=5 align=center><input onClick="javascript:window.open('managevote.asp?action=add','_self','')" type="button" value="添加新投票" name="button" style="font-family: 宋体; font-size: 9pt">
</td>
</tr>
</form>
</table>

<%case "add"%>
<SCRIPT language="JavaScript" type="text/javascript">
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1">
<form method="POST" action="?action=save">
<tr> 
<td colspan="4" class="managetop">添加新的投票</td>
</tr>
<tr class="tdcolor"> 
<td width="20%" align="right">投票主题：</td>
<td width="80%"> 
<input type="text" name="Title" size="40" style="font-family: 宋体; font-size: 9pt"></td>
</tr>
<%for i=1 to 8%>
<tr class="tdcolor"> 
<td align="right">选 项 <%=i%>：</td>
<td> 
<input type="text" name="select<%=i%>" size="25" style="font-family: 宋体; font-size: 9pt">
票 数：<input type="text" name="answer<%=i%>" size="5" value="0" style="font-family: 宋体; font-size: 9pt" onKeyPress="event.returnValue=IsDigit();" ></td>
</tr>
<%next%>
<tr class="tdcolor">
<td></td>
<td>
<input type="hidden" value="add" name="act">
<input type="submit" value=" 添 加 " name="cmdok" style="font-family: 宋体; font-size: 9pt">&nbsp;
<input type="reset" value=" 取 消 "name="cmdcancel" style="font-family: 宋体; font-size: 9pt">
<input type="button" value=" 返 回 " onClick="javascript:history.go(-1)" style="font-family: 宋体; font-size: 9pt">&nbsp;
</td>
</tr>
</form>
</table>

<%case "list"%>
<%set rs=conn.execute("SELECT * FROM toupiao where id="&request("id")&" ")%>
<table class="tableBorder" width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td height="25" style="padding-left:10px" class="managetop"><%=rs("title")%></td>
</tr>
<tr class="tdcolor">
<td style="padding-left:20px">直接复制粘贴投放到相关位置，无需做任何改动。</td>
</tr>
<tr class="tdcolor">
<td style="padding:20px"><table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><%if rs.eof then%>暂无投票<%else%>
<table border="0" width="91%" cellspacing="2" cellpadding="2">
<tr>
<td width=100% align="center"><%=rs("Title")%></td>
</tr>
<form action="http://it532.cn/bigqd/vote.asp?id=<%=rs("id")%>" target="newwindow" method=post name=research>
<tr>
<td width="100%" valign=top nowrap style="padding-left:15px">
<%for i=1 to 8
if rs("Select"&i)<>"" then%>
<input style="border: 0" <%if i=1 then%>checked<%end if%> name=Options type=radio value=<%=i%>>
<%=i%>.<%=rs("Select"&i)%><br>
<%end if
next%></td>
</tr>
<tr>
<td width="100%" height=30 align=center><input type="image" border="0" name="submit" src="../image/voteSubmit.gif" width="52" height="18" style="cursor:hand">
<a href="../vote.asp?id=<%=rs("id")%>&stype=view" target="_blank"><img src="../image/voteView.gif" width="52" height="18" border="0"></a> </td>
</tr>
</form>
</table>
<%end if%></td>
</tr>
</table></td>
</tr>
</table>

<%case "save"
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 "<script language=javascript>alert('投票主题不能为空！');history.go(-1);</script>"
response.end
Response.End 
end if
set rs=server.createobject("adodb.recordset")
if act="edit" then
sql="select * from toupiao where ID="&ID
elseif act="add" then
sql="select * from 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 "<script language=javascript>alert('操作错误！');history.go(-1);</script>"
Response.End 
end if
end if
if act="add" then rs.addnew
rs("Title")=Title
'rs("depid")=request.cookies("admin")("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 "managevote.asp"%>

<%case "edit"
id=request.QueryString("id")
set rs=server.createobject("adodb.recordset")
sql="select * from toupiao where id="&id
rs.open sql,conn,1,1
if rs.eof then
response.write "<script language=javascript>alert('操作错误！');history.go(-1);</script>"
Response.End 
else
Title=rs("Title")
DateAndTime=rs("DateAndTime")
end if%>
<SCRIPT language="JavaScript" type="text/javascript">
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
</head>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<form method="POST" action="?action=save&id=<%=id%>">
<tr> 
<td colspan="4" class="managetop">修改网站投票</td>
</tr>
<tr class="tdcolor"> 
<td width="20%" align="right">投主题：</td>
<td width="80%"> 
<input type="text" name="Title" value="<%=Title%>" size="20" style="font-family: 宋体; font-size: 9pt"></td>
</tr>
<%for i=1 to 8%>
<tr class="tdcolor"> 
<td align="right">选 项 <%=i%>：</td>
<td> 
<input type="text" name="select<%=i%>" value="<%=rs("select"&i)%>" size="20" style="font-family: 宋体; font-size: 9pt"> 票数：<input type="text" name="answer<%=i%>" value="<%=rs("answer"&i)%>" size="5" style="font-family: 宋体; font-size: 9pt"></td>
</tr>
<%next%>
<tr class="tdcolor"> 
<td align="right">发布时间：</td>
<td><%=DateAndTime%></td>
</tr>
<tr class="tdcolor"> 
<td colspan=2 align=center> 
<input type="hidden" value="edit" name="act">
<input type="submit" value=" 修 改 " name="cmdok" style="font-family: 宋体; font-size: 9pt">&nbsp;
<input type="reset" value=" 清 除 "name="cmdcancel" style="font-family: 宋体; font-size: 9pt">
<input type="button" value=" 返 回 " onClick="javascript:history.go(-1)" style="font-family: 宋体; font-size: 9pt">&nbsp;
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<%rs.close
set rs=nothing%>

<%end select%>
</body>
</html>