📄 fclass.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>
/// fTeacher 的摘要说明。
/// </summary>
public class fClass : System.Windows.Forms.UserControl
{
public event System.EventHandler CallMessage;
public event System.EventHandler CallMessageJ;
public event System.EventHandler NoDisplayJ;
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 classNo;
public string getClassNo
{
get
{
return classNo;
}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public fClass()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </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(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(136, 23);
this.label1.TabIndex = 0;
this.label1.Text = "教室课表查询";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 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);
//
// fClass
//
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label1);
this.Name = "fClass";
this.Size = new System.Drawing.Size(200, 432);
this.Load += new System.EventHandler(this.fClass_Load);
this.ResumeLayout(false);
}
#endregion
private void fClass_Load(object sender, System.EventArgs e)
{
Connection c = new Connection();
SqlConnection conn = new SqlConnection(c.getConnectionString);
conn.Open();
string str = "";
string strsql = "select * from class";
SqlCommand cmd = new SqlCommand(strsql,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
str = Convert.ToString(dr["classNo"]);
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.classNo = str;
if (staticClass.isUsed(this.classNo))
{
if (CallMessageJ != null)
CallMessageJ(sender,e);
}
else
{
if (NoDisplayJ != null)
NoDisplayJ(sender,e);
MessageBox.Show("没安排此教室上课!");
}
//MessageBox.Show(str);
}
catch
{
MessageBox.Show("请选择教室!");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
if (CallMessage != null)
this.CallMessage(sender,e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -