📄 fstuecha.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 教师网上录入成绩
{
/// <summary>
/// Form4 的摘要说明。
/// </summary>
public class Form4 : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private 教师网上录入成绩.DataSet6 dataSet61;
private System.Windows.Forms.Button button1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form4()
{
//
// 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.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet61 = new 教师网上录入成绩.DataSet6();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet61)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox3);
this.groupBox1.Controls.Add(this.textBox2);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(24, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(584, 88);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "查询信息";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(448, 32);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 5;
this.textBox3.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(240, 32);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 4;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(80, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(96, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(360, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 16);
this.label3.TabIndex = 2;
this.label3.Text = "课程名称";
//
// label2
//
this.label2.Location = new System.Drawing.Point(184, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 1;
this.label2.Text = "课程编号";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 24);
this.label1.TabIndex = 0;
this.label1.Text = "学号";
//
// dataGrid1
//
this.dataGrid1.DataMember = "SeCour";
this.dataGrid1.DataSource = this.dataSet61;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 104);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(672, 152);
this.dataGrid1.TabIndex = 1;
//
// dataSet61
//
this.dataSet61.DataSetName = "DataSet6";
this.dataSet61.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", "SeCour", 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("开课系别", "开课系别"),
new System.Data.Common.DataColumnMapping("学时", "学时"),
new System.Data.Common.DataColumnMapping("学分", "学分")})});
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO SeCour(序号, 学号, 课程编号, 课程名称, 开课教师, 开课系别, 学时, 学分) VALUES (@序号, @学号, @课程编" +
"号, @课程名称, @开课教师, @开课系别, @学时, @学分); SELECT 序号, 学号, 课程编号, 课程名称, 开课教师, 开课系别, 学时, 学分" +
" FROM SeCour";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
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, 16, "学号"));
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, 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.Int, 4, "学时"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学分", System.Data.SqlDbType.Int, 4, "学分"));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=3366359E777E4EE;packet size=4096;integrated security=SSPI;data sou" +
"rce=3366359E777E4EE;persist security info=False;initial catalog=jiaoshi";
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 序号, 学号, 课程编号, 课程名称, 开课教师, 开课系别, 学时, 学分 FROM SeCour WHERE (学号 LIKE @a)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@a", System.Data.SqlDbType.VarChar, 16, "学号"));
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 288);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "查询";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form4
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(816, 485);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.groupBox1);
this.Name = "Form4";
this.Text = "学生查询选课情况";
this.Load += new System.EventHandler(this.Form4_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet61)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void dataGrid2_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
private void Form4_Load(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%%";
}
private void button1_Click(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%%";
if(this.textBox1.Text != "")
{
this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%" + this.textBox1.Text + "%";
}
this.sqlDataAdapter1.Fill(this.dataSet61);
}
private void button2_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -