?? fstudyclass.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace PK
{
/// <summary>
/// fStudyClass 的摘要說明。
/// </summary>
public class fStudyClass : System.Windows.Forms.UserControl
{
public event System.EventHandler SCallMessage;
public event System.EventHandler SCallMessageB;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private string studyClassNo;
public string getStudyClassNo
{
get
{
return studyClassNo;
}
}
/// <summary>
/// 必需的設(shè)計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public fStudyClass()
{
// 該調(diào)用是 Windows.Forms 窗體設(shè)計器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 調(diào)用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 組件設(shè)計器生成的代碼
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 23);
this.label1.TabIndex = 0;
this.label1.Text = "班級課表查詢";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(16, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(144, 220);
this.listBox1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 312);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "查詢";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(48, 368);
this.button2.Name = "button2";
this.button2.TabIndex = 3;
this.button2.Text = "返回";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// fStudyClass
//
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label1);
this.Name = "fStudyClass";
this.Size = new System.Drawing.Size(200, 416);
this.Load += new System.EventHandler(this.fStudyClass_Load);
this.ResumeLayout(false);
}
#endregion
private void label1_Click(object sender, System.EventArgs e)
{
}
private void fStudyClass_Load(object sender, System.EventArgs e)
{
Connection c = new Connection();
SqlConnection conn = new SqlConnection(c.getConnectionString);
conn.Open();
string str = "";
string strsql = "select distinct StudyClassNo from course";
SqlCommand cmd = new SqlCommand(strsql,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
str = Convert.ToString(dr["studyClassNo"]);
this.listBox1.Items.Add(str);
}
dr.Close();
conn.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{
string str = "";
try
{
str = this.listBox1.SelectedItem.ToString();
this.studyClassNo = str;
if (SCallMessageB != null)
SCallMessageB(sender,e);
//MessageBox.Show(str);
}
catch
{
MessageBox.Show("請選擇班級!");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
if (SCallMessage != null)
SCallMessage(sender,e);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -