📄 seleclass.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 学生与成绩
{
/// <summary>
/// SeleClass 的摘要说明。
/// </summary>
public class SeleClass : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox lstClassID;
private System.Windows.Forms.ListBox lstClassName;
private System.Data.SqlClient.SqlDataAdapter da1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private 学生与成绩.DataSet2 dataSet21;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public SeleClass()
{
//
// 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.lstClassID = new System.Windows.Forms.ListBox();
this.lstClassName = new System.Windows.Forms.ListBox();
this.da1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.dataSet21 = new 学生与成绩.DataSet2();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
this.SuspendLayout();
//
// lstClassID
//
this.lstClassID.DataSource = this.dataSet21;
this.lstClassID.DisplayMember = "班级.班级编号";
this.lstClassID.ItemHeight = 12;
this.lstClassID.Location = new System.Drawing.Point(44, 16);
this.lstClassID.Name = "lstClassID";
this.lstClassID.Size = new System.Drawing.Size(120, 124);
this.lstClassID.TabIndex = 0;
this.lstClassID.SelectedIndexChanged += new System.EventHandler(this.lstClassID_SelectedIndexChanged);
//
// lstClassName
//
this.lstClassName.DataSource = this.dataSet21;
this.lstClassName.DisplayMember = "班级.班级名称";
this.lstClassName.ItemHeight = 12;
this.lstClassName.Location = new System.Drawing.Point(228, 16);
this.lstClassName.Name = "lstClassName";
this.lstClassName.Size = new System.Drawing.Size(120, 124);
this.lstClassName.TabIndex = 1;
this.lstClassName.SelectedIndexChanged += new System.EventHandler(this.lstClassName_SelectedIndexChanged);
//
// da1
//
this.da1.SelectCommand = this.sqlSelectCommand1;
this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "班级", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("班级编号", "班级编号"),
new System.Data.Common.DataColumnMapping("班级名称", "班级名称")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 班级编号, 班级名称 FROM 班级";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source=ys" +
"js44;persist security info=False;initial catalog=stu01";
//
// dataSet21
//
this.dataSet21.DataSetName = "DataSet2";
this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// SeleClass
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(392, 166);
this.Controls.Add(this.lstClassName);
this.Controls.Add(this.lstClassID);
this.Name = "SeleClass";
this.Text = "选择班级";
this.Load += new System.EventHandler(this.SeleClass_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void SeleClass_Load(object sender, System.EventArgs e)
{
da1.Fill(dataSet21,"班级");
}
private void lstClassID_SelectedIndexChanged(object sender, System.EventArgs e)
{
AddUsers.Class=this.lstClassID.Text;
this.Close();
}
private void lstClassName_SelectedIndexChanged(object sender, System.EventArgs e)
{
AddUsers.Class=this.lstClassName.Text;
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -