📄 vote_show.aspx.cs
字号:
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using NetCMS.Content.Common;
using NetCMS.Model;
public partial class survey_Vote_Show : NetCMS.Web.UI.BasePage
{
public string dc = null;
public string strtheurl = null;
Survey sur = new Survey();
private string OutHtmlID;
private int PicW = 60;
protected void Page_Load(object sender, EventArgs e)
{
Response.CacheControl = "no-cache"; //清除缓存
RequestQueyStrig();//获取前台调用参数
}
protected void RequestQueyStrig()
{
if (Request["TID"] == null)
PageError("缺少必要的参数", "");
int tid = int.Parse(Request["TID"]);//主题ID
if (Request["PicW"] != null)
PicW = int.Parse(Request["PicW"]);//图片宽度
OutHtmlID = "Vote_HTML_ID";
if (Request["OutHtmlID"] != null)
{
OutHtmlID = Request["OutHtmlID"];
}
if (tid < 1)
{
PageError("参数传递错误", "");
}
if (PicW < 1)
{
PicW = 60;
}
ShowItem(tid, PicW, OutHtmlID);
}
protected void ShowItem(int Tid, int PicW, string OutHtmlID)
{
string SiteID = "0";
if (Validate_Session())
{
SiteID = NetCMS.Global.Current.SiteID;
}
VoteTopicInfo info;
int Steps = 0;
int PreStep = 0;
int NextStep = 0;
string maintt = string.Empty;
info = sur.GetTopic(Tid);
if (info == null)
PageError("对不起,没有找到相关的投票选项!", "");
ParseVote(info);
}
private void ParseVote(VoteTopicInfo info)
{
rootPublic rt = new rootPublic();
string Cookie_Domain = rt.sitedomain();
if (Cookie_Domain == "")
{
Cookie_Domain = "localhost";
}
string Str_dirMana = NetCMS.Config.UIConfig.dirDumm;
if (Str_dirMana != "" && Str_dirMana != null && Str_dirMana != string.Empty)//判断虚拟路径是否为空,如果不是则加上//
{
Str_dirMana = "/" + Str_dirMana;
}
else
{
Str_dirMana = "";
}
byte ItemModeTitle = info.ItemMode;//该主题下选项的排列方式/5项/行...
string html;
html = "<form name=\"voteForm\" id=\"voteForm\" method=\"post\" action=\"http://" + Cookie_Domain + Str_dirMana + "/survey/view.aspx\">\r\n";
html += "<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"table\">\r\n";
html += "<tr class=\"TR_BG_list\" align=\"center\"><td width=\"100%\" class=\"list_link\">投票主题:" + info.Title + "</td></tr>\r\n";
html += "</table><table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"table\" id=\"TabVoteItems\">\r\n";
html += "<tr class=\"TR_BG_list\"><td class=\"list_link\" align=\"center\">";
html += Options(info.TID, info.Type, ItemModeTitle, info.SeriesMode);
//html += "</td>\r\n</tr>";
if (info.AllowFillIn)
html += "<input type=\"text\" size=\"20\" name=\"TxtDefine\"/>";
html += "</td>\r\n</tr></table>";
html += "<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"table\">\r\n";
html += "<tr class=\"TR_BG_list\"><td class=\"list_link\" align=\"center\">";
html += "<input type=\"reset\" value=\" 重置 \"/> ";
html += "<input type=\"button\" id=\"but_VoteSubmit\" value=\" 投票 \" onclick=\"var obj = document.getElementById('TabVoteItems').getElementsByTagName('input');var p = '';for(var i=0;i<obj.length;i++){if((obj[i].name=='SelVoteItems' && obj[i].checked) || (obj[i].name != 'SelVoteItems' && obj[i].value.trim() != '')) p += '&'+ obj[i].name +'=' +obj[i].value;} if(p==''){alert('您没有选中任何投票项!');return;};new Ajax.Request('/survey/Vote_Ajax.aspx',{method:'post',parameters:'TID=" + info.TID + "'+ p ,onComplete:function(transport){document.getElementById('" + OutHtmlID + "').innerHTML = transport.responseText;}});\"> ";
html += "<input type=\"button\" id=\"but_ViewVote\" value=\"查看结果\" onclick=\"window.open('http://" + Cookie_Domain + Str_dirMana + "/survey/view.aspx?TID=" + info.TID + "')\">";
html += "</td></tr></table></form>";
Response.Write(html);
Response.End();
}
#region 选项
protected string Options(int Tid, byte CheckType, byte ItemModeTitle, byte NumType)
{
int iid = 0;//相应选项的iid
string ItemName = "";//选项名
string ItemModell = "";//控制文字,图片,自主(选项)时后跟的内容
string PicSrcc = "";//图片地址
string ItemColor = "";//选项颜色
string ItemValueDisP = "";//1-9/a-z/A-Z/.
int y = 0;//控制前台显示1-9样式排序
string strlist = null;
List<VoteItemInfo> list = (List<VoteItemInfo>)sur.GetItemsByTopic(Tid);//找出tid的所有记录(选项)
foreach (VoteItemInfo info in list)
{
y++;//前台数字1-9显示自增
iid = info.IID;//相应选项的iid
ItemName = info.ItemName;//选项名
byte ItemModel = info.ItemMode;//文字,图片,自主(选项)
ItemModell = "";//控制文字,图片,自主(选项)时后跟的内容
PicSrcc = info.PicSrc;//图片地址
ItemColor = info.DisColor;//选项颜色
//byte nowNumber = info.ItemMode;
#region 序号
switch (NumType)
{
case 0://1-9样式
ItemValueDisP = y.ToString() + "<strong>.</strong>";
break;
case 1://a-z
char b = (char)(96 + y);
ItemValueDisP = b.ToString() + "<strong>.</strong>";
break;
case 2://A-Z
char a = (char)(64 + y);
ItemValueDisP = a.ToString() + "<strong>.</strong>";
break;
case 3://.
ItemValueDisP = "<strong>.</strong>";
break;
case 4://★
ItemValueDisP = "<strong>★</strong>";
break;
}
#endregion
#region 显示方式
switch (ItemModel)
{
case 0X01://文字
ItemModell = "";
break;
case 0X02://图片
if (PicSrcc != null && PicSrcc.Trim() != string.Empty)
{
string imgpath = PicSrcc.Replace("{@dirfile}", NetCMS.Config.UIConfig.dirFile);
ItemModell = "<a href=\""+ imgpath +"\" target=\"_blank\"><img src=\"" + imgpath + "\" title=\"点击查看图片\" border=\"0\" alt=\"暂无图片\"/></a>";
}
else
{
ItemModell = "";
}
break;
default://默认文字
ItemModell = "";
break;
}
#endregion
strlist += "<input type=\"";
if (CheckType == 0)
strlist += "radio";
else
strlist += "checkbox";
strlist += "\" name=\"SelVoteItems\" id=\"Items_" + iid + "\" value=\"" + iid + "\"><font color=#" + ItemColor + ">" + ItemValueDisP + " " + ItemName + "</font> " + ItemModell + "";
#region 排列方式
if (ItemModeTitle == 0X00)
{
//横向排列(什么也不做。照原样排列成一行)
}
else
{
//纵向排列
//int nowNumber = int.Parse(ItemModeTitle);
if (y % ItemModeTitle == 0)
{
strlist += "<br />";//换x行排列
}
}
#endregion
}
return strlist;
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -