📄 fmmianshi.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 招聘考试成绩管理系统
{
/// <summary>
/// FMmianshi 的摘要说明。
/// </summary>
public class FMmianshi : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlCommand sqlCommand1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private 招聘考试成绩管理系统.DataSet1 dataSet11;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public FMmianshi()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 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.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet11 = new 招聘考试成绩管理系统.DataSet1();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet11.no_ruqu;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 24);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(296, 224);
this.dataGrid1.TabIndex = 0;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// comboBox1
//
this.comboBox1.DataSource = this.dataSet11.Ddaiwei;
this.comboBox1.DisplayMember = "Dname";
this.comboBox1.Location = new System.Drawing.Point(32, 128);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(120, 20);
this.comboBox1.TabIndex = 1;
this.comboBox1.ValueMember = "Dname";
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 216);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dataGrid1);
this.groupBox1.Location = new System.Drawing.Point(200, 40);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(328, 272);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "未被录用考生";
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"GHX-82E19EF0633\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=zhaopin";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Ddaiwei", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Dname", "Dname")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Dname FROM Ddaiwei";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlDataAdapter2
//
this.sqlDataAdapter2.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter2.SelectCommand = this.sqlSelectCommand2;
this.sqlDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "no_ruqu", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("准考证号", "准考证号"),
new System.Data.Common.DataColumnMapping("英语", "英语"),
new System.Data.Common.DataColumnMapping("语文", "语文"),
new System.Data.Common.DataColumnMapping("政治", "政治"),
new System.Data.Common.DataColumnMapping("总分", "总分")})});
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO no_ruqu(准考证号, 英语, 语文, 政治, 总分) VALUES (@准考证号, @英语, @语文, @政治, @总分); SEL" +
"ECT 准考证号, 英语, 语文, 政治, 总分 FROM no_ruqu";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@准考证号", System.Data.SqlDbType.VarChar, 6, "准考证号"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@英语", System.Data.SqlDbType.Int, 4, "英语"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@语文", System.Data.SqlDbType.Int, 4, "语文"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@政治", System.Data.SqlDbType.Int, 4, "政治"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@总分", System.Data.SqlDbType.Int, 4, "总分"));
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT 准考证号, 英语, 语文, 政治, 总分 FROM no_ruqu";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
//
// FMmianshi
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(552, 342);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "FMmianshi";
this.Text = "考生录用";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.FMmianshi_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void FMmianshi_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11,"Ddaiwei");
sqlDataAdapter2.Fill(dataSet11,"no_ruqu");
//this.comboBox1.SelectedIndex=0;
}
private void button1_Click(object sender, System.EventArgs e)
{
string k=Convert.ToString(this.comboBox1.SelectedIndex+1);
int inRow = dataGrid1.CurrentRowIndex;
string s = dataGrid1[inRow,0].ToString();
string SQL ="select Zno from employ where Zno =";
SQL+=s;
string myConstr ="workstation id=\"GHX-82E19EF0633\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=zhaopin";
SqlCommand myCom= null;
SqlConnection myCon=null;
try
{
myCon =new SqlConnection(myConstr);
myCon.Open();
myCom =new SqlCommand(SQL,myCon);
myCom=new SqlCommand(SQL,myCon);
int power=Convert.ToInt32(myCom.ExecuteScalar());
if(power<=0)
{
SQL="insert into employ(Dno,Zno) Values ('"+k+"','"+s+"')";
myCom.CommandText=SQL;
myCom.ExecuteNonQuery();
MessageBox.Show("提交成功");
}
else
{
MessageBox.Show("此人信息已经存在");
}
}
catch(Exception o)
{
MessageBox.Show(o.Message,"error");
}
finally
{
if(myCon.State==ConnectionState.Open)
myCon.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -