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

📄 dfrep.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 gwpj
{
	/// <summary>
	/// DFREP 的摘要说明。
	/// </summary>
	public class DFREP : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		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 Label8;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label10;
	
		DataSet ds,ds1,ds2;
		public int i=0,j=0;
		public string strtable,sum1,textbox,role_id1;
		static ArrayList al1=new ArrayList();//存放TEXTBOX的NAME
		static ArrayList al2=new ArrayList();//存放岗位ID
		static ArrayList al3=new ArrayList();//存放分值
		string score1,score2,score3,score4,score5,score6,score7,score,score8,score9;
		int score_1,score_2,score_3,score_4,score_5,score_6,score_7;
		double score1_1,score2_2,score3_3,score4_4,score5_5,score6_6,score7_7;
		protected System.Web.UI.WebControls.Label Label11;
		protected System.Web.UI.WebControls.Label Label12;
	
		static string rep;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Label Label13;
		public string prtobj="<OBJECT id=\"WebBrowser\" height=\"0\" width=\"0\" classid=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\" VIEWASTEXT></OBJECT>";
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack)
			{
				select();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		#region 判断数据的COLSPAN ROWSPAN 并取得数据
		private void select()
		{
			al1.Clear();
			al2.Clear();
			SqlConnection cnn=new SqlConnection(ConfigurationSettings.AppSettings["connstring"]);
			cnn.Open();
			//			string sql="select dept_name from evaluated_role group by dept_name";
			string sql="SELECT dept_name,min(role_id)as role_id FROM evaluated_role GROUP BY dept_name order by role_id";
			
			SqlDataAdapter da=new SqlDataAdapter(sql,cnn);
			ds=new DataSet();
			da.Fill(ds,"gwpj");
			for(i=0;i<ds.Tables["gwpj"].Rows.Count;i++)
			{
				string sqlsum="select count(*) as sum1 from evaluated_role where dept_name='"+ds.Tables["gwpj"].Rows[i].ItemArray[0].ToString()+"'";
				SqlCommand cmdsum=new SqlCommand(sqlsum,cnn);
				SqlDataReader drsum=cmdsum.ExecuteReader();
				if(drsum.Read())
				{
					sum1=drsum["sum1"].ToString();
				}
				drsum.Close();
				cmdsum.Dispose();
				string sql1="select evaluated_role,role_id from evaluated_role where dept_name='"+ds.Tables["gwpj"].Rows[i].ItemArray[0].ToString()+"'";
				SqlDataAdapter da1=new SqlDataAdapter(sql1,cnn);
				ds1=new DataSet();
				da1.Fill(ds1,"gwpj1");
				for(j=0;j<ds1.Tables["gwpj1"].Rows.Count;j++)
				{
					textbox="TextBox"+ds1.Tables["gwpj1"].Rows[j].ItemArray[1].ToString();
					al1.Add(textbox);
					role_id1=ds1.Tables["gwpj1"].Rows[j].ItemArray[1].ToString();
					al2.Add(role_id1);
					al3.Clear();
					for(int k=1;k<8;k++)
					{
						string sqlshow="select score from FCH_SCORE_REP where role_id='"+role_id1+"' and factor_id='"+k+"'";
						SqlCommand cmdshow=new SqlCommand(sqlshow,cnn);
						SqlDataReader drshow=cmdshow.ExecuteReader();
						if(drshow.Read())
						{
							score=drshow["score"].ToString();
							al3.Add(score);
						}
						else
						{
							drshow.Close();
							score="";
							al3.Add(score);
						}
						drshow.Close();
						cmdshow.Dispose();
					}
					//drshow.Close();


					string sql2="select * from factor order by factor_id";
					SqlDataAdapter da2=new SqlDataAdapter(sql2,cnn);
					ds2=new DataSet();
					da2.Fill(ds2,"factor");

					if(al3[0].ToString()!=""){
						score1=al3[0].ToString();
						score_1=int.Parse(al3[0].ToString());
//						score1_1=score_1*0.38;
						score1_1=score_1*double.Parse(ds2.Tables["factor"].Rows[0].ItemArray[4].ToString());
					}
					else{
						score1="&nbsp;";
						score_1=0;
						score1_1=0;
					}
					if(al3[1].ToString()!="")
					{
						score2=al3[1].ToString();
						score_2=int.Parse(al3[1].ToString());
//						score2_2=score_2*0.11;
						score2_2=score_2*double.Parse(ds2.Tables["factor"].Rows[1].ItemArray[4].ToString());
					}
					else
					{
						score2="&nbsp;";
						score_2=0;
						score2_2=0;
					}
					if(al3[2].ToString()!="")
					{
						score3=al3[2].ToString();
						score_3=int.Parse(al3[2].ToString());
//						score3_3=score_3*0.13;
						score3_3=score_3*double.Parse(ds2.Tables["factor"].Rows[2].ItemArray[4].ToString());
					}
					else
					{
						score3="&nbsp;";
						score_3=0;
						score3_3=0;
					}
					if(al3[3].ToString()!="")
					{
						score4=al3[3].ToString();
						score_4=int.Parse(al3[3].ToString());
//						score4_4=score_4*0.08;
						score4_4=score_4*double.Parse(ds2.Tables["factor"].Rows[3].ItemArray[4].ToString());
					}
					else
					{
						score4="&nbsp;";
						score_4=0;
						score4_4=0;
					}
					if(al3[4].ToString()!="")
					{
						score5=al3[4].ToString();
						score_5=int.Parse(al3[4].ToString());
//						score5_5=score_5*0.16;
						score5_5=score_5*double.Parse(ds2.Tables["factor"].Rows[4].ItemArray[4].ToString());
					}
					else
					{
						score5="&nbsp;";
						score_5=0;
						score5_5=0;
					}
					if(al3[5].ToString()!="")
					{
						score6=al3[5].ToString();
						score_6=int.Parse(al3[5].ToString());
//						score6_6=score_6*0.11;
						score6_6=score_6*double.Parse(ds2.Tables["factor"].Rows[5].ItemArray[4].ToString());
					}
					else
					{
						score6="&nbsp;";
						score_6=0;
						score6_6=0;
					}
					if(al3[6].ToString()!="")
					{
						score7=al3[6].ToString();
						score_7=int.Parse(al3[6].ToString());
//						score7_7=score_7*0.03;
						score7_7=score_7*double.Parse(ds2.Tables["factor"].Rows[6].ItemArray[4].ToString());
					}
					else
					{
						score7="&nbsp;";
						score_7=0;
						score7_7=0;
					}
					score8=Convert.ToString(score_1+score_2+score_3+score_4+score_5+score_6+score_7);
					score9=Convert.ToString(score1_1+score2_2+score3_3+score4_4+score5_5+score6_6+score7_7);

					showtable();
					da2.Dispose();
					ds2.Dispose();
				}
				ds1.Dispose();
				da1.Dispose();
			}
			da.Dispose();
			ds.Dispose();
			cnn.Close();
			rep="<table width=\"100%\" border=\"1\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\" id=\"table1\" borderColor=\"#005dab\" borderColorDark=\"#f5f5f5\"><tr><td align=\"center\" colspan=\"11\" height=\"30\"><strong>岗位评价统计表</strong></td></tr><tr><td rowspan=\"2\" align=\"center\">部门名称</td><td rowspan=\"2\" align=\"center\">被测评岗位</td><td height=\"25\" colspan=\"9\" align=\"center\">评价要素</td></tr>"
				+"<tr><td height=\"25\" align=\"center\">对企业的影响</td><td align=\"center\">管理幅度</td><td align=\"center\">责任范围</td><td align=\"center\">沟通技巧</td><td align=\"center\">任职资格</td><td align=\"center\">解决问题难度</td><td align=\"center\">工作特征</td><td align=\"center\">总分</td><td align=\"center\">加权平均分</td>"
				+"</tr>"+strtable+"</table>";
		} 
		#endregion

		#region 显示动态的打分表
		private void showtable()
		{
			if(i==0&&j==0)
			{
				strtable=strtable+"<tr align=\"center\"><td height=\"25\" rowspan='"+sum1+"'>"+ds.Tables["gwpj"].Rows[i].ItemArray[0].ToString()+"</td><td>"+ds1.Tables["gwpj1"].Rows[j].ItemArray[0].ToString()+"</td><td>"+score1+"</td><td>"+score2+"</td><td>"+score3+"</td><td>"+score4+"</td><td>"+score5+"</td><td>"+score6+"</td><td>"+score7+"</td><td>"+score8+"</td><td>"+score9+"</td></tr>";
			}
			else
			{
				if(i==0&&j!=0)
				{
					strtable=strtable+"<tr align=\"center\"><td>"+ds1.Tables["gwpj1"].Rows[j].ItemArray[0].ToString()+"</td><td>"+score1+"</td><td>"+score2+"</td><td>"+score3+"</td><td>"+score4+"</td><td>"+score5+"</td><td>"+score6+"</td><td>"+score7+"</td><td>"+score8+"</td><td>"+score9+"</td></tr>";
				}
				else
				{
					if(i!=0&&j==0)
					{
						strtable=strtable+"<tr align=\"center\"><td height=\"25\" rowspan='"+sum1+"'>"+ds.Tables["gwpj"].Rows[i].ItemArray[0].ToString()+"</td><td>"+ds1.Tables["gwpj1"].Rows[j].ItemArray[0].ToString()+"</td><td>"+score1+"</td><td>"+score2+"</td><td>"+score3+"</td><td>"+score4+"</td><td>"+score5+"</td><td>"+score6+"</td><td>"+score7+"</td><td>"+score8+"</td><td>"+score9+"</td></tr>";
					}
					else
					{
						if(i!=0&&j!=0)
						{
							strtable=strtable+"<tr align=\"center\"><td>"+ds1.Tables["gwpj1"].Rows[j].ItemArray[0].ToString()+"</td><td>"+score1+"</td><td>"+score2+"</td><td>"+score3+"</td><td>"+score4+"</td><td>"+score5+"</td><td>"+score6+"</td><td>"+score7+"</td><td>"+score8+"</td><td>"+score9+"</td></tr>";
						}
					}
				}
			}
		}
		#endregion


		private void Button2_Click(object sender, System.EventArgs e)
		{
			Response.Clear();
			Response.Buffer= true;
			Response.Charset="GB2312";
			this.Label13.Text=rep;
			Response.AppendHeader("Content-Disposition","attachment;filename=ReptName.xls");
			Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
			Response.ContentType = "application/ms-excel";
			this.EnableViewState = false;
			System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
			System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
			this.Label13.RenderControl(oHtmlTextWriter);
			Response.Write(oStringWriter.ToString());
			Response.End();
			this.Button2.Enabled=false;
		}
	}
}

⌨️ 快捷键说明

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