📄 score_reserch.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace chaxun
{
/// <summary>
/// Score_reserch 的摘要说明。
/// </summary>
public class Score_reserch : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.TextBox txt_Xh;
private System.Windows.Forms.Button btn_research;
private System.Windows.Forms.TextBox txt_Cou_Scor;
private System.Windows.Forms.TextBox txt_textID;
private System.Windows.Forms.TextBox txt_avg;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Score_reserch()
{
//
// 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.label1 = new System.Windows.Forms.Label();
this.txt_Xh = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.btn_research = new System.Windows.Forms.Button();
this.txt_Cou_Scor = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.txt_textID = new System.Windows.Forms.TextBox();
this.txt_avg = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(6, 6);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(402, 224);
this.dataGrid1.TabIndex = 0;
//
// label1
//
this.label1.Location = new System.Drawing.Point(18, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 18);
this.label1.TabIndex = 1;
this.label1.Text = "学 号:";
//
// txt_Xh
//
this.txt_Xh.Location = new System.Drawing.Point(84, 19);
this.txt_Xh.Name = "txt_Xh";
this.txt_Xh.Size = new System.Drawing.Size(75, 21);
this.txt_Xh.TabIndex = 2;
this.txt_Xh.Text = "";
this.txt_Xh.TextChanged += new System.EventHandler(this.txt_Xh_TextChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(18, 68);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(36, 18);
this.label3.TabIndex = 5;
this.label3.Text = "总分:";
//
// btn_research
//
this.btn_research.Location = new System.Drawing.Point(12, 124);
this.btn_research.Name = "btn_research";
this.btn_research.Size = new System.Drawing.Size(72, 25);
this.btn_research.TabIndex = 6;
this.btn_research.Text = "查询";
this.btn_research.Click += new System.EventHandler(this.btn_research_Click);
//
// txt_Cou_Scor
//
this.txt_Cou_Scor.Location = new System.Drawing.Point(84, 62);
this.txt_Cou_Scor.Name = "txt_Cou_Scor";
this.txt_Cou_Scor.Size = new System.Drawing.Size(75, 21);
this.txt_Cou_Scor.TabIndex = 7;
this.txt_Cou_Scor.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(12, 68);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(66, 18);
this.label4.TabIndex = 8;
this.label4.Text = "课程号:";
//
// txt_textID
//
this.txt_textID.Location = new System.Drawing.Point(84, 62);
this.txt_textID.Name = "txt_textID";
this.txt_textID.Size = new System.Drawing.Size(75, 21);
this.txt_textID.TabIndex = 9;
this.txt_textID.Text = "";
//
// txt_avg
//
this.txt_avg.Location = new System.Drawing.Point(84, 106);
this.txt_avg.Name = "txt_avg";
this.txt_avg.Size = new System.Drawing.Size(75, 21);
this.txt_avg.TabIndex = 10;
this.txt_avg.Text = "";
this.txt_avg.TextChanged += new System.EventHandler(this.txt_avg_TextChanged);
//
// label5
//
this.label5.Location = new System.Drawing.Point(12, 112);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(60, 18);
this.label5.TabIndex = 11;
this.label5.Text = "平均成绩:";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.groupBox3);
this.groupBox1.Controls.Add(this.btn_research);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(18, 236);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(366, 162);
this.groupBox1.TabIndex = 12;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "查询条件";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.txt_Cou_Scor);
this.groupBox2.Controls.Add(this.txt_Xh);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Location = new System.Drawing.Point(6, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(168, 94);
this.groupBox2.TabIndex = 13;
this.groupBox2.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.txt_avg);
this.groupBox3.Controls.Add(this.label4);
this.groupBox3.Controls.Add(this.txt_textID);
this.groupBox3.Controls.Add(this.radioButton2);
this.groupBox3.Controls.Add(this.radioButton1);
this.groupBox3.Location = new System.Drawing.Point(186, 0);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(174, 149);
this.groupBox3.TabIndex = 13;
this.groupBox3.TabStop = false;
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(102, 25);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(66, 19);
this.radioButton2.TabIndex = 9;
this.radioButton2.Text = "平均查询";
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(12, 25);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(66, 19);
this.radioButton1.TabIndex = 8;
this.radioButton1.Text = "总分查询";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 124);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(66, 25);
this.button1.TabIndex = 12;
this.button1.Text = "退出";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Score_reserch
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(409, 405);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.dataGrid1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "Score_reserch";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "成绩查询";
this.Load += new System.EventHandler(this.Score_reserch_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void txt_avg_TextChanged(object sender, System.EventArgs e)
{
}
private void Score_reserch_Load(object sender, System.EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("select S.xh as 学号,S.xm as 姓名,S.QQhm as QQ号码, score.Scores as 分数,score.Test_Id as 课程编号 ,test.Test_name as 课程名称 from student as S inner join score on score.xh = S.xh inner join test on test.Test_Id = score.Test_Id order by S.xh","Integrated Security=SSPI;Initial Catalog=xxgcx;Data Source=.");
DataSet ds = new DataSet();
sda.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];
}
private void btn_research_Click(object sender, System.EventArgs e)
{
if(radioButton1.Checked == true) //查询总分
{
SqlConnection cn = new SqlConnection("Integrated Security=SSPI;Initial Catalog=xxgcx;Data Source=.");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand ();
cmd.Connection=cn;
cmd.CommandType=CommandType.StoredProcedure;
cmd.CommandText="CustOrderHist";
cmd.Parameters.Add("@aa",SqlDbType.Int, 100);
cmd.Parameters["@aa"].Value=this.txt_Xh.Text.Trim();
da.SelectCommand =cmd;
DataSet ds =new DataSet();
da.Fill(ds);
this.txt_Cou_Scor.Text = ds.Tables[0].Rows[0][0].ToString();
cn.Close();
}
if(radioButton2.Checked == true) //查询平均分
{
SqlConnection cn = new SqlConnection("Integrated Security=SSPI;Initial Catalog=xxgcx;Data Source=.");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand ();
cmd.Connection=cn;
cmd.CommandType=CommandType.StoredProcedure;
cmd.CommandText="kcpjf";
cmd.Parameters.Add("@bb",SqlDbType.Int, 100);
cmd.Parameters["@bb"].Value=this.txt_textID.Text.Trim();
da.SelectCommand =cmd;
DataSet ds =new DataSet();
da.Fill(ds);
this.txt_avg.Text = ds.Tables[0].Rows[0][0].ToString();
cn.Close();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
}
private void txt_Xh_TextChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -