📄 stms_xsc.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;
using System.Data.SqlClient;
namespace WindowsApplication1
{
/// <summary>
/// STMS_XSC 的摘要说明。
/// </summary>
public class STMS_XSC : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public STMS_XSC()
{
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(STMS_XSC));
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// button2
//
this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Font = new System.Drawing.Font("华文行楷", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Location = new System.Drawing.Point(396, 350);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(92, 32);
this.button2.TabIndex = 13;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Font = new System.Drawing.Font("华文行楷", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Location = new System.Drawing.Point(188, 350);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(92, 32);
this.button1.TabIndex = 12;
this.button1.Text = "查询";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Font = new System.Drawing.Font("华文行楷", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Image = ((System.Drawing.Image)(resources.GetObject("label2.Image")));
this.label2.Location = new System.Drawing.Point(204, 302);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 23);
this.label2.TabIndex = 11;
this.label2.Text = "学号";
//
// label1
//
this.label1.Font = new System.Drawing.Font("华文行楷", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
this.label1.Location = new System.Drawing.Point(12, 302);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 23);
this.label1.TabIndex = 10;
this.label1.Text = "班级";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(284, 302);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 9;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(84, 302);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 8;
this.textBox1.Text = "";
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Top;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(542, 296);
this.dataGrid1.TabIndex = 7;
//
// STMS_XSC
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(542, 387);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dataGrid1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "STMS_XSC";
this.Text = "学生查询";
this.Load += new System.EventHandler(this.STMS_XSC_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection cn;
System.Data.SqlClient.SqlDataAdapter da = new SqlDataAdapter();
System.Data.SqlClient.SqlCommand cmd = new SqlCommand();
cn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student;Data Source=(local);");
System.Data.DataSet ds= new System.Data.DataSet();
System.Int32 no;
cmd = new SqlCommand("dbo.studentQuse",cn);
cmd.CommandType =CommandType.StoredProcedure;
try
{
if (this.textBox1.Text !="")
{
no = Convert.ToInt32(this.textBox1.Text);
}
else
{
no = 0;
}
cmd.Parameters.Add("@ord",SqlDbType.Int ,16);
cmd.Parameters["@ord"].Value =no;
cmd.Parameters.Add("@name",SqlDbType.VarChar ,20);
cmd.Parameters["@name"].Value =this.textBox2.Text;
da.SelectCommand =cmd;
da.Fill(ds);
this.dataGrid1.DataSource =ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void STMS_XSC_Load(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -