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

📄 frmmain.cs

📁 简单的学生成绩管理系统。实现学生成绩学号管理
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace 教务管理系统
{
	/// <summary>
	/// frmMain 的摘要说明。
	/// </summary>
	public class frmMain : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.MenuItem mnExit;
		internal System.Windows.Forms.MenuItem mnReport;
		internal System.Windows.Forms.MenuItem mnPrint;
		internal System.Windows.Forms.MenuItem mnTeach;
		internal System.Windows.Forms.MenuItem mnSelect;
		internal System.Windows.Forms.MenuItem mnCourse;
		internal System.Windows.Forms.MenuItem mnResult;
		internal System.Windows.Forms.MenuItem mnBasic;
		internal System.Windows.Forms.MenuItem mnClass;
		internal System.Windows.Forms.MenuItem mnStudent;
		internal System.Windows.Forms.MenuItem mnSubject;
		internal System.Windows.Forms.MainMenu MainMenu1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

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

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}


		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());
		}

		/// <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.mnExit = new System.Windows.Forms.MenuItem();
			this.mnReport = new System.Windows.Forms.MenuItem();
			this.mnPrint = new System.Windows.Forms.MenuItem();
			this.mnTeach = new System.Windows.Forms.MenuItem();
			this.mnSelect = new System.Windows.Forms.MenuItem();
			this.mnCourse = new System.Windows.Forms.MenuItem();
			this.mnResult = new System.Windows.Forms.MenuItem();
			this.mnBasic = new System.Windows.Forms.MenuItem();
			this.mnClass = new System.Windows.Forms.MenuItem();
			this.mnStudent = new System.Windows.Forms.MenuItem();
			this.mnSubject = new System.Windows.Forms.MenuItem();
			this.MainMenu1 = new System.Windows.Forms.MainMenu();
			// 
			// mnExit
			// 
			this.mnExit.Index = 3;
			this.mnExit.Text = "退出系统(&Z)";
			this.mnExit.Click += new System.EventHandler(this.mnExit_Click);
			// 
			// mnReport
			// 
			this.mnReport.Index = 0;
			this.mnReport.Text = "打印成绩单(&Z)";
			this.mnReport.Click += new System.EventHandler(this.mnReport_Click);
			// 
			// mnPrint
			// 
			this.mnPrint.Index = 2;
			this.mnPrint.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnReport});
			this.mnPrint.Text = "报表统计(&Y)";
			// 
			// mnTeach
			// 
			this.mnTeach.Index = 1;
			this.mnTeach.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnSelect,
																					this.mnCourse,
																					this.mnResult});
			this.mnTeach.Text = "教学管理(&X)";
			// 
			// mnSelect
			// 
			this.mnSelect.Index = 0;
			this.mnSelect.Text = "学生选课(&X)";
			this.mnSelect.Click += new System.EventHandler(this.mnSelect_Click);
			// 
			// mnCourse
			// 
			this.mnCourse.Index = 1;
			this.mnCourse.Text = "课表查询(&Y)";
			this.mnCourse.Click += new System.EventHandler(this.mnCourse_Click);
			// 
			// mnResult
			// 
			this.mnResult.Index = 2;
			this.mnResult.Text = "成绩输入(&Z)";
			this.mnResult.Click += new System.EventHandler(this.mnResult_Click);
			// 
			// mnBasic
			// 
			this.mnBasic.Index = 0;
			this.mnBasic.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnClass,
																					this.mnStudent,
																					this.mnSubject});
			this.mnBasic.Text = "基础维护(&W)";
			// 
			// mnClass
			// 
			this.mnClass.Index = 0;
			this.mnClass.Text = "班级信息维护(&X)";
			this.mnClass.Click += new System.EventHandler(this.mnClass_Click);
			// 
			// mnStudent
			// 
			this.mnStudent.Index = 1;
			this.mnStudent.Text = "学生信息维护(&Y)";
			this.mnStudent.Click += new System.EventHandler(this.mnStudent_Click);
			// 
			// mnSubject
			// 
			this.mnSubject.Index = 2;
			this.mnSubject.Text = "课程信息维护(&Z)";
			this.mnSubject.Click += new System.EventHandler(this.mnSubject_Click);
			// 
			// MainMenu1
			// 
			this.MainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.mnBasic,
																					  this.mnTeach,
																					  this.mnPrint,
																					  this.mnExit});
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(400, 290);
			this.IsMdiContainer = true;
			this.Menu = this.MainMenu1;
			this.Name = "frmMain";
			this.Text = "学生信息管理系统";
			this.Load += new System.EventHandler(this.frmMain_Load);

		}
		#endregion

		private bool GetInstanceState( string name )
		{
			// 获得frmMain窗体的子窗体的数量
			int i = this.MdiChildren.Length;
			// 循环判断是否有名为name的子窗体实例
			for ( i = 0; i <= MdiChildren.Length; i ++ )
			{
				if ( MdiChildren[ i ].Name == name )
				{
					// 存在名为name的子窗体,是子窗体获得焦点并返回true
					MdiChildren[ i ].Focus();
					return true;
				}
			}
			// 不存在名为Name的子窗体false
			return false;
		}

		private void frmMain_Load(object sender, System.EventArgs e)
		{
		
		}

		private void mnClass_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmClass" ) )
				return;
			frmClass childFrm = new frmClass();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnStudent_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmStudent" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmStudent childFrm = new frmStudent();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnSubject_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmSubject" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmSubject childFrm = new frmSubject();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnSelect_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmSelect" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmSelect childFrm = new frmSelect();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnCourse_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmCourse" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmCourse childFrm = new frmCourse();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnResult_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmResult" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmScore childFrm = new frmScore();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnReport_Click(object sender, System.EventArgs e)
		{
			if ( GetInstanceState( "frmReport" ) )
				return;
			// frmClass childFrm = new frmClass();
			frmReport childFrm = new frmReport();
			childFrm.MdiParent = this;
			childFrm.Show();
		}

		private void mnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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