📄 fm_nos1.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>
/// Fm_nos 的摘要说明。
/// </summary>
public class Fm_nos1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btquery;
private System.Windows.Forms.ComboBox comboBox;
private System.Windows.Forms.TextBox textBox1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlCommand sqlCommand1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private 招聘考试成绩管理系统.DataSet1 dataSet11;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Fm_nos1()
{
//
// 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.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btquery = new System.Windows.Forms.Button();
this.comboBox = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet11 = new 招聘考试成绩管理系统.DataSet1();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// label2
//
this.label2.Font = new System.Drawing.Font("华文楷体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(184, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(136, 24);
this.label2.TabIndex = 6;
this.label2.Text = "考生成绩查询";
//
// label4
//
this.label4.Location = new System.Drawing.Point(240, 64);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 16);
this.label4.TabIndex = 12;
this.label4.Text = "关键字:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 11;
this.label3.Text = "查询类型:";
//
// btquery
//
this.btquery.Location = new System.Drawing.Point(432, 56);
this.btquery.Name = "btquery";
this.btquery.TabIndex = 10;
this.btquery.Text = "查询";
this.btquery.Click += new System.EventHandler(this.btquery_Click);
//
// comboBox
//
this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.comboBox.Items.AddRange(new object[] {
"准考证号码",
"总分"});
this.comboBox.Location = new System.Drawing.Point(104, 56);
this.comboBox.Name = "comboBox";
this.comboBox.Size = new System.Drawing.Size(121, 20);
this.comboBox.Sorted = true;
this.comboBox.TabIndex = 9;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(312, 56);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 8;
this.textBox1.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";
//
// sqlCommand1
//
this.sqlCommand1.CommandText = "SELECT * FROM mark_no";
this.sqlCommand1.Connection = this.sqlConnection1;
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet11.mark_no;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(32, 96);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(489, 224);
this.dataGrid1.TabIndex = 13;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "mark_no", 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("政治", "政治"),
new System.Data.Common.DataColumnMapping("总分", "总分")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 准考证号, 姓名, 英语, 语文, 政治, 总分 FROM mark_no";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO mark_no(准考证号, 姓名, 英语, 语文, 政治, 总分) VALUES (@准考证号, @姓名, @英语, @语文, @政治, " +
"@总分); SELECT 准考证号, 姓名, 英语, 语文, 政治, 总分 FROM mark_no";
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.VarChar, 10, "姓名"));
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, "总分"));
//
// Fm_nos1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(558, 364);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.btquery);
this.Controls.Add(this.comboBox);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "Fm_nos1";
this.Text = "Fm_nos1";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Fm_nos_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Fm_nos_Load(object sender, System.EventArgs e)
{
this.comboBox.SelectedIndex =1;
sqlDataAdapter1.Fill(dataSet11,"mark_no");
}
private void btquery_Click(object sender, System.EventArgs e)
{
try
{
if(this.textBox1.Text.Trim()=="")
return;
string str ="select * from mark_no ";
if(this.comboBox.SelectedIndex==0)
str += "where 准考证号 = "+this.textBox1.Text;
else
str += "where 总分 = "+this.textBox1.Text;
this.sqlCommand1.CommandType=CommandType.Text;
this.sqlDataAdapter1.SelectCommand = sqlCommand1;
sqlCommand1.CommandText=str;
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11,"mark_no");
}
catch(Exception oe)
{
this.textBox1.Text=oe.Message;
MessageBox.Show(oe.Message,"Error");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -