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

📄 toupiao_res.aspx.cs

📁 一个出售宠物的网站,比较全面
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
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.Data.SqlClient;
using System.Configuration;
namespace hellopet
{
	/// <summary>
	/// toupiao_res 的摘要说明。
	/// </summary>
	public class toupiao_res : System.Web.UI.Page
	{
	    protected System.Web.UI.WebControls.Label lb1;
	    protected System.Web.UI.WebControls.Label lb2;
	    protected System.Web.UI.WebControls.Label lb3;
	    protected System.Web.UI.WebControls.Label lb4;
	    protected System.Web.UI.WebControls.Label lb0;
	    protected System.Web.UI.HtmlControls.HtmlImage Img1;
	    protected System.Web.UI.HtmlControls.HtmlImage IMG6;
	    protected System.Web.UI.WebControls.Image Image1;
	    protected System.Web.UI.WebControls.Image Image2;
	    protected System.Web.UI.WebControls.Image Image3;
	    protected System.Web.UI.WebControls.Image Image4;
	    protected System.Web.UI.WebControls.Image Image5;
	    protected System.Web.UI.WebControls.HyperLink HyperLink1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			toupiao();// 在此处放置用户代码以初始化页面
		}
	    public void toupiao()
	    {
		SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
		string str0="select count(*) as n1 from diaocha where 宠物名称='0'";
		string str1="select count(*) from diaocha where 宠物名称='1'";
		string str2="select count(*) from diaocha where 宠物名称='2'";
		string str3="select count(*) from diaocha where 宠物名称='3'";
		string str4="select count(*) from diaocha where 宠物名称='4'";
		conn.Open();
		SqlCommand sc0=new SqlCommand(str0,conn);
		SqlCommand sc1=new SqlCommand(str1,conn);
		SqlCommand sc2=new SqlCommand(str2,conn);
		SqlCommand sc3=new SqlCommand(str3,conn);
		SqlCommand sc4=new SqlCommand(str4,conn);
		SqlDataReader dr0=sc0.ExecuteReader();
		int num0=0;
		int num1=0;
		int num2=0;
		int num3=0;
		int num4=0;
		if(dr0.Read())
		{
		    num0=Convert.ToInt32(dr0["n1"]);
		    dr0.Close();
		}
		SqlDataReader dr1=sc1.ExecuteReader();
		if(dr1.Read())
		{
		    num1=Convert.ToInt16(dr1[0]);
		    dr1.Close();
		}
		SqlDataReader dr2=sc2.ExecuteReader();
		if(dr2.Read())
		{
		    num2=Convert.ToInt16(dr2[0]);
		    dr2.Close();
		}
		SqlDataReader dr3=sc3.ExecuteReader();
		if(dr3.Read())
		{
		    num3=Convert.ToInt16(dr3[0]);
		    dr3.Close();
		}

		SqlDataReader dr4=sc4.ExecuteReader();
		    if(dr4.Read())
		    {
			num4=Convert.ToInt16(dr4[0]);
			dr4.Close();
		    }
		int sum=num0+num1+num2+num3+num4;
		double n0=100*Convert.ToSingle(num0)/sum;
		double n1=100*Convert.ToSingle(num1)/sum;
		double n2=100*Convert.ToSingle(num2)/sum;
		double n3=100*Convert.ToSingle(num3)/sum;
		double n4=100*Convert.ToSingle(num4)/sum;
		lb0.Text=num0.ToString()+"票"+(Math.Round(n0,1)).ToString()+"%";
		lb1.Text=num1.ToString()+"票"+(Math.Round(n1,1)).ToString()+"%";
		lb2.Text=num2.ToString()+"票"+(Math.Round(n2,1)).ToString()+"%";
		lb3.Text=num3.ToString()+"票"+(Math.Round(n3,1)).ToString()+"%";
		lb4.Text=num4.ToString()+"票"+(Math.Round(n4,1)).ToString()+"%";
		Image1.Width=Convert.ToInt32(n0*6);
		Image2.Width=Convert.ToInt32(n1*6);
		Image3.Width=Convert.ToInt32(n2*6);
		Image4.Width=Convert.ToInt32(n3*6);
		Image5.Width=Convert.ToInt32(n4*6);
	    }
		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
		    this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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