亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? votingcontrol.cs

?? 非常不錯的學校在線考試分析系統
?? CS
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using ASPNET.StarterKit.Communities;


namespace ASPNET.StarterKit.Communities {
	/// <summary>
	/// The Vote control is allows for users to vote on topics. The results are stored in 
	/// a SQL Server table and a HTML graph is used to display the selections/percentages.
	/// 
	/// Adopted from Rob Howard's (rhoward@microsoft.com) Voting Control.
	/// </summary>
	public class VotingControl : WebControl, System.Web.UI.INamingContainer {
		// Internal members
		//
		RadioButtonList radioButtonList;
		PollDetails polldetails;
		System.Drawing.Color barBackColor = System.Drawing.Color.LightGray;
		System.Drawing.Color barForeColor = System.Drawing.Color.Blue;
		Style questionStyle;
		Style itemStyle;
		Style buttonStyle;
		
		string itemClass = "VoteItemClass";
		string questionClass = "VoteQuestionClass";
		string buttonClass = "VoteButtonClass";
		string tableClass = "VoteTableClass";
		string resultClass = "VoteResultClass";


		string buttonText = "Vote";
		int section_ID;
		string userName;
		
		protected override void OnLoad(EventArgs e) {
			//InitializeControl();
		}

		private void InitializeControl() {
			
			// Try to get user and page information if available
			if (HttpContext.Current.Items["UserInfo"]!=null) {
				UserInfo userInfo = (UserInfo)HttpContext.Current.Items["UserInfo"];
				userName=userInfo.Username;
			} else {
				userName=String.Empty;
			}
			if (HttpContext.Current.Items["SectionInfo"]!=null) {
				SectionInfo objSectionInfo =(SectionInfo)HttpContext.Current.Items["SectionInfo"];
				section_ID = objSectionInfo.ID;
			} else {
				section_ID=0;
			}

			// Get Poll Details 
			//
			polldetails = GetPollDetails();
		}

		
		/// <summary>
		/// Used to indicate whether multiple votes are allowed per user. Default is false.
		/// </summary>
		public bool AllowMultipleVote=false;

		public string ItemClass
		{
			get
			{
				return itemClass;
			}
			set
			{
				itemClass = value;
			}
		}
	
		public string QuestionClass
		{
			get
			{
				return questionClass;
			}
			set
			{
				questionClass = value;
			}
		}

		public string ButtonClass
		{
			get
			{
				return buttonClass;
			}
			set
			{
				buttonClass = value;
			}
		}

		public string TableClass
		{
			get
			{
				return tableClass;
			}
			set
			{
				tableClass = value;
			}
		}

		public string ResultClass
		{
			get
			{
				return resultClass;
			}
			set
			{
				resultClass = value;
			}

		}

		/// <summary>
		/// Controls the height of the control
		/// </summary>
		public override Unit Height 
			   {
			get {
				return base.Height;
			}
			set {
				base.Height = value;
			}
		}

		/// <summary>
		/// Controls the width of the control
		/// </summary>
		public override Unit Width {
			get {
				return base.Width;
			}
			set {
				base.Width = value;
			}
		}

		/// <summary>
		/// Used to control the text on the button. Default is 'Vote'
		/// </summary>
		public String ButtonText {
			get {
				return buttonText;
			}
			set {
				buttonText = value;
			}
		}

		/// <summary>
		/// Sets the style for the question
		/// </summary>
		public Style QuestionStyle {
			get {
				if (questionStyle == null)
					questionStyle = new Style();

				return questionStyle;
			}
		}

		/// <summary>
		/// Sets the general style for displayed items
		/// </summary>
		public Style ItemStyle {
			get {
				if (itemStyle == null)
					itemStyle = new Style();
					
				return itemStyle;
			}
		}

		/// <summary>
		/// Sets the style for the button used in voting
		/// </summary>
		public Style ButtonStyle {
			get {
				if (buttonStyle == null)
					buttonStyle = new Style();
					
				return buttonStyle;
			}
		}

		/// <summary>
		/// Override control collection and return base collection
		/// </summary>
		public override ControlCollection Controls {
			get {
				EnsureChildControls();
				return base.Controls;
			}
		}

		/// <summary>
		/// Controls the back ground color of the rendered bar(s).
		/// </summary>
		public System.Drawing.Color BarBackColor {
			get {
				return barBackColor;
			}
			set {
				barBackColor = value;
			}
		}

		/// <summary>
		/// Controls the foreground color of the rendered bar(s).
		/// </summary>
		public System.Drawing.Color BarForeColor {
			get {
				return barForeColor;
			}
			set {
				barForeColor = value;
			}
		}
		
		protected override void CreateChildControls() {
			InitializeControl();
			// There may not be a poll available for this page
			if (polldetails!=null) {
				if (CheckHasVoted())
					HasVoted();
				else
					HasNotVoted();
			}
		}

		protected void HasNotVoted() {
			// Member variables
			//
			Table t = new Table();
			t.CssClass = tableClass;
			t.Width = System.Web.UI.WebControls.Unit.Percentage(100);
			TableRow questionRow = new TableRow();
			TableRow choicesRow = new TableRow();
			TableRow buttonRow = new TableRow();
			TableCell questionCell = new TableCell();
			TableCell choicesCell = new TableCell();
			TableCell buttonCell = new TableCell();
			Button button = new Button();
			radioButtonList = new RadioButtonList();
			
			// Wire up the button click event
			//
			button.Click += new EventHandler(VoteButtonClick);
			
			
			// Format Question
			//
			questionCell.Text = polldetails.Question;
			questionRow.ControlStyle.CopyFrom(questionStyle);
			questionCell.CssClass = questionClass;
			// Insert question cell and row into table
			//
			questionRow.Cells.Add(questionCell);
			t.Rows.Add(questionRow);

			// Format Radio Button
			//
			radioButtonList.ControlStyle.CopyFrom(itemStyle);
			radioButtonList.CssClass = itemClass;

			// Populate the radioButtonList
			//
			foreach (ChoiceInfo choice in polldetails.Choices.OrderedChoices) 
				radioButtonList.Items.Add(new ListItem(choice.Choice,choice.PollChoice_ID.ToString()));
			// Insert the radio button into the cell
			//
			choicesCell.Controls.Add(radioButtonList);

			// Add row/cell to table
			//
			choicesRow.Cells.Add(choicesCell);
			t.Rows.Add(choicesRow);

			// Format Button
			//
			button.Text = buttonText;
			button.ControlStyle.CopyFrom(buttonStyle);
			button.CssClass = buttonClass;
			// Insert button into cell
			//
			buttonCell.Controls.Add(button);

			// Add button cell/row to table
			//
			buttonRow.Cells.Add(buttonCell);
			t.Rows.Add(buttonRow);

			// Add table to the controls collection
			//
			this.Controls.Add(t);
			this.Controls.Add(new LiteralControl("<p>"));

		}

		protected void VoteButtonClick(Object sender, EventArgs e) {
			HttpContext.Current.Trace.Write("VoteButtonClick");
			if (radioButtonList.SelectedIndex!=-1) {
				int pollChoice_ID=Int32.Parse(radioButtonList.SelectedItem.Value);
				// Cast vote and save in DB
				VotingUtility.CreatePollResult(userName,pollChoice_ID);
				// Make cookie aware that this user has voted for this poll.
				AddPollToCookie();
			
				this.Controls.Clear();	
				
				HasVoted();
			}
		}

		protected void HasVoted() {
			// Member Variables
			//
			Table t = new Table();
			
			TableRow questionRow = new TableRow();
			TableRow resultsRow = new TableRow();
			TableRow footerRow = new TableRow();
			TableCell questionCell = new TableCell();
			TableCell resultsCell = new TableCell();
			TableCell footer = new TableCell();

			// Format the table
			//
			//t.BorderWidth = 0;
			t.CssClass = tableClass;
			t.Width = System.Web.UI.WebControls.Unit.Percentage(100);
			// Question
			//
			questionCell.Text = polldetails.Question;
			questionCell.ColumnSpan = 3;
			questionCell.ControlStyle.CopyFrom(questionStyle);
			questionCell.CssClass = questionClass;
	
			// Add the question cell/row to the table
			//
			questionRow.Cells.Add(questionCell);
			t.Rows.Add(questionRow);

			if (polldetails.DisplayResultsToPublic) {
				Hashtable pollresults = VotingUtility.GetPollResults(polldetails.Poll_ID);

				// Calculate the sum
				//
				int sum=0;
				
				foreach (int key in pollresults.Keys)
					sum = sum + (int)pollresults[key];
				
				// Calculate percentage
				//
				foreach (int key in pollresults.Keys) {
					// Internal variables/instances
					//
					double d = 0;
					TableRow row = new TableRow();
					TableCell progressCell = new TableCell();
					TableCell percentageCell = new TableCell();
					TableCell choiceCell = new TableCell();
					ProgressBar bar = new ProgressBar();
				
					// Percentage for this poll value
					//
					d = ((double)((int)pollresults[key]) / (double)sum) * 100;

					// Display the choice in cell and format
					//
					choiceCell.Text = ((ChoiceInfo)polldetails.Choices[key]).Choice + ": ";
					choiceCell.VerticalAlign = VerticalAlign.Top;
					choiceCell.HorizontalAlign = HorizontalAlign.Right;
					choiceCell.ControlStyle.CopyFrom(itemStyle);
					choiceCell.CssClass = itemClass;
					choiceCell.Wrap = false;

					// Set properties for each bar
					//
					bar.PercentageOfProgress = (int)d;
					bar.BackColor = this.BarBackColor;
					bar.ForeColor = this.BarForeColor;

					// Add the bar and set properties of the cell
					//
					progressCell.Controls.Add(bar);
					progressCell.HorizontalAlign = HorizontalAlign.Right;
					progressCell.VerticalAlign = VerticalAlign.Top;
					progressCell.Width = 100;

					// Special case 0
					//
					if ((double.IsNaN(d)) || (0 == d))
						percentageCell.Text = "(0%)";
					else
						percentageCell.Text = "(" + d.ToString("##.#") + "%)";

					// Format percentage cell
					//
					percentageCell.HorizontalAlign = HorizontalAlign.Left;
					percentageCell.VerticalAlign = VerticalAlign.Top;
					percentageCell.ControlStyle.CopyFrom(itemStyle);
					percentageCell.CssClass = itemClass;
					// Add the cells to the row
					//
					row.Cells.Add(choiceCell);
					row.Cells.Add(progressCell);
					row.Cells.Add(percentageCell);

					// Add the row to the table
					//
					t.Rows.Add(row);
					
				}
			}

			// What you voted for
			// 
			resultsCell.ColumnSpan = 3;
			resultsCell.HorizontalAlign = HorizontalAlign.Right;
			resultsCell.ControlStyle.CopyFrom(itemStyle);
			resultsCell.CssClass = resultClass;
			// Get Users data from the database
			// TODO: Rethink cookie design to store Anonymous user's values.
			if (userName!=String.Empty && userName!="Anonymous") {
				resultsCell.Text = "Your vote: " + VotingUtility.GetUsersChoice(polldetails.Poll_ID,userName).Choice;
			} else {
				resultsCell.Text = "You have already voted for this poll.";
			}

			// Add results cell/row to table
			//
			resultsRow.Cells.Add(resultsCell);
			t.Rows.Add(resultsRow);
			
			this.Controls.Add(t);
            this.Controls.Add(new LiteralControl("<p>"));
		}

		// Cache poll details in the ViewState. 
		private PollDetails GetPollDetails() {
			PollDetails pollDetails;
			// Maintain the same Poll_ID accross postbacks
			if (ViewState["Poll_ID"]==null) {
				pollDetails = VotingUtility.GetPollForWebBox(CommunityGlobals.CommunityID,section_ID,userName);
				if (pollDetails!=null)
					ViewState["Poll_ID"]=pollDetails.Poll_ID;
			} else {
				pollDetails = VotingUtility.GetPollForWebBox((int)ViewState["Poll_ID"]);
			}
			return pollDetails;
		}
		

		// Checks if the user has already voted. 
		private bool CheckHasVoted() {
			HttpCookie cookie = GetCookie();
			bool hasVoted=false;
			// First, check cookie
			if (cookie.Value.Length>0) {
				string[] polls=cookie.Value.Split('|');
				foreach (string poll in polls) {
					if (poll==polldetails.Poll_ID.ToString()) {
						hasVoted=true;
						break;
					}
				}
			}
			// Check DB
			if (!hasVoted && userName.Length>0) {
				ChoiceInfo choice = VotingUtility.GetUsersChoice(polldetails.Poll_ID,userName);
				if (choice.PollChoice_ID!=0) {
					hasVoted=true;
				}
			}
			return hasVoted;
		}

		// Adds this poll to the "voted" cookie.
		private void AddPollToCookie() {
			HttpCookie cookie = GetCookie();
			if (cookie.Value.Length==0)
				cookie.Value=polldetails.Poll_ID.ToString();
			else
				cookie.Value=cookie.Value+"|" + polldetails.Poll_ID.ToString();
			HttpContext.Current.Response.Cookies.Add(cookie);
		}

		// Retrieves the cookie and creates a new one if it doesn't exist.
		private HttpCookie GetCookie() {
			string cookieName="AspNetCommunityVoting_" + userName;
			HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];
			if (cookie==null) {
				HttpContext.Current.Response.Cookies.Add(new HttpCookie(cookieName,String.Empty));
				cookie = HttpContext.Current.Response.Cookies[cookieName];
				cookie.Expires=DateTime.MaxValue;
			}
			return cookie;
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品第13页| 欧美老年两性高潮| 国产精品毛片久久久久久久| 国产精品综合二区| 久久久五月婷婷| 国产在线播放一区| 久久久国产综合精品女国产盗摄| 国产在线看一区| 中文字幕不卡在线播放| 成人爽a毛片一区二区免费| 久久久久亚洲综合| 99视频在线精品| 亚洲午夜在线视频| 欧美一区二区在线视频| 精品在线亚洲视频| 国产欧美1区2区3区| 一本久久a久久精品亚洲| 亚洲午夜成aⅴ人片| 欧美一级片在线看| 岛国一区二区在线观看| 亚洲免费观看高清完整版在线| 欧美日韩中字一区| 极品销魂美女一区二区三区| 国产免费成人在线视频| 欧洲色大大久久| 国产在线视频一区二区三区| 亚洲色图制服丝袜| 日韩一二三四区| eeuss鲁片一区二区三区| 天堂一区二区在线免费观看| 国产欧美一区二区精品婷婷| 欧美在线不卡视频| 国产精品99久久久| 亚洲成av人影院| 亚洲国产成人私人影院tom| 在线观看成人小视频| 国产在线不卡一卡二卡三卡四卡| 一区二区三区在线影院| 久久综合国产精品| 色婷婷激情综合| 国产激情视频一区二区在线观看| 亚洲男同性视频| 久久久激情视频| 欧美一区二区三区日韩视频| 一本一本久久a久久精品综合麻豆| 日韩高清一区二区| 亚洲欧美日韩一区| 国产欧美视频一区二区三区| 欧美日韩国产另类一区| 成人av中文字幕| 九色|91porny| 日韩在线一二三区| 亚洲三级在线免费| 中国av一区二区三区| 日韩精品一区二区三区swag| 欧美日韩国产不卡| 色悠悠久久综合| 国产成人综合网站| 亚洲国产精品二十页| 国产在线观看免费一区| 日韩一区有码在线| 国产麻豆视频精品| 国产精品美女www爽爽爽| 国产白丝精品91爽爽久久| 亚洲视频一区二区在线| 色综合久久久久| 一区二区三区四区亚洲| 国产欧美一区二区精品久导航| 欧美aⅴ一区二区三区视频| 亚洲欧美国产毛片在线| 国产精品丝袜黑色高跟| 国产亚洲欧美日韩日本| 久久众筹精品私拍模特| 日韩视频国产视频| 日韩欧美亚洲一区二区| 欧美一二三区在线| 日韩一区二区三区在线视频| 欧美精品一级二级| 欧美精品v国产精品v日韩精品| 欧美手机在线视频| 91精品国产综合久久福利软件 | 91国内精品野花午夜精品| 99视频在线精品| 色欧美日韩亚洲| 欧美日韩不卡一区| 3751色影院一区二区三区| 69堂精品视频| 欧美xxx久久| 国产日韩亚洲欧美综合| 欧美激情一区二区在线| 中文字幕一区二区三区四区不卡| 亚洲国产成人在线| 一区二区三区精品在线| 日日夜夜精品免费视频| 麻豆精品一二三| 国产suv精品一区二区883| 国产aⅴ精品一区二区三区色成熟| 成人永久aaa| 色中色一区二区| 日韩一级免费观看| 国产亚洲成av人在线观看导航| 中文字幕在线不卡视频| 中文字幕在线观看一区| 亚洲成人av电影| 激情综合网最新| 99久久综合色| 91精品国产综合久久婷婷香蕉| 欧美一区三区二区| 国产精品久久看| 亚洲18影院在线观看| 国产在线一区观看| 欧美亚洲图片小说| 26uuu精品一区二区| 18成人在线观看| 日本v片在线高清不卡在线观看| 国产精品系列在线观看| 91激情在线视频| 久久亚洲精品小早川怜子| 亚洲欧美日本韩国| 久久99久久精品| 日本高清不卡aⅴ免费网站| 日韩精品一区二区三区四区| 亚洲欧美另类在线| 国产综合色产在线精品| 色欧美片视频在线观看| 26uuu精品一区二区在线观看| 亚洲免费电影在线| 国产麻豆精品95视频| 欧美性受xxxx黑人xyx性爽| 欧美va在线播放| 国产精品第一页第二页第三页| 中文字幕在线播放不卡一区| 北条麻妃一区二区三区| 国产精品国产a| 99综合影院在线| 精品国产一区久久| 一区二区三区国产精品| 亚洲综合免费观看高清在线观看| 韩国欧美国产1区| 精品婷婷伊人一区三区三| 国产精品乱码久久久久久| 国产主播一区二区| xf在线a精品一区二区视频网站| 国产综合久久久久影院| 欧美一级二级三级乱码| 中文字幕+乱码+中文字幕一区| 国产午夜精品福利| 麻豆精品久久久| 日韩欧美中文一区二区| 日韩精品一区第一页| 欧美va亚洲va国产综合| 激情av综合网| 欧美日韩一区二区三区视频| 欧美精品一区二区三区视频| 中文字幕乱码亚洲精品一区| 一区二区成人在线| 成人av在线播放网站| 欧美一区二区三区男人的天堂| 国产精品少妇自拍| 成人手机在线视频| 亚洲欧美韩国综合色| 欧美一区二区三区在线视频| 美女在线一区二区| 欧美国产视频在线| 欧美久久一区二区| 粉嫩aⅴ一区二区三区四区| 天使萌一区二区三区免费观看| 日本道在线观看一区二区| 国产91精品在线观看| 综合av第一页| 国产午夜精品美女毛片视频| 久久国产福利国产秒拍| 26uuu另类欧美亚洲曰本| 另类综合日韩欧美亚洲| 日韩一级欧美一级| 国产自产高清不卡| 欧美本精品男人aⅴ天堂| 国产综合色产在线精品| 国产无遮挡一区二区三区毛片日本| 国产一区在线观看视频| 久久久精品tv| 99精品视频在线观看| 亚洲欧美日韩国产一区二区三区| 在线亚洲+欧美+日本专区| 一区二区三区美女视频| 欧美丰满高潮xxxx喷水动漫| 日本成人中文字幕在线视频| 26uuu久久综合| 成人午夜短视频| 一区在线中文字幕| 九九**精品视频免费播放| 亚洲高清免费在线| 美女视频免费一区| 欧美国产激情二区三区| 亚洲国产精品t66y| 中文字幕高清一区| 成人欧美一区二区三区黑人麻豆 | 欧美日韩亚洲丝袜制服| 亚洲成人先锋电影| 欧美成人精品1314www|