?? fm_imformq.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 招聘考試成績管理系統(tǒng)
{
/// <summary>
/// fm_imformq 的摘要說明。
/// </summary>
public class fm_imformq : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private 招聘考試成績管理系統(tǒng).DataSet1 dataSet11;
private System.Data.SqlClient.SqlCommand sqlCommand1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btquery;
private System.Windows.Forms.ComboBox comboBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public fm_imformq()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataSet11 = new 招聘考試成績管理系統(tǒng).DataSet1();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.textBox1 = new System.Windows.Forms.TextBox();
this.comboBox = new System.Windows.Forms.ComboBox();
this.btquery = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// 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.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "vstudent", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("準(zhǔn)考證號", "準(zhǔn)考證號"),
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 vstudent(準(zhǔn)考證號, 姓名, 性別, 生日, 地址, 身份證, 電話) VALUES (@準(zhǔn)考證號, @姓名, @性別, @生日," +
" @地址, @身份證, @電話); SELECT 準(zhǔn)考證號, 姓名, 性別, 生日, 地址, 身份證, 電話 FROM vstudent";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@準(zhǔn)考證號", System.Data.SqlDbType.VarChar, 6, "準(zhǔn)考證號"));
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.VarChar, 10, "性別"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@生日", System.Data.SqlDbType.VarChar, 20, "生日"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@地址", System.Data.SqlDbType.VarChar, 50, "地址"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@身份證", System.Data.SqlDbType.VarChar, 20, "身份證"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@電話", System.Data.SqlDbType.VarChar, 20, "電話"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 準(zhǔn)考證號, 姓名, 性別, 生日, 地址, 身份證, 電話 FROM vstudent";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// sqlCommand1
//
this.sqlCommand1.Connection = this.sqlConnection1;
this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Zno", System.Data.SqlDbType.Char, 6));
this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.Char, 10));
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet11.vstudent;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 104);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.RowHeadersVisible = false;
this.dataGrid1.Size = new System.Drawing.Size(530, 264);
this.dataGrid1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(296, 74);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
//
// comboBox
//
this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.comboBox.Items.AddRange(new object[] {
"姓名",
"準(zhǔn)考證號碼"});
this.comboBox.Location = new System.Drawing.Point(88, 75);
this.comboBox.Name = "comboBox";
this.comboBox.Size = new System.Drawing.Size(121, 20);
this.comboBox.Sorted = true;
this.comboBox.TabIndex = 3;
//
// btquery
//
this.btquery.Location = new System.Drawing.Point(416, 72);
this.btquery.Name = "btquery";
this.btquery.TabIndex = 4;
this.btquery.Text = "查詢";
this.btquery.Click += new System.EventHandler(this.btquery_Click);
//
// 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(192, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(136, 24);
this.label2.TabIndex = 5;
this.label2.Text = "考生信息查詢";
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 79);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 6;
this.label3.Text = "查詢類型:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(224, 79);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 16);
this.label4.TabIndex = 7;
this.label4.Text = "關(guān)鍵字:";
//
// fm_imformq
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(560, 374);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.btquery);
this.Controls.Add(this.comboBox);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dataGrid1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "fm_imformq";
this.Text = "考生信息查詢";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.fm_imformq_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void fm_imformq_Load(object sender, System.EventArgs e)
{
this.comboBox.SelectedIndex =1;
sqlDataAdapter1.Fill(dataSet11,"vstudent");
}
private void btquery_Click(object sender, System.EventArgs e)
{
try
{
this.sqlCommand1.Parameters[0].Value="%"+this.textBox1.Text+"%";
this.sqlCommand1.Parameters[1].Value="%"+this.textBox1.Text+"%";
string str ="select * from vstudent ";
if(this.comboBox.SelectedIndex==0)
str += "where 姓名 like @Name";
else
str += "where 準(zhǔn)考證號 like @Zno ";
this.sqlCommand1.CommandType=CommandType.Text;
this.sqlDataAdapter1.SelectCommand = sqlCommand1;
sqlCommand1.CommandText=str;
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11,"vstudent");
}
catch(Exception oe)
{
this.textBox1.Text=oe.Message;
MessageBox.Show(oe.Message,"Error");
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -