<!--#include file="setup.asp"-->
<%
Dim CurrentPage
Dim maxperpage
Dim totalnumber
Dim Pcount
Dim totalPut
Dim isEdit
Dim selVoteid
Dim VoteTitle
Dim i
Set Rs = Server.CreateObject("ADODB.Recordset")
NC_Admin.AdminChk = "54"
NC_Admin.Check
DownsysClass.admin_header
'*****************************************************************
'*  NewCloud Movie System Version 1.0.0
'*  File: admin_vote.asp
'*  Date: 2004-5-12
'*****************************************************************
'*  Copyright 2002-2004 DownsysClass.net - All Rights Reserved.
'*  DownsysClass is a trademark of DownsysClass.net
'*  HomePage: http://www.DownsysClass.net
'*****************************************************************
Select Case Trim(Request("action"))
	Case "save"
		Call SaveVote
	Case "modify"
		Call ModifyVote
	Case "add"
		isEdit = False
		EditVote
	Case "edit"
		isEdit = True
		EditVote
	Case Else
		Call VoteMain
End Select
If Founderr = True Then
	NC_Admin.Error_Msg (ErrMsg)
End If
DownsysClass.admin_footer
NothingObject

Private Sub VoteMain()
	Dim bookmark
	If Not IsEmpty(Request("selVoteid")) Then
		selVoteid = Request("selVoteid")
		Select Case Request("type")
			Case "del"
				Call DelVote
			Case "isLock"
				Call isLock
			Case "noLock"
				Call noLock
			Case "radio"
				Call setRadio
			Case "checkbox"
				Call setCheckbox
			Case Else
				Response.Write "无效参数！"
				Response.End
		End Select
	End If
	Response.Write "<TABLE width=""99%"" border=0 cellpadding=3 cellspacing=1 align=center class=tableBorder>" & vbCrLf
	Response.Write "<TR>" & vbCrLf
	Response.Write " <TH colspan=6>投票管理</TH>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""28"">" & vbCrLf
	Response.Write " <TD colspan=6 class=forumRow>投票调用方法:<BR>①&lt;script src=""js/showvote.js""&gt;&lt;/script&gt;<BR>" & vbCrLf
	Response.Write " ②&lt;IFRAME name=vote src=""vote.htm"" frameBorder=no scrolling=no width=180 height=220&gt;&lt;/IFRAME&gt;<BR>" & vbCrLf
	Response.Write " </TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR>" & vbCrLf
	Response.Write " <TH noWrap>选 择</TH>" & vbCrLf
	Response.Write " <TH noWrap>投票主题　[<a href=admin_vote.asp?action=add class=TableTitleLink>添加投票</a>]</TH>" & vbCrLf
	Response.Write " <TH noWrap>投 票 数</TH>" & vbCrLf
	Response.Write " <TH noWrap>编辑投票</TH>" & vbCrLf
	Response.Write " <TH noWrap>投票类型</TH>" & vbCrLf
	Response.Write " <TH noWrap>状 态</TH>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CLng(Request("page"))
	Else
		CurrentPage = 1
	End If
	maxperpage = 20 '###每页显示数
	SQL = "select * from NC_Vote order by id desc"
	Rs.Open SQL, Conn, 1, 1
	DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td colspan=10 class=forumrow>没有投票主题！</td></tr>"
	Else
		totalnumber = Rs.recordcount
		If (totalnumber Mod maxperpage) = 0 Then
			Pcount = totalnumber \ maxperpage
		Else
			Pcount = totalnumber \ maxperpage + 1
		End If
		Rs.MoveFiRst
		If CurrentPage > Pcount Then CurrentPage = Pcount
		If CurrentPage < 1 Then CurrentPage = 1
		Rs.Move (CurrentPage - 1) * maxperpage
		bookmark = Rs.bookmark
		i = 0
		Response.Write "<TR height=""28"">" & vbCrLf
		Response.Write " <TD colspan=6 class=forumRowHighlight align=center>"
		Call showpage
		Response.Write "</TD>" & vbCrLf
		Response.Write "</TR>" & vbCrLf
		Response.Write "<form name=""selform"" method=""post"" action="""">" & vbCrLf
		Do While Not Rs.EOF And i < CLng(maxperpage)
			Response.Write "<TR>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow align=center><input type=checkbox name=selVoteid value="""
			Response.Write Rs("id")
			Response.Write """></TD>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow width=""70%""><a href=../vote.htm title=""查看投票"" target=_blank>"
			Response.Write Rs("topic")
			Response.Write "</a></TD>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow align=center><FONT COLOR=RED><B>"
			Response.Write Rs("VoteNum")
			Response.Write "</B></FONT></TD>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow align=center><a href=admin_vote.asp?action=edit&id="
			Response.Write Rs("id")
			Response.Write " title=""查看编辑:"
			Response.Write Rs("topic")
			Response.Write """>编辑投票</a></TD>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow align=center>"
			If CInt(Rs("VoteType")) = 0 Then
				Response.Write "单选"
			Else
				Response.Write "多选"
			End If
			Response.Write "</TD>" & vbCrLf
			Response.Write " <TD noWrap class=forumRow align=center>"
			If CInt(Rs("isLock")) = 0 Then
				Response.Write "正常"
			Else
				Response.Write "<FONT COLOR=RED>锁定</FONT>"
			End If
			Response.Write "</TD>" & vbCrLf
			Response.Write "</TR>" & vbCrLf
			Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close
	Set Rs = Nothing
	Response.Write "<TR height=""30"">" & vbCrLf
	Response.Write " <TD class=forumRow>管理</TD>" & vbCrLf
	Response.Write " <TD colspan=5 class=forumRow>全选/反选 <input type=""checkbox"" name=""checkbox"" value=""checkbox"" onclick=CheckAll(this.form)> " & vbCrLf
	Response.Write " <input type=""radio"" name=""type"" value=""del"" title=""管理选项：批量删除选中的新闻"">批量删除 " & vbCrLf
	Response.Write " <input type=""radio"" name=""type"" value=""isLock"" title=""管理选项：批量锁定投票主题"">锁定 " & vbCrLf
	Response.Write " <input type=""radio"" name=""type"" value=""noLock"" title=""管理选项：批量解除锁定"">解锁 " & vbCrLf
	Response.Write " <input type=""radio"" name=""type"" value=""radio"" title=""管理选项：批量设置单选投票"">单选 " & vbCrLf
	Response.Write " <input type=""radio"" name=""type"" value=""checkbox"" title=""管理选项：批量设置多选投票"">多选 " & vbCrLf
	Response.Write " <input type=submit name=Submit value=""执行操作"" class=button onclick=""{if(confirm('您确定执行此操作吗?')){this.document.selform.submit();return true;}return false;}""></TD>" & vbCrLf
	Response.Write "</TR></form>" & vbCrLf
	Response.Write "<TR height=""28"">" & vbCrLf
	Response.Write " <TD colspan=6 class=forumRowHighlight align=center>"
	Call showpage
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "</TABLE>" & vbCrLf
End Sub


Private Sub EditVote()
	If isEdit Then
		SQL = "select * from NC_Vote where id=" & Request("id")
		Rs.Open SQL, Conn, 1, 1
		DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
		VoteTitle = "编辑投票"
	Else
		VoteTitle = "添加新的投票"
	End If
	Response.Write " <TABLE width=""99%"" border=0 cellpadding=3 cellspacing=1 align=center class=tableBorder>" & vbCrLf
	Response.Write "<TR><form name=""myform"" method=""post"" action=""admin_vote.asp"">" & vbCrLf
	Response.Write " <input type=""Hidden"" name=""action"" value='"
	If isEdit Then
		Response.Write "modify"
	Else
		Response.Write "save"
	End If
	Response.Write "'>" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write " <input type=""Hidden"" name=""id"" value='"
		Response.Write CStr(Request("id"))
		Response.Write "'>" & vbCrLf
		Response.Write " "
	End If
	Response.Write " <TH colspan=2>"
	Response.Write VoteTitle
	Response.Write "</TH>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票类型：</TD>" & vbCrLf
	Response.Write " <TD width=""85%"" class=forumRow>" & vbCrLf
	Response.Write " <input type=""radio"" name=""VoteType"" value=""0"" title=""设置单选投票"" "
	If isEdit Then
		If CInt(Rs("VoteType")) = 0 Then
			Response.Write "checked"
		End If
	Else
		Response.Write "checked"
	End If
	Response.Write ">单选 " & vbCrLf
	Response.Write " <input type=""radio"" name=""VoteType"" value=""1"" title=""设置多选投票"" "
	If isEdit Then
		If CInt(Rs("VoteType")) = 1 Then
			Response.Write "checked"
		End If
	End If
	Response.Write ">多选</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票主题：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=topic size=50 value="""
	If isEdit Then
		Response.Write Rs("topic")
	End If
	Response.Write """></TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票选项1：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=Choose_1 size=20 value="""
	If isEdit Then
		Response.Write Rs("Choose_1")
	End If
	Response.Write """>&nbsp;&nbsp;&nbsp;" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write "投票数：<input type=text name=ChooseNum_1 size=10 value="""
		Response.Write Rs("ChooseNum_1")
		Response.Write """>"
	End If
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票选项2：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=Choose_2 size=20 value="""
	If isEdit Then
		Response.Write Rs("Choose_2")
	End If
	Response.Write """>&nbsp;&nbsp;&nbsp;" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write "投票数：<input type=text name=ChooseNum_2 size=10 value="""
		Response.Write Rs("ChooseNum_2")
		Response.Write """>"
	End If
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票选项3：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=Choose_3 size=20 value="""
	If isEdit Then
		Response.Write Rs("Choose_3")
	End If
	Response.Write """>&nbsp;&nbsp;&nbsp;" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write "投票数：<input type=text name=ChooseNum_3 size=10 value="""
		Response.Write Rs("ChooseNum_3")
		Response.Write """>"
	End If
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票选项4：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=Choose_4 size=20 value="""
	If isEdit Then
		Response.Write Rs("Choose_4")
	End If
	Response.Write """>&nbsp;&nbsp;&nbsp;" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write "投票数：<input type=text name=ChooseNum_4 size=10 value="""
		Response.Write Rs("ChooseNum_4")
		Response.Write """>"
	End If
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>投票选项5：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=Choose_5 size=20 value="""
	If isEdit Then
		Response.Write Rs("Choose_5")
	End If
	Response.Write """>&nbsp;&nbsp;&nbsp;" & vbCrLf
	Response.Write " "
	If isEdit Then
		Response.Write "投票数：<input type=text name=ChooseNum_5 size=10 value="""
		Response.Write Rs("ChooseNum_5")
		Response.Write """>"
	End If
	Response.Write "</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>背景颜色：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=bgcolor size=10 value="""
	If isEdit Then
		Response.Write Rs("bgcolor")
	Else
		Response.Write "FFFFFF"
	End If
	Response.Write """>&nbsp;" & vbCrLf
	Response.Write " 如：FFFFFF 不用加&quot;<font color=""#FF3300"">#</font>&quot;</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>字体颜色：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=FontColor size=10 value="""
	If isEdit Then
		Response.Write Rs("FontColor")
	Else
		Response.Write "000000"
	End If
	Response.Write """>&nbsp;" & vbCrLf
	Response.Write " 如：000000 不用加&quot;<font color=""#FF3300"">#</font>&quot;</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>字体大小：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=FontSize size=10 value="""
	If isEdit Then
		Response.Write Rs("FontSize")
	Else
		Response.Write "12"
	End If
	Response.Write """>&nbsp;" & vbCrLf
	Response.Write " 单位px 如：这是12px <span style=""font-size:14px"">这是14px</span>,只输入数字</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>总投票数：</TD>" & vbCrLf
	Response.Write " <TD class=forumRow><input type=text name=VoteNum size=10 value="""
	If isEdit Then
		Response.Write Rs("VoteNum")
	Else
		Response.Write "0"
	End If
	Response.Write """></TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write "<TR height=""22"">" & vbCrLf
	Response.Write " <TD noWrap align=""right"" class=forumRowHighlight>是否锁定：</TD>" & vbCrLf
	Response.Write " <TD width=""85%"" class=forumRow>" & vbCrLf
	Response.Write " <input type=""radio"" name=""isLock"" value=""0"" title=""设置单选投票"" "
	If isEdit Then
		If CInt(Rs("isLock")) = 0 Then
			Response.Write "checked"
		End If
	Else
		Response.Write "checked"
	End If
	Response.Write ">否 " & vbCrLf
	Response.Write " <input type=""radio"" name=""isLock"" value=""1"" title=""设置多选投票"" "
	If isEdit Then
		If CInt(Rs("isLock")) = 1 Then
			Response.Write "checked"
		End If
	End If
	Response.Write ">是</TD>" & vbCrLf
	Response.Write "</TR>" & vbCrLf
	Response.Write " <tr>" & vbCrLf
	Response.Write " <td height=""22"" align=""right"" class=""forumRowHighlight"">&nbsp;</td>" & vbCrLf
	Response.Write " <td align=""center"" class=""forumRow"">" & vbCrLf
	Response.Write " <input type=""button"" name=""Submit1"" onclick=""javascript:history.go(-1)"" value=""返回上一页"" class=button>　" & vbCrLf
	Response.Write " <input type=reset name=Submit2 class=button value=""清 除"">　" & vbCrLf
	Response.Write "　<input type=Submit class=button value=""保存投票"" name=Submit>　" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr></form>" & vbCrLf
	Response.Write "</table>" & vbCrLf
	If isEdit Then
		Rs.Close
		Set Rs = Nothing
	End If
End Sub


Private Sub SaveVote()
	'保存新的投票
	If Trim(Request.Form("topic")) = "" Then
		Founderr = True
		ErrMsg = ErrMsg + "<li>投票主题不能为空！</li>"
		Exit Sub
	End If
	If Founderr = False Then
		SQL = "select * from NC_Vote where (id is null)"
		Rs.Open SQL, Conn, 1, 3
		Rs.addnew
		Rs("Topic") = Request.Form("Topic")
		Rs("Choose_1") = Request.Form("Choose_1")
		Rs("Choose_2") = Request.Form("Choose_2")
		Rs("Choose_3") = Request.Form("Choose_3")
		Rs("Choose_4") = Request.Form("Choose_4")
		Rs("Choose_5") = Request.Form("Choose_5")
		Rs("ChooseNum_1") = 0
		Rs("ChooseNum_2") = 0
		Rs("ChooseNum_3") = 0
		Rs("ChooseNum_4") = 0
		Rs("ChooseNum_5") = 0
		Rs("isLock") = Request.Form("isLock")
		Rs("bgcolor") = Request.Form("bgcolor")
		Rs("FontColor") = Request.Form("FontColor")
		Rs("FontSize") = Request.Form("FontSize")
		Rs("VoteTime") = Now
		Rs("VoteNum") = 0
		Rs("VoteType") = Request.Form("VoteType")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		NC_Admin.Succeed_Msg ("<li>添加" & Request.Form("topic") & "成功!</li>")
		Response.Write "<meta http-equiv=""refresh"" content=""2;url='admin_Vote.asp?action=add'"">" & vbCrLf
	End If
End Sub


Private Sub ModifyVote()
	'修改投票
	If Trim(Request.Form("topic")) = "" Then
		Founderr = True
		ErrMsg = ErrMsg + "<li>投票主题不能为空！</li>"
		Exit Sub
	End If
	If Founderr = False Then
		SQL = "select * from NC_Vote where id=" & Request.Form("id")
		Rs.Open SQL, Conn, 1, 3
		Rs("Topic") = Request.Form("Topic")
		Rs("Choose_1") = Request.Form("Choose_1")
		Rs("Choose_2") = Request.Form("Choose_2")
		Rs("Choose_3") = Request.Form("Choose_3")
		Rs("Choose_4") = Request.Form("Choose_4")
		Rs("Choose_5") = Request.Form("Choose_5")
		Rs("ChooseNum_1") = Request.Form("ChooseNum_1")
		Rs("ChooseNum_2") = Request.Form("ChooseNum_2")
		Rs("ChooseNum_3") = Request.Form("ChooseNum_3")
		Rs("ChooseNum_4") = Request.Form("ChooseNum_4")
		Rs("ChooseNum_5") = Request.Form("ChooseNum_5")
		Rs("isLock") = Request.Form("isLock")
		Rs("bgcolor") = Request.Form("bgcolor")
		Rs("FontColor") = Request.Form("FontColor")
		Rs("FontSize") = Request.Form("FontSize")
		Rs("VoteNum") = Request.Form("VoteNum")
		Rs("VoteType") = Request.Form("VoteType")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		NC_Admin.Succeed_Msg ("<li>修改" & Request.Form("topic") & "成功!</li>")
		Response.Write "<meta http-equiv=""refresh"" content=""2;url='admin_Vote.asp'"">" & vbCrLf
	End If
End Sub


Private Sub DelVote()
	'删除投票
	DownsysClass.Execute ("delete from NC_Vote where id in (" & selVoteid & ")")
End Sub


Private Sub isLock()
	'锁定投票
	DownsysClass.Execute ("update NC_Vote set isLock=1 where id in (" & selVoteid & ")")
End Sub ' islock


Private Sub noLock()
	'解除锁定
	DownsysClass.Execute ("update NC_Vote set isLock=0 where id in (" & selVoteid & ")")
End Sub


Private Sub setRadio()
	'设置单选投票
	DownsysClass.Execute ("update NC_Vote set VoteType=0 where id in (" & selVoteid & ")")
End Sub


Private Sub setCheckbox()
	'设置多选投票
	DownsysClass.Execute ("update NC_Vote set VoteType=1 where id in (" & selVoteid & ")")
End Sub


Private Sub showpage()
	Dim FileName
	Dim n
	Dim ii
	' 分页
	FileName = "admin_vote.asp"
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	Response.Write "<table cellspacing=1 width='100%' border=0><form method=Post action=" & FileName & "><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		Response.Write "投票主题 <font COLOR=#FF0000><B>" & totalnumber & "</B></font>&nbsp;首 页&nbsp;上一页&nbsp;"
	Else
		Response.Write "投票主题 <font COLOR=#FF0000><B>" & totalnumber & "</B></font>&nbsp;<a href=" & FileName & "?page=1>首 页</a>&nbsp;"
		Response.Write "<a href=" & FileName & "?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		Response.Write "下一页&nbsp;尾 页 " & vbCrLf
	Else
		Response.Write "<a href=" & FileName & "?page=" & (CurrentPage + 1) & ">下一页</a>"
		Response.Write "&nbsp;<a href=" & FileName & "?page=" & n & ">尾 页</a>" & vbCrLf
	End If
	Response.Write "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	Response.Write "&nbsp;转到："
	Response.Write "&nbsp;<select name='page' size='1' style=""font-size: 9pt"" onChange='javascript:submit()'>" & vbCrLf
	For ii = 1 To n
		Response.Write "<option value='" & ii & "' "
		If CurrentPage = Int(ii) Then
			Response.Write "selected "
		End If
		Response.Write ">第" & ii & "页</option>"
	Next
	Response.Write "&nbsp;</select> " & vbCrLf
	Response.Write "</td></tr></FORM></table>" & vbCrLf
End Sub
%>
