📄 personalsearch.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>
/// PersonalSearch 的摘要说明。
/// </summary>
public class PersonalSearch : System.Windows.Forms.Form
{
private DataSet ds=new DataSet();
private string sendStrSQL;
private string sendTableName="成绩表";
private DataTable myTable;
private LinkDataBase link=new LinkDataBase();
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtID;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public PersonalSearch()
{
//
// 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.label1 = new System.Windows.Forms.Label();
this.txtID = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(13, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 23);
this.label1.TabIndex = 0;
this.label1.Text = "输入学号";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtID
//
this.txtID.Location = new System.Drawing.Point(87, 16);
this.txtID.Name = "txtID";
this.txtID.TabIndex = 0;
this.txtID.Text = "";
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(205, 14);
this.btnSearch.Name = "btnSearch";
this.btnSearch.TabIndex = 2;
this.btnSearch.Text = "查询";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(14, 56);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(264, 192);
this.dataGrid1.TabIndex = 3;
//
// PersonalSearch
//
this.AcceptButton = this.btnSearch;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.txtID);
this.Controls.Add(this.label1);
this.Name = "PersonalSearch";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "个个人成绩";
this.Load += new System.EventHandler(this.PersonalSearch_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void PersonalSearch_Load(object sender, System.EventArgs e)
{
this.dataGrid1.CaptionText="学生成绩查询";
myTable=new DataTable();
myTable.Columns.Add("名称",typeof(char));
myTable.Columns.Add("成绩",typeof(int));
this.dataGrid1.DataSource=myTable;
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
if(this.txtID.Text=="")
{
MessageBox.Show("学号不能为空","提示");
return;
}
this.sendStrSQL="select 课程表.名称,成绩表.成绩 from 成绩表 inner join 课程表 on 课程表.编号=成绩表.课程编号"
+" where(成绩表.学号='"+txtID.Text.Trim()+"')";
this.ds=link.SelectDataBase(sendStrSQL,sendTableName);
this.dataGrid1.DataSource=ds;
this.dataGrid1.DataMember="成绩表";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -