📄 fenxiyb.aspx.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 fenxiyb.
/// </summary>
public class fenxiyb : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.Label Label14;
protected System.Web.UI.WebControls.Label Label16;
protected System.Web.UI.WebControls.Label Label17;
protected System.Web.UI.WebControls.Label Label18;
protected System.Web.UI.WebControls.Label Label19;
protected System.Web.UI.WebControls.Label Label20;
protected System.Web.UI.WebControls.Label Label21;
protected System.Web.UI.WebControls.Label Label22;
protected System.Web.UI.WebControls.Label Label23;
protected System.Web.UI.WebControls.Label Label24;
protected System.Web.UI.WebControls.Label Label25;
protected System.Web.UI.WebControls.Label Label26;
protected System.Web.UI.WebControls.Label Label27;
protected System.Web.UI.WebControls.Label Label28;
protected System.Web.UI.WebControls.Label Label29;
protected System.Web.UI.WebControls.Label Label30;
protected System.Web.UI.WebControls.Label Label31;
protected System.Web.UI.WebControls.Label Label32;
protected System.Web.UI.WebControls.Label Label33;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Label Label34;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
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.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 dbo.szb.szbname AS 指标名称, dbo.szbsj.njh AS 年计划,dbo.szbsj.nlj AS 年累计, CAST(dbo.szbsj.nlj AS int) / CAST(dbo.szbsj.njh AS int)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 left JOIN dbo.szbsj ON dbo.company.comid = dbo.szbsj.comid cross JOIN dbo.szb";
//sql+=" from dbo.company left JOIN dbo.szbsj ON dbo.company.comid = dbo.szbsj.comid right JOIN dbo.szb ON dbo.szbsj.comid = dbo.szb.szbid";
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+="and (dbo.szb.szbid = 1 OR dbo.szb.szbid = 3 OR dbo.szb.szbid = 5 OR dbo.szb.szbid = 7 OR dbo.szb.szbid = 17 OR dbo.szb.szbid = 19 OR dbo.szb.szbid = 20 OR dbo.szb.szbid = 8)";
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();
DataGrid1.DataSource=reader;
DataGrid1.DataBind();
conn.Close();
string sel="SELECT SUM(CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label4.Text=this.GetValueFromSql(sel);
string sel1="SELECT SUM(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label5.Text=this.GetValueFromSql(sel1);
string sel2="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label6.Text=this.GetValueFromSql(sel2);
string sel3="SELECT SUM(CAST(ysj AS int)-cast(yjh as int)) AS Expr1 FROM szbsj WHERE (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label7.Text=this.GetValueFromSql(sel3);
string sel4="SELECT SUM(CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label9.Text=this.GetValueFromSql(sel4);
string sel5="SELECT SUM(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label10.Text=this.GetValueFromSql(sel5);
string sel6="SELECT SUM(CAST(ysj AS int)-cast(yjh as int)) AS Expr1 FROM szbsj WHERE (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label11.Text=this.GetValueFromSql(sel6);
string sel7="SELECT SUM(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (szbid=2 or szbid=4 or szbid=6) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label13.Text=this.GetValueFromSql(sel7);
string sel8="SELECT SUM(CAST(ysj AS int)-cast(yjh as int)) AS Expr1 FROM szbsj WHERE (szbid=2 or szbid=4 or szbid=6) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label14.Text=this.GetValueFromSql(sel8);
string sel9="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 1) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label16.Text=this.GetValueFromSql(sel9);
string sel10="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 2) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label17.Text=this.GetValueFromSql(sel10);
string sel11="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 3) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label18.Text=this.GetValueFromSql(sel11);
string sel12="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 4) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label19.Text=this.GetValueFromSql(sel12);
string sel13="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 5) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label20.Text=this.GetValueFromSql(sel13);
string sel14="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (comid = 3) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label21.Text=this.GetValueFromSql(sel14);
string sel15="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (comid = 4) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label22.Text=this.GetValueFromSql(sel15);
string sel16="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (comid = 5) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label23.Text=this.GetValueFromSql(sel16);
string sel17="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (comid = 2) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label24.Text=this.GetValueFromSql(sel17);
string sel18="SELECT (sum(CAST(ysj AS int))/sum(cast(yjh as int)) * 100) AS Expr1 FROM szbsj WHERE (comid = 1) and (szbid=1 or szbid=3 or szbid=5) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label25.Text=this.GetValueFromSql(sel18);
string sel19="SELECT sum(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (comid=2) and (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label26.Text=this.GetValueFromSql(sel19);
string sel20="SELECT sum(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (comid=1) and (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label27.Text=this.GetValueFromSql(sel20);
string sel21="SELECT sum(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (comid=4) and (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label28.Text=this.GetValueFromSql(sel21);
string sel22="SELECT sum(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (comid=3) and (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label29.Text=this.GetValueFromSql(sel22);
string sel23="SELECT sum(CAST(ysj AS int)) AS Expr1 FROM szbsj WHERE (comid=5) and (szbid=20) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label30.Text=this.GetValueFromSql(sel23);
string sel24="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 1) and (szbid=2 or szbid=4 or szbid=6) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label31.Text=this.GetValueFromSql(sel24);
string sel25="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 2) and (szbid=2 or szbid=4 or szbid=6) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label32.Text=this.GetValueFromSql(sel25);
string sel26="SELECT SUM(CAST(ysj AS int) - CAST(yjh AS int)) AS Expr1 FROM szbsj WHERE (comid = 3) and (szbid=2 or szbid=4 or szbid=6) and [time]='"+this.DropDownList2.SelectedValue+"'";
Label33.Text=this.GetValueFromSql(sel26);
}
catch{}
}
private string GetValueFromSql(string sql)
{
string res="";
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();
reader.Read();
res=reader[0].ToString();
reader.Close();
conn.Close();
return res;
}
private void Button2_Click(object sender, System.EventArgs e)
{
Response.Redirect("zhujiemian.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -