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

📄 zonghe.aspx.cs

📁 这是一个基于WEB的电场耗水量管理与分析系统
💻 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;
namespace nicholasbjj
{
	/// <summary>
	/// Summary description for zonghe.
	/// </summary>
	public class zonghe : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.DataGrid DataGridx;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{

				
				string sql1="select * from [szbsj]";
				string strConn1="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
				SqlConnection conn1=new SqlConnection(strConn1);
				SqlCommand cmd1=new SqlCommand();
				SqlDataReader reader1;
				cmd1.Connection=conn1;
				cmd1.CommandText=sql1;
				conn1.Open();
				reader1=cmd1.ExecuteReader();
				DropDownList2.DataSource=reader1;
				DropDownList2.DataTextField="time";
				reader1.Close();
				conn1.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.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		private void Button1_Click(object sender, System.EventArgs e)
		{
			try
			{

				string sql="SELECT TOP 100 PERCENT dbo.szb.szbname AS 指标名称, dbo.szbsj.yjh AS 计划值, dbo.szbsj.ysj AS 实际值, CAST(dbo.szbsj.ysj AS int) - CAST(dbo.szbsj.yjh AS int) AS 偏差值";
				sql+="  FROM dbo.company INNER JOIN dbo.szbsj ON dbo.company.comid = dbo.szbsj.comid RIGHT OUTER JOIN dbo.szb ON dbo.szbsj.szbid = dbo.szb.szbid";
				sql+=  " where comname='" + DropDownList1.SelectedItem.Text +"'and time='"+ DropDownList2.SelectedItem.Text+"'";
				//sql+=	"OR dbo.szbsj.yjh IS NULL";
				sql+=" ORDER BY dbo.szb.szbid";

				string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
				SqlConnection conn=new SqlConnection(strConn);
				SqlCommand cmd=new SqlCommand();
				SqlDataReader reader;
				cmd.Connection=conn;
				cmd.CommandText=sql;
				conn.Open();
				reader=cmd.ExecuteReader();
				DataGridx.DataSource=reader;
				DataGridx.DataBind();
				conn.Close();

			}
			catch
			{
				Response.Write("分析失败!");
			}

		}
		
		private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("zhujiemian.aspx");
		}
	}
}

⌨️ 快捷键说明

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