<!--#include file="../inc/Conn.asp"-->
<!--#include file="Inc/Admin.Asp"-->
<%
dim ID,Title,VoteTime,IsSelected
dim rs,sql
ID=request.QueryString("id")   ' 也可用ID=request("id")

if Request.QueryString("mark")="operate" then
 ID=request("id")
 Title=trim(request.form("Title"))
 VoteTime=now()
 IsSelected=trim(request("IsSelected"))
 if IsSelected="True" then
	conn.execute "Update Vote set IsSelected=False where IsSelected=True"
 end if
 dim i

 sql="select * from Vote where ID="&ID
 Set rs_sql= Server.CreateObject("ADODB.Recordset")
 rs_sql.open sql,conn,1,3
 if not rs_sql.eof then
	 if Title<>"" then
		rs_sql("Title")=Title
		for i=1 to 8
			if trim(request("select"&i))<>"" then
				rs_sql("select"&i)=trim(request("select"&i))
				if request("answer"&i)="" then
					rs_sql("answer"&i)=0
				else
					rs_sql("answer"&i)=clng(request("answer"&i))
				end if
			else
				rs_sql("select"&i)=""
				rs_sql("answer"&i)=0
			end if
		next
		rs_sql("VoteTime")=VoteTime
		rs_sql("VoteType")=request("VoteType")
		if IsSelected="True" then
		  rs_sql("IsSelected")=True
	    else
		  rs_sql("IsSelected")=False
	    end if		
		rs_sql.update
		rs_sql.close
		Response.Redirect "VoteManage.asp"
	end if
  end if
end if  
%>

<%
sql="select * from Vote where ID="&ID
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1	
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="2%" border="0" cellpadding="0" cellspacing="1" class="border">
  <tr> 
    <td align="center" valign="top" class="topbg"><strong>修 改 调 查</strong>    </td>
  </tr>
  <tr>
    <td height="175" align="center" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
      <form method="POST" action="VoteModify.asp?mark=operate">
        <tr class="tdbg">
          <td width="15%" height="22" align="right" class=tdbgl>主题：</td>
          <td width="85%" colspan="3" class=tdbg><input name="Title" type="text" value="<%=rs("Title")%>" size="52"></td>
        </tr>
        <%
for i=1 to 8%>
        <tr class="tdbg">
          <td height="22" align="right" class=tdbgl>选项<%=i%>：</td>
          <td class=tdbg><input name="select<%=i%>" type="text" value="<%=rs("select"& i)%>" size="36">          </td>
          <td align="right" class=tdbg>票数：</td>
          <td width="80" class=tdbg><input name="answer<%=i%>" type="text" value="<%=rs("answer"&i)%>" size="5"></td>
        </tr>
        <%next%>
        <tr class="tdbg">
          <td height="22" align="right" class=tdbgl>调查类型：</td>
          <td colspan="3" class=tdbg><select name="VoteType" id="VoteType">
              <option value="Single" <% if rs("VoteType")="Single" then %> selected <% end if%>>单选</option>
              <option value="Multi" <% if rs("VoteType")="Multi" then %> selected <% end if%>>多选</option>
          </select></td>
        </tr>
        <tr class="tdbg">
          <td height="22" align="right" class=tdbgl>　</td>
          <td colspan="3" class=tdbg><input name="IsSelected" type="checkbox" id="IsSelected" value="True" <% if rs("IsSelected")=true then response.write "checked"%>>
            设为最新调查</td>
        </tr>
        <tr class="tdbg">
          <td colspan=4 align=center class=tdbg><input name="ID" type="hidden" id="ID" value="<%=rs("ID")%>">
              <input name="Submit" type="submit" id="Submit" value="保存修改结果">          </td>
        </tr>
      </form>
    </table></td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
<%
rs.close:set rs=nothing
call CloseConn()
%>