⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.aspx.cs

📁 This is not a very mean things
💻 CS
字号:
//-----------------------------------------------------------------------------
//
// WebExpert.NET 1.0 
//
// (c) 2003, www.AspCool.com. All rights reserved.
// ASP酷技术网版权所有
//
// 该源码下载自:http://www.51aspx.com
// 邮箱:tim@aspcool.com
//
// 版权声明:本程序仅供学习使用,你也可以修改后在网站上使用,但使用时必
// 须保留ASP酷技术网(www.AspCool.com)的版权信息和链接。本程序随《ASP.NET
// 网站建设专家》一书赠送,未经作者同意,不得随意修改、传播。
//
// 描述:
//   此文件包含下面的类:
//       Show
//
// 作者:     王保健
// 时间:     2003/09/15
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;

namespace vote
{
	/// <summary>
	/// Summary description for Show.
	/// </summary>
	public class Show : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblQuestion;
		protected System.Web.UI.WebControls.Label lblPeople;
		protected System.Web.UI.WebControls.Repeater rp;
	
		private void Page_Load(object sender, System.EventArgs e)
        {
			string QuestionID=Request["ID"];
			
			SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			conn.Open();

			//计算投票总数开始
			string strSum="Select sum(Got) as Total from Answers group by Question_ID having Question_ID='"+QuestionID+"'";
			SqlCommand TotalCommand=new SqlCommand(strSum,conn);
			SqlDataReader tdr=TotalCommand.ExecuteReader();
			ViewState["Total"]=1;
			if (tdr.Read())
			{
				ViewState["Total"]=tdr.GetInt32(0);
				lblPeople.Text="总共有 <font color=red>"+tdr.GetInt32(0).ToString()+"</font> 票。";
			}
			tdr.Close();
			//计算投票总数结束
			string strQuestion= "Select Question_Subject from Questions where Question_ID='"+QuestionID+"'";
			
			SqlCommand myComm=new SqlCommand(strQuestion,conn);

			SqlDataReader dr=myComm.ExecuteReader();
			if (dr.Read())
			{
				lblQuestion.Text=dr.GetString(0);
				
			}
			else
			{
				Response.Write("对不起,没有找到你的问题编号,请检查!");                		
			}
			dr.Close();

			string strAnswer="Select Answer_ID,Answer,Got from Answers where Question_ID='"+QuestionID+"'";
			
			SqlDataAdapter da=new SqlDataAdapter(strAnswer,conn);

			DataSet ds=new DataSet();
			da.Fill(ds,"Answers");
			rp.DataSource=ds.Tables["Answers"].DefaultView;
			rp.DataBind();
			
			conn.Close();
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -