<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file = "../admin/tuzh_pri.asp"-->
<!--#include file="conn.asp"-->
<%vid=request("vid")
aact=request("aact")
vtitle=request.form("addtitle")
modicf=request.form("modicf")
id=request("id")
doact=request("doact")
okmodi=request("txtmodi")
modiact=request("modiact")
modiact2=request("modiact2")
modicf=request.form("modicf")
modikind=request.form("modikind")
modititle=request.form("modititle")

if aact="addt" then
conn.execute("insert into vitem (vid,vtitle) values ("&vid&",'"&vtitle&"')")
response.redirect "voteitem.asp?vid="& vid '&"&id="&id
end if

if doact="dele" then
conn.execute("delete from vitem where id="&cint(id))
response.redirect "voteitem.asp?vid="& vid '&"&id="&id
end if

if doact="modi" then
set rsmodi=conn.execute("select * from vitem where id="&cint(id))
moditxt=rsmodi("vtitle")
end if

if modiact2="modi" then
set rs=server.createobject("ADODB.recordset")
sql="select * from vname where id="&cint(vid)
rs.open sql,conn,1,3
			rs("title") = modititle
			rs("cf") = modicf
			rs("kind") = modikind
			rs.update
rs.close
response.redirect "voteitem.asp?vid="& vid '&"&id="&id
end if

if modiact="ok" then
okmodi=request("txtmodi")
conn.execute("update vitem set vtitle='"&okmodi&"' where id="&id&"")
response.redirect "voteitem.asp?vid="& vid '&"&id="&id

end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=site_name%></title>
<script language=javascript>
function SureDel(vid,id)
{
    if ( confirm("警告!你是否真的要删除？"))
        {
            window.location.href ="voteitem.asp?vid=" + vid  + "&doact=dele&id=" + id
        }
}
</script>
<link rel="stylesheet" type="text/css" href="../img/css.css">
<style type=text/css>
body  {
SCROLLBAR-FACE-COLOR: #9CC5D7;
SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; 
SCROLLBAR-SHADOW-COLOR: #006699; 
SCROLLBAR-3DLIGHT-COLOR: #006699; 
SCROLLBAR-ARROW-COLOR: #330000; 
SCROLLBAR-TRACK-COLOR: #E2F3F1; 
SCROLLBAR-DARKSHADOW-COLOR: #ffffff;}
</style>
</head>

<body>
<table class="border" width="98%" border="0" align="center" cellpadding="1" cellspacing="0">
  <tr> 
    <td height="540" align="center" valign="top" class="bg_low"> <table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td align="center" valign="middle" class="bgtop"><font color="#FFFFFF"><b>修改投票</b></font> 
          </td>
        </tr>
      </table>
        <%set rs=server.createobject("ADODB.recordset")
sql="select * from vname where id="&cint(vid)&""
rs.open sql,conn,1,1
if not rs.eof then%>
        <br/>
        <table width="98%" border="5" cellpadding="0" cellspacing="0" bordercolor="#ABCEDD">
          <tr>
            <td align="center"><br />
              <form id="form2" name="form2" method="post" action="?modiact2=modi&id=<%=id%>&vid=<%=vid%>">
                
              <table width="98%" border="1" cellpadding="2" cellspacing="0" bordercolor="#ABCEDD">
                <tr> 
                    <td width="228">标题</td>
                    <td width="122">是否重复投票</td>
                    <td width="73">单选/多选</td>
                  </tr>
                  <tr> 
                    <td><label> 
                      <input name="modititle" type="text" size="20" value="<%=rs("title")%>"/>
                      </label> &nbsp;</td>
                    <td>&nbsp; <select name="modicf">
                        <option value="y" <%if rs("cf")="y" then response.Write("selected") end if%>>可以</option>
                        <option value="n" <%if rs("cf")="n" then response.Write("selected") end if%>>不可以</option>
                      </select> </td>
                    <td><%=rs("kind")%>&nbsp; <select name="modikind">
                        <option value="1" <%if rs("kind")="1" then response.Write("selected") end if%>>单选</option>
                        <option value="2" <%if rs("kind")="2" then response.Write("selected") end if%>>多选</option>
                      </select> </td>
                  </tr>
                </table>
                <input type="submit" name="Submit3" value="修改投票信息" />
              </form>
        </td>
          </tr>
        </table>
      <br />
      <br />
      <br />
      <br />
          <center>
        <table width="98%" border="5" cellpadding="0" cellspacing="0" bordercolor="#ABCEDD">
          <tr>
            <td align="center"><center>
                <br />
              </center>
              <table width="98%" border="1" cellspacing="0" cellpadding="2" bordercolor="#ABCEDD">
                <tr> 
                  <td>编号</td>
                  <td>投票选项</td>
                  <td>票数</td>
                  <td>操作</td>
                  <td>操作</td>
                </tr>
                <%else%>
                <table width="600"  border="1" cellpadding="2" cellspacing="0" bordercolor="#E8E8E8">
                  <tr> 
                    <td colspan="5" align="center" bgcolor="#999900">该投票不存在或已经被删除！</td>
                  </tr>
                  <%
	response.End()
	end if%>
                  <%
	rs.close
	i=0
	set rs=server.createobject("ADODB.recordset")
	sql="select * from vitem where vid="&cint(vid)
	rs.open sql,conn,1,1
	if rs.eof then%>
                  <tr> 
                    <td colspan="5" align="center" >本投票的投票选项还未添加</td>
                  </tr>
                  <% else
	do while not rs.eof
	i=i+1
	%>
                  <tr> 
                    <td width="45"><%=i%></td>
                    <td width="309"><%=rs("vtitle")%></td>
                    <td width="32"><%=rs("vcount")%></td>
                    <td width="42"> <input type="button" name="modi" value="修改"  onclick="window.location.href='voteitem.asp?vid=<%=vid%>&doact=modi&id=<%=rs("id")%>'" /> 
                    </td>
                    <td width="87"><input name="dele" type="button" id="dele3" value="删除"   onclick="SureDel(<%=vid%>,<%=rs("id")%>);"/></td>
                  </tr>
                  <%  
	rs.movenext
	loop
	end if
	rs.close
	'end if
%>
                </table>
                <br />
                <%if doact<>"modi" then%>
                <form id="form1" name="form1" method="post" action="">
                  <table width="98%" border="1" cellpadding="2" cellspacing="0" bordercolor="#ABCEDD">
                    <tr> 
                      <td width="302"  height="23" valign="top"><label> 增加选项 
                        <input name="addtitle" type="text" id="addtitle3" size="30" />
                        </label></td>
                      <td width="42" valign="top"><label> 
                        <input type="submit" name="Submit" value="增加选项" />
                        <input type="hidden" name="aact" value="addt" />
                        <input type="hidden" name="vid" value="<%=vid%>" />
                        </label></td>
                    </tr>
                  </table>
                </form>
                <%else%>
                <form action="?modiact=ok&id=<%=id%>&vid=<%=vid%>" method="post">
                  <label> 
                  <input name="txtmodi" type="text" id="txtmodi3"  value="<%=moditxt%>"/>
                  </label>
                  <label> 
                  <input type="submit" name="Submit2" value="修改" />
                  </label>
                </form>
                <%end if%>
              </table></td>
          </tr>
        </table>
      </center>
        </td>
  </tr>
</table>
</body>
</html>
