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

📄 form4.cs

📁 本科生面试崔健研究生的软件评选系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;


namespace recommendation
{
	/// <summary>
	/// Form4 的摘要说明。
	/// </summary>
	public class Form4 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label7;
		public System.Windows.Forms.ListView listView1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.ColumnHeader columnHeader1;
		private System.Windows.Forms.ColumnHeader columnHeader2;
		private System.Windows.Forms.ColumnHeader columnHeader3;
		private System.Windows.Forms.ColumnHeader columnHeader4;
		private System.Windows.Forms.Button button2;
		private System.Data.OleDb.OleDbConnection oleDbConnection1;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label2;
		public System.Windows.Forms.TextBox PXbili;
		public System.Windows.Forms.TextBox ZYbili;
		private System.Windows.Forms.RadioButton radioButton1;
		private System.Windows.Forms.RadioButton radioButton2;
		private System.Data.OleDb.OleDbConnection oleDbConnection2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form4()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
		}
			//初始化规则
		

			/// <summary>
			/// 清理所有正在使用的资源。
			/// </summary>
			protected override void Dispose( bool disposing )
			{
				if( disposing )
				{
					if(components != null)
					{
						components.Dispose();
					}
				}
				base.Dispose( disposing );
			}
	
		
			#region Windows 窗体设计器生成的代码
			/// <summary>
			/// 设计器支持所需的方法 - 不要使用代码编辑器修改
			/// 此方法的内容。
			/// </summary>
			private void InitializeComponent()
			{
				this.label1 = new System.Windows.Forms.Label();
				this.label7 = new System.Windows.Forms.Label();
				this.listView1 = new System.Windows.Forms.ListView();
				this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
				this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
				this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
				this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
				this.button1 = new System.Windows.Forms.Button();
				this.button2 = new System.Windows.Forms.Button();
				this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
				this.label8 = new System.Windows.Forms.Label();
				this.PXbili = new System.Windows.Forms.TextBox();
				this.label2 = new System.Windows.Forms.Label();
				this.ZYbili = new System.Windows.Forms.TextBox();
				this.radioButton1 = new System.Windows.Forms.RadioButton();
				this.radioButton2 = new System.Windows.Forms.RadioButton();
				this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection();
				this.SuspendLayout();
				// 
				// label1
				// 
				this.label1.Location = new System.Drawing.Point(8, 16);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size(96, 16);
				this.label1.TabIndex = 0;
				this.label1.Text = "请输入评选比例";
				// 
				// label7
				// 
				this.label7.Font = new System.Drawing.Font("楷体_GB2312", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
				this.label7.ForeColor = System.Drawing.Color.Red;
				this.label7.Location = new System.Drawing.Point(144, 128);
				this.label7.Name = "label7";
				this.label7.Size = new System.Drawing.Size(128, 24);
				this.label7.TabIndex = 9;
				this.label7.Text = "评选结果如下";
				// 
				// listView1
				// 
				this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
					| System.Windows.Forms.AnchorStyles.Left) 
					| System.Windows.Forms.AnchorStyles.Right)));
				this.listView1.BackColor = System.Drawing.SystemColors.Window;
				this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																							this.columnHeader1,
																							this.columnHeader2,
																							this.columnHeader3,
																							this.columnHeader4});
				this.listView1.Location = new System.Drawing.Point(0, 160);
				this.listView1.Name = "listView1";
				this.listView1.Size = new System.Drawing.Size(560, 280);
				this.listView1.TabIndex = 10;
				this.listView1.View = System.Windows.Forms.View.Details;
				// 
				// columnHeader1
				// 
				this.columnHeader1.Text = "学号";
				// 
				// columnHeader2
				// 
				this.columnHeader2.Text = "姓名";
				this.columnHeader2.Width = 80;
				// 
				// columnHeader3
				// 
				this.columnHeader3.Text = "最后总分";
				this.columnHeader3.Width = 72;
				// 
				// columnHeader4
				// 
				this.columnHeader4.Text = "是否入选";
				this.columnHeader4.Width = 112;
				// 
				// button1
				// 
				this.button1.BackColor = System.Drawing.Color.Red;
				this.button1.Location = new System.Drawing.Point(264, 8);
				this.button1.Name = "button1";
				this.button1.Size = new System.Drawing.Size(88, 23);
				this.button1.TabIndex = 11;
				this.button1.Text = "开始评选";
				this.button1.Click += new System.EventHandler(this.button1_Click);
				// 
				// button2
				// 
				this.button2.BackColor = System.Drawing.Color.Red;
				this.button2.Location = new System.Drawing.Point(264, 48);
				this.button2.Name = "button2";
				this.button2.Size = new System.Drawing.Size(88, 23);
				this.button2.TabIndex = 12;
				this.button2.Text = "查看评比规则";
				this.button2.Click += new System.EventHandler(this.button2_Click);
				// 
				// oleDbConnection1
				// 
				this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=""recommendation.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
				this.oleDbConnection1.InfoMessage += new System.Data.OleDb.OleDbInfoMessageEventHandler(this.oleDbConnection1_InfoMessage);
				// 
				// label8
				// 
				this.label8.Location = new System.Drawing.Point(16, 96);
				this.label8.Name = "label8";
				this.label8.Size = new System.Drawing.Size(56, 16);
				this.label8.TabIndex = 13;
				this.label8.Text = "六级过否";
				// 
				// PXbili
				// 
				this.PXbili.Location = new System.Drawing.Point(160, 8);
				this.PXbili.Name = "PXbili";
				this.PXbili.Size = new System.Drawing.Size(72, 21);
				this.PXbili.TabIndex = 16;
				this.PXbili.Text = "0.2";
				// 
				// label2
				// 
				this.label2.Location = new System.Drawing.Point(8, 56);
				this.label2.Name = "label2";
				this.label2.Size = new System.Drawing.Size(128, 16);
				this.label2.TabIndex = 17;
				this.label2.Text = "输入专业成绩所占比例";
				// 
				// ZYbili
				// 
				this.ZYbili.Location = new System.Drawing.Point(160, 48);
				this.ZYbili.Name = "ZYbili";
				this.ZYbili.Size = new System.Drawing.Size(72, 21);
				this.ZYbili.TabIndex = 18;
				this.ZYbili.Text = "0.8";
				this.ZYbili.WordWrap = false;
				// 
				// radioButton1
				// 
				this.radioButton1.Location = new System.Drawing.Point(96, 88);
				this.radioButton1.Name = "radioButton1";
				this.radioButton1.Size = new System.Drawing.Size(72, 24);
				this.radioButton1.TabIndex = 19;
				this.radioButton1.Text = "要求过";
				// 
				// radioButton2
				// 
				this.radioButton2.Checked = true;
				this.radioButton2.Location = new System.Drawing.Point(176, 88);
				this.radioButton2.Name = "radioButton2";
				this.radioButton2.Size = new System.Drawing.Size(64, 24);
				this.radioButton2.TabIndex = 20;
				this.radioButton2.TabStop = true;
				this.radioButton2.Text = "无要求";
				// 
				// oleDbConnection2
				// 
				this.oleDbConnection2.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=""F:\recommendation\recommendation\jxj2\bin\Debug\recommendation.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
				// 
				// Form4
				// 
				this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
				this.BackColor = System.Drawing.SystemColors.ActiveBorder;
				this.ClientSize = new System.Drawing.Size(560, 445);
				this.Controls.Add(this.radioButton2);
				this.Controls.Add(this.radioButton1);
				this.Controls.Add(this.ZYbili);
				this.Controls.Add(this.label2);
				this.Controls.Add(this.PXbili);
				this.Controls.Add(this.label8);
				this.Controls.Add(this.button2);
				this.Controls.Add(this.button1);
				this.Controls.Add(this.listView1);
				this.Controls.Add(this.label7);
				this.Controls.Add(this.label1);
				this.Name = "Form4";
				this.Text = "评比选项";
				this.ResumeLayout(false);

			}
		#endregion

		private void button2_Click(object sender, System.EventArgs e)
		{
			recommendation.Form5 explain=new Form5(this.radioButton1.Checked,this.PXbili.Text.ToString(),this.ZYbili.Text.ToString());
			explain.ShowDialog();
		}
		//开始评比
		private void button1_Click(object sender, System.EventArgs e)
		{
		    try
			{				
				this.oleDbConnection1.Open();
				this.oleDbConnection2.Open();
				
				//计算并排序
				
				//选出具有重大发明奖的同学
				string selstr2="select id,name,MajorPrize from student";
				string selstr3="select ID,gaoshu,zhengzhi,English,os,network,database,bianyi,C from original order by ID";
				System.Data.OleDb.OleDbCommand sel=new System.Data.OleDb.OleDbCommand(selstr2,this.oleDbConnection1);
				System.Data.OleDb.OleDbCommand sel1=new System.Data.OleDb.OleDbCommand(selstr3,this.oleDbConnection2);
				System.Data.OleDb.OleDbDataReader rd2=sel.ExecuteReader();
				System.Data.OleDb.OleDbDataReader rd3=sel1.ExecuteReader();
				int CountMP=0;
				this.listView1.Items.Clear();
				while(rd2.Read())
				{
					int mp=rd2.GetInt32(2);
					if(mp==1)
					{	
						ListViewItem LiItem1=new ListViewItem(System.Convert.ToString(rd2.GetInt32(0)));
						LiItem1.SubItems.Add(rd2.GetString(1).Trim());						
						LiItem1.SubItems.Add("  ");	
						LiItem1.SubItems.Add("发明奖获得者入选");
						this.listView1.Items.Insert(CountMP,LiItem1);
						//this.listView1.Items.Add(LiItem1);
						CountMP++;
					}
				}
				rd2.Close();

				int[]  st_fail=new int[11];
				int st_id=0;
				while(rd3.Read())
				{
				   st_id=rd3.GetInt32(0);
					for(int p=1;p<9;p++)
					{
						int score=rd3.GetInt32(p);
						if(score< 60)
						{
							st_fail[st_id]=1;
							break;
						}

						else st_fail[st_id]=0;
					}
				
				}
				rd3.Close();
				this.oleDbConnection2.Close();

				//依据最终成绩排名
				string choose="",MP="and student.MajorPrize=0";
				if(this.radioButton1.Checked)
				{
					choose="and student.cet6 = '1'";
				}
				else
					choose="and ( student.cet6 = '1' or student.cet6 = '0')";

				string selstr1="select count(student.id) from student";
				sel=new System.Data.OleDb.OleDbCommand(selstr1,this.oleDbConnection1);
				int icount=System.Convert.ToInt32(sel.ExecuteScalar().ToString().Trim());
				
				double dpxbili = System.Convert.ToDouble(PXbili.Text.ToString());
				double dzybili = System.Convert.ToDouble(ZYbili.Text.ToString() );

				string selstr="select student.id,student.name,(student.score*"+dzybili+"+acscore.score*"+(1-dzybili)+")as result "+
					" from (select (sum(num.num*actionitem.actionscore)) as score,num.studentid from num,actionitem "+
					" where num.actionid=actionitem.actionid group by num.studentid) as acscore,student "+
					"where acscore.studentid=student.id "+choose+""+ MP +" "+ 
					"order by (student.score*"+dzybili+"+acscore.score*"+(1-dzybili)+")desc";
				sel=new System.Data.OleDb.OleDbCommand(selstr,this.oleDbConnection1);
				System.Data.OleDb.OleDbDataReader rd1=sel.ExecuteReader();
				
				double score1=-1,score2=0;
 				int i=0;
				int j=System.Convert.ToInt32(icount*dpxbili);
				j-=CountMP;
				int k=0;
				
				//this.listView1.Items.Clear();
				while(rd1.Read())  
				{
					ListViewItem LiItem=new ListViewItem(System.Convert.ToString(rd1.GetInt32(0)));
					LiItem.SubItems.Add(rd1.GetString(1).Trim());
					score2 = rd1.GetDouble(2);
					LiItem.SubItems.Add(score2.ToString());		
					if(st_fail[i]==0)
					{
						if(k<(j-1))
						{
							LiItem.SubItems.Add("入选");					
						}
						else if(k == (j-1)) 
						{
							score1=score2;
							LiItem.SubItems.Add("入选");
						}
						else 
						{
							if(score1==score2)
								LiItem.SubItems.Add("入选");
							else
								LiItem.SubItems.Add("未入选");
						}					
						//this.listView1.Items.Insert(index,LiItem);
						this.listView1.Items.Add(LiItem);
						//index++;
						k++;
					}
					else
					{
						LiItem.SubItems.Add("单科成绩不合格");	
						this.listView1.Items.Add(LiItem);
					}
					i++;

					
				}                    
				this.oleDbConnection1.Close();
			}
			catch(Exception ex2)
			{
				MessageBox.Show(ex2.Message);
				this.oleDbConnection1.Close();
				this.oleDbConnection2.Close();
				return;
			}
		}

		private void oleDbConnection1_InfoMessage(object sender, System.Data.OleDb.OleDbInfoMessageEventArgs e)
		{
		
		}

	

		
	}
}

⌨️ 快捷键说明

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