⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmclassroominfo.cs

📁 学生类:Student 教师类:Teacher 主任:AdminTeacher 班主任:MasterTeacher 授课老师: PrelectTeacher 班级类:classTeam 班
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DataAccess;
using BusinessRule;

namespace Forms
{
	/// <summary>
	/// frmClassroomInfo 的摘要说明。
	/// </summary>
	public class frmClassroomInfo : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btnSelect;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.ComboBox cboClaID;
		private System.Windows.Forms.ComboBox cboClaRoomID;
		private System.Windows.Forms.DataGrid dbgClaRoomUserInfo;
		private System.Windows.Forms.RadioButton radClaID;
		private System.Windows.Forms.RadioButton radCrID;

		private DataTable myDt;

		private AdminTeacher Ateacher = null;
		private PrelectTeacher Pteacher = null;
		private MasterTeacher Mteacher = null;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmClassroomInfo()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			Post.EventSendLoginedID += new DataAccess.Post.SendMsgDelegate(Post_EventSendLoginedID);
		}

		/// <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.dbgClaRoomUserInfo = new System.Windows.Forms.DataGrid();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.radCrID = new System.Windows.Forms.RadioButton();
			this.radClaID = new System.Windows.Forms.RadioButton();
			this.cboClaRoomID = new System.Windows.Forms.ComboBox();
			this.cboClaID = new System.Windows.Forms.ComboBox();
			this.btnSelect = new System.Windows.Forms.Button();
			this.btnExit = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dbgClaRoomUserInfo)).BeginInit();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// dbgClaRoomUserInfo
			// 
			this.dbgClaRoomUserInfo.DataMember = "";
			this.dbgClaRoomUserInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dbgClaRoomUserInfo.Location = new System.Drawing.Point(0, 104);
			this.dbgClaRoomUserInfo.Name = "dbgClaRoomUserInfo";
			this.dbgClaRoomUserInfo.ReadOnly = true;
			this.dbgClaRoomUserInfo.Size = new System.Drawing.Size(472, 208);
			this.dbgClaRoomUserInfo.TabIndex = 0;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.radCrID);
			this.groupBox1.Controls.Add(this.radClaID);
			this.groupBox1.Controls.Add(this.cboClaRoomID);
			this.groupBox1.Controls.Add(this.cboClaID);
			this.groupBox1.Controls.Add(this.btnSelect);
			this.groupBox1.Controls.Add(this.btnExit);
			this.groupBox1.Location = new System.Drawing.Point(0, 0);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(472, 96);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			// 
			// radCrID
			// 
			this.radCrID.Location = new System.Drawing.Point(16, 56);
			this.radCrID.Name = "radCrID";
			this.radCrID.Size = new System.Drawing.Size(72, 24);
			this.radCrID.TabIndex = 8;
			this.radCrID.Text = "教室编号";
			this.radCrID.CheckedChanged += new System.EventHandler(this.radCrID_CheckedChanged);
			// 
			// radClaID
			// 
			this.radClaID.Checked = true;
			this.radClaID.Location = new System.Drawing.Point(16, 24);
			this.radClaID.Name = "radClaID";
			this.radClaID.Size = new System.Drawing.Size(72, 24);
			this.radClaID.TabIndex = 7;
			this.radClaID.TabStop = true;
			this.radClaID.Text = "班级编号";
			this.radClaID.CheckedChanged += new System.EventHandler(this.radClaID_CheckedChanged);
			// 
			// cboClaRoomID
			// 
			this.cboClaRoomID.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboClaRoomID.Enabled = false;
			this.cboClaRoomID.Location = new System.Drawing.Point(88, 56);
			this.cboClaRoomID.Name = "cboClaRoomID";
			this.cboClaRoomID.Size = new System.Drawing.Size(104, 20);
			this.cboClaRoomID.TabIndex = 4;
			// 
			// cboClaID
			// 
			this.cboClaID.Location = new System.Drawing.Point(88, 24);
			this.cboClaID.Name = "cboClaID";
			this.cboClaID.Size = new System.Drawing.Size(104, 20);
			this.cboClaID.TabIndex = 0;
			// 
			// btnSelect
			// 
			this.btnSelect.Location = new System.Drawing.Point(256, 32);
			this.btnSelect.Name = "btnSelect";
			this.btnSelect.Size = new System.Drawing.Size(75, 40);
			this.btnSelect.TabIndex = 6;
			this.btnSelect.Text = "查询(&S)";
			this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
			// 
			// btnExit
			// 
			this.btnExit.Location = new System.Drawing.Point(352, 32);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(72, 40);
			this.btnExit.TabIndex = 4;
			this.btnExit.Text = "退出(&E)";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// frmClassroomInfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(472, 333);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.dbgClaRoomUserInfo);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmClassroomInfo";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "教室使用信息浏览";
			this.Load += new System.EventHandler(this.frmClassroomInfo_Load);
			((System.ComponentModel.ISupportInitialize)(this.dbgClaRoomUserInfo)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		
		
		//获得实例化好的用户实例
		public Teacher User
		{
			get
			{
				if(Ateacher != null)
				{
					return Ateacher;
				}
				else if(Mteacher != null)
				{
					return Mteacher;
				}
				else
				{
					return Pteacher;
				}
			}
		}

		//订阅“邮递员”
		private void Post_EventSendLoginedID(object obj, object teacher, string formName)
		{
			if(teacher.GetType().ToString().Equals("BusinessRule.AdminTeacher"))
			{
				this.Ateacher = (AdminTeacher)teacher;
			}
			else if(teacher.GetType().ToString().Equals("BusinessRule.MasterTeacher"))
			{
				this.Mteacher = (MasterTeacher)teacher;
			}
			else
			{
				this.Pteacher = (PrelectTeacher)teacher;
			}
			Post.EventSendLoginedID -= new DataAccess.Post.SendMsgDelegate(Post_EventSendLoginedID);
		}

		//窗体加载事件
		private void frmClassroomInfo_Load(object sender, System.EventArgs e)
		{
			SqlDataReader myRd = this.User.GetAllClaID();
			cboClaID.Items.Add("所有上课信息");
			while(myRd.Read())
			{
				cboClaID.Items.Add(myRd.GetString(0));
			}
			cboClaID.SelectedIndex = 0;
			cboClaRoomID.Items.Add("所有教室");
			myRd = this.User.GetAllClaRoomID();
			while(myRd.Read())
			{
				cboClaRoomID.Items.Add(myRd.GetString(0));
			}
			cboClaRoomID.SelectedIndex = 0;
		}

		//查询按键
		private void btnSelect_Click(object sender, System.EventArgs e)
		{
			if(radClaID.Checked)
			{
				if(cboClaID.Text.Trim().Equals("所有上课信息"))
				{
					myDt = this.User.GetAllClassRoomUserInfo();
				}
				else
				{
					myDt = this.User.GetClassRoomUserByClaID(cboClaID.Text.Trim());
					if(myDt.Rows.Count == 0)
					{
						MessageBox.Show("抱歉,此班级不存在","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					}
				}
			}
			else
			{
				if(cboClaRoomID.SelectedIndex == 0)
				{
					myDt = this.User.GetAllClassRoomUserInfo();
				}
				else
				{
					myDt = this.User.GetClassRoomUserByCrID(cboClaRoomID.Text);
				}
			}
			dbgClaRoomUserInfo.DataSource = myDt;
			jimmy.CreateClassRoomUserInfoStyle(dbgClaRoomUserInfo,myDt.TableName);
		}

		//控制两个单选框
		private void radClaID_CheckedChanged(object sender, System.EventArgs e)
		{
			cboClaID.Enabled = true;
			cboClaRoomID.Enabled = false;
		}
		private void radCrID_CheckedChanged(object sender, System.EventArgs e)
		{
			cboClaID.Enabled = false;
			cboClaRoomID.Enabled = true;
		}

		//推出按键
		private void btnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -