<html>
<head>
<META content=ywnt,云网互动影视管理系统 name=keywords>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>云网互动影视6.0--投票管理</title>
<LINK href="css/css.css" type=text/css rel=stylesheet>
</head>
<BODY leftMargin=0 topMargin=0 scroll=yes MARGINHEIGHT="0" MARGINWIDTH="0">
<script language="JavaScript" src="YWNT_TMS_Inc/YWNT_TMS_Common.js"></script>
<script language="JavaScript" src="YWNT_TMS_Inc/Calendar.js"></script>
<!--#include file="../Conn.asp" -->
<!--#include file="YWNT_TMS_inc/YWNT_TMS_Function.asp" -->
<%
'===================================================================================================================
'软件名称：云网影视管理系统
'Copyright (C) 2002-2007 ywnt.net  All rights reserved.
'产品咨询QQ：489234,2813712
'程序版权：云网互动科技有限公司
'程序开发：云网互动科技有限公司
'官方网站：http://www.ywnt.net 
'郑重声明:
'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
'    2、任何个人或组织不得在授权允许的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    3、云网互动科技有限公司保留此软件的法律追究权利
'===================================================================================================================
Call CheckLogin("Vote")
sub EditSave()
		Set Rs=Server.CreateObject(YWNT_TMS_RS)
		sql="select * from YWNT_TMS_VoteClass where ID="&NoSqlHack(Request.Form("ID"))
		Rs.open sql,Conn,1,3
		RS("VoteName")=NoSqlHack(Request.Form("VoteName"))
		RS("VoteType")=NoSqlHack(Request.Form("VoteType"))
		RS("VoteMaxNum")=NoSqlHack(Request.Form("VoteMaxNum"))
		RS("StartDate")=NoSqlHack(Request.Form("StartDate"))
		RS("EndDate")=NoSqlHack(Request.Form("EndDate"))
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		call EditVote("EditVote","EditVoteNum","EditColor",NoSqlHack(Request.Form("ID")))
		if Request.Form("Vote1")<>"" then
		call AddVote(NoSqlHack(Request.Form("VoteVolume")),"Vote","Color",NoSqlHack(Request.Form("ID")))
		end if
		Call AddLog("修改投票"&Request.Form("VoteName"),9)
		call Admin_ShowErr("<li>投票修改成功</li>","Admin_Vote.asp",1)
end sub
sub AddSave()
		Set Rs=Server.CreateObject(YWNT_TMS_RS)
		sql="select * from YWNT_TMS_VoteClass"
		Rs.open sql,Conn,1,3
		Rs.addnew
		RS("VoteName")=NoSqlHack(Request.Form("VoteName"))
		RS("VoteType")=NoSqlHack(Request.Form("VoteType"))
		RS("VoteMaxNum")=NoSqlHack(Request.Form("VoteMaxNum"))
		RS("StartDate")=NoSqlHack(Request.Form("StartDate"))
		RS("EndDate")=NoSqlHack(Request.Form("EndDate"))
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		set RS = Conn.execute("select top 1 ID from YWNT_TMS_VoteClass Order by ID desc")
		ID=RS("ID")
		Rs.Close
		Set Rs = Nothing
		if Request.Form("Vote1")<>"" then
		call AddVote(NoSqlHack(Request.Form("VoteVolume")),"Vote","Color",ID)
		end if
		Call AddLog("添加投票"&Request.Form("VoteName"),9)
		call Admin_ShowErr("<li>投票添加成功</li>","Admin_Vote.asp",1)
end sub
sub Del()
	conn.execute "delete from YWNT_TMS_VoteClass WHERE ID="&NoSqlHack(Request.QueryString("ID"))
	conn.execute "delete from YWNT_TMS_Vote WHERE VoteID="&NoSqlHack(Request.QueryString("ID"))
	Call AddLog("删除投票",9)
	call Admin_ShowErr("<li>投票删除成功！</li>","Admin_Vote.asp",1)
end sub
sub DelVote()
	conn.execute "delete from YWNT_TMS_Vote WHERE ID="&NoSqlHack(Request.QueryString("ID"))
	response.redirect Request.ServerVariables("HTTP_REFERER")
end sub%>
<table class=table cellspacing=1 cellpadding=3 width="98%" align=center border=0>
  <tbody>
    <tr>
      <td class=xingmu>投票管理</td>
    </tr>
    <tr>
      <td class="hback"><a href="Admin_Vote.asp">管理首页</a> | <a href="Admin_Vote.asp?Action=Add">添加投票</a> </td>
    </tr>
  </tbody>
</table>
<% Action=Trim(request.QueryString("Action"))
Select Case Action
Case "Add"
	call Add()
Case "AddSave"
	call AddSave()
Case "Edit"
		Set Rs=Server.CreateObject(YWNT_TMS_RS)
		sql="select * from YWNT_TMS_VoteClass where ID="&NoSqlHack(Request.QueryString("ID"))
		Rs.open sql,Conn,1,1
		YWNT_TMS_ID=RS("ID")
		YWNT_TMS_VoteName=RS("VoteName")
		YWNT_TMS_VoteType=RS("VoteType")
		YWNT_TMS_VoteMaxNum=RS("VoteMaxNum")
		YWNT_TMS_StartDate=RS("StartDate")
		YWNT_TMS_EndDate=RS("EndDate")
		RS.close   
      	set RS=nothing
	call Edit()
Case "EditSave"
	call EditSave()
Case "Del"
	call Del()
Case "DelVote"
    call DelVote()
Case else
	call List()
End Select
sub List()%>
<table class=table cellspacing=1 cellpadding=3 width="98%" align=center border=0>
  <tbody>
    <tr>
      <td width="5%" align="center" class=xingmu>ID</td>
      <td align="center" class=xingmu>标题</td>
      <td width="15%" align="center" class=xingmu>操作</td>
    </tr>
		<%Set Rs = server.CreateObject(YWNT_TMS_RS)
		sql="Select ID,VoteName from YWNT_TMS_VoteClass Order by ID asc"
		Rs.open sql,Conn,1,1
		if RS.eof then
		Response.Write"<tr><td colspan=""5"" height=40 class=""hback"">没有投票</td></tr>"
		else
		do while not RS.eof%>
    <tr>
      <td height=32 align="center" class="hback"><%=RS("ID")%></td>
      <td height=32 class="hback"><%=RS("VoteName")%></td>
      <td align="center" class="hback"><A href="Admin_Vote.asp?Action=Edit&ID=<%=RS("ID")%>">修改</A>｜<A href="Admin_Vote.asp?Action=Del&ID=<%=RS("ID")%>">删除</A></td>
    </tr>
	<%Rs.MoveNext
	loop 
	end if
	RS.close     
	set RS=nothing%>
  </tbody>
</table>
<%end sub
sub Add()%>
<script language="javascript">
function setid()
{
str='';
if(!window.form.VoteVolume.value)
window.form.VoteVolume.value=4;
for(i=1;i<=window.form.VoteVolume.value;i++)
{
str+='<div style="height: 30px;"><input type="text" name="Vote'+i+'" value="" size="40"><input name="Color'+i+'" type="hidden" value="">'
str+='<img src="../Editor/icons/btColor.gif" width="16" height="15" class="overBorder" onClick=\'p=showModalDialog("../Editor/SelectColor.asp",window,"center:yes;dialogHeight:251px;dialogWidth:300px;help:no;status:no");if(p!=null){this.style.backgroundColor=Color'+i+'.value=p.split("*")[0]}else{this.style.backgroundColor=""}\'></div>';
}
document.all.Voteup.innerHTML=str;
}
</script>
<table class=table cellspacing=1 cellpadding=3 width="98%" align=center border=0>
 <form name="form" action="Admin_Vote.asp?Action=AddSave" method="post">
  <tbody>
    <tr>
      <td colspan="2" class=xingmu>投票添加</td>
    </tr>
    <tr>
      <td width="21%" height=32 align="right" class="hback">投票主题：</td>
      <td height=7 class="hback"><input name="VoteName" type="text" id="VoteName" size="40"></td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">类型：</td>
      <td height=7 class="hback"><INPUT name=VoteType type=radio value=0 checked>
        单选
          <INPUT type=radio value=1 name=VoteType>
        多选</td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">最多选项个数：</td>
      <td height=7 class="hback"><INPUT id=VoteMaxNum maxLength=4 size=5 value=1 name=VoteMaxNum>
        最多选项个数,只针对多选</td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">开始时间：</td>
      <td height=16 class="hback"><INPUT id=StartDate onfocus=setday(this) readOnly value="" name=StartDate maskType="longDate" realValue="">
        <IMG onclick=StartDate.focus() src="images/calendar.gif" align=absBottom></td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">到期时间：</td>
      <td height=16 class="hback"><INPUT id=EndDate onfocus=setday(this) readOnly value="" name=EndDate maskType="longDate" realValue="">
        <IMG onclick=EndDate.focus() src="images/calendar.gif" align=absBottom></td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">选择项个数：</td>
      <td height=16 class="hback"><INPUT size=6 value=4 name=VoteVolume><INPUT type=button  onclick="setid();" value="设 定">
    </td>
    </tr>
    <tr>
      <td height=32 align="right" class="hback">选项：</td>
      <td height=16 class="hback" ID="Voteup"></td>
    </tr>
    <tr>
      <td height=32 colspan="2" align="center" class="hback"><input type="submit" name="Submit" value="添 加"></td>
    </tr>
  </tbody>
</form>
</table>
<%end sub
sub Edit()%>
<table class=table cellspacing=1 cellpadding=3 width="98%" align=center border=0>
  <form name="form" action="Admin_Vote.asp?Action=EditSave" method="post">
    <tbody>
      <tr>
        <td colspan="2" class=xingmu>投票修改</td>
      </tr>
      <tr>
        <td width="21%" height=32 align="right" class="hback">投票主题：</td>
        <td height=7 class="hback"><input name="VoteName" type="text" id="VoteName" value="<%=YWNT_TMS_VoteName%>" size="40"></td>
      </tr>
      <tr>
        <td height=32 align="right" class="hback">类型：</td>
        <td height=7 class="hback"><INPUT name="VoteType" type="radio" value=0 <%if YWNT_TMS_VoteType=0 then Response.Write"checked"%>>
          单选
            <INPUT type="radio" value=1 name="VoteType" <%if YWNT_TMS_VoteType=1 then Response.Write"checked"%>>
          多选</td>
      </tr>
      <tr>
        <td height=32 align="right" class="hback">最多选项个数：</td>
        <td height=7 class="hback"><INPUT id="VoteMaxNum" maxLength="4" size="5" value="<%=YWNT_TMS_VoteMaxNum%>" name=VoteMaxNum>
          最多选项个数,只针对多选</td>
      </tr>
      <tr>
        <td height=32 align="right" class="hback">开始时间：</td>
        <td height=16 class="hback"><INPUT id="StartDate" onfocus=setday(this) readOnly value="<%=YWNT_TMS_StartDate%>" name="StartDate" maskType="longDate" realValue="">
            <IMG onclick=StartDate.focus() src="images/calendar.gif" align=absBottom></td>
      </tr>
      <tr>
        <td height=32 align="right" class="hback">到期时间：</td>
        <td height=16 class="hback"><INPUT id=EndDate onfocus=setday(this) readOnly value="<%=YWNT_TMS_EndDate%>" name="EndDate" maskType="longDate" realValue="">
            <IMG onclick=EndDate.focus() src="images/calendar.gif" align=absBottom></td>
      </tr>
      <tr>
        <td height=32 align="right" class="hback">选择项个数：</td>
        <td height=16 class="hback"><INPUT size="6" value="1" name="VoteVolume">
            <INPUT type=button  onclick="setid();" value="设 定">
        </td>
      </tr>
      <tr>
        <td height=32 rowspan="2" align="right" class="hback">选项：</td>
        <td height=16 class="hback">
<% Set Rs = server.CreateObject(YWNT_TMS_RS)
sql="Select * from YWNT_TMS_Vote where VoteID="&YWNT_TMS_ID&""
Rs.open sql,Conn,1,1
do while not RS.eof
i=i+1
Response.Write"<div style=""height: 30px;""><input type=""text"" name=""EditVote"&i&""" size=40 value="""&RS("Vote")&""">"
Response.Write"<input name=""EditColor"&i&""" type=""hidden"" value="""&RS("Color")&""">"
Response.Write"<img src=""../Editor/icons/btColor.gif"" width=""16"" height=""15"" class=""overBorder"" style=""background-color:"&RS("Color")&""" onClick='p=showModalDialog(""../Editor/SelectColor.asp"",window,""center:yes;dialogHeight:251px;dialogWidth:300px;help:no;status:no"");if(p!=null){this.style.backgroundColor=EditColor"&i&".value=p.split(""*"")[0]}else{this.style.backgroundColor=""""}'>"
Response.Write"&nbsp;&nbsp;投票数：&nbsp;<input name=""EditVoteNum"&i&""" type=""text"" size=""6"" value="""&RS("VoteNum")&""">"
Response.Write"&nbsp;&nbsp;&nbsp;<a href=""Admin_Vote.asp?Action=DelVote&id="&RS("ID")&"""><font color=""#FF0000"">删除</font></a></div>" &vbcrlf
RS.movenext     
loop
RS.close    
set RS=nothing %></td>
      </tr>
	  	<tr>
  		<td class="hback" id="Voteup"></td>
		</tr>
      <tr>
        <td height=32 colspan="2" align="center" class="hback"><input name="ID" type="hidden" value="<%=YWNT_TMS_ID%>">
        <input type="submit" name="Submit" value="修 改"></td>
      </tr>
    </tbody>
  </form>
</table>
<script language="javascript">
function setid()
{
str='';
if(!window.form.VoteVolume.value)
window.form.VoteVolume.value=1;
for(i=1;i<=window.form.VoteVolume.value;i++)
{
str+='<div style="height: 30px;"><input type="text" name="Vote'+i+'" value="" size="40"><input name="Color'+i+'" type="hidden" value="">'
str+='<img src="../Editor/icons/btColor.gif" width="16" height="15" class="overBorder" onClick=\'p=showModalDialog("../Editor/SelectColor.asp",window,"center:yes;dialogHeight:251px;dialogWidth:300px;help:no;status:no");if(p!=null){this.style.backgroundColor=Color'+i+'.value=p.split("*")[0]}else{this.style.backgroundColor=""}\'></div>';
}
document.all.Voteup.innerHTML=str;
}
</script>
<%end sub
call connclose()%>
</BODY></HTML>
