📄 mainfrm.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 学生管理系统
{
public partial class MainFrm : Form
{
private MenuStrip menuStrip1;
private ToolStripMenuItem ToolStripMenuItem1;
private ToolStripMenuItem ToolStripMenuItem2;
private ToolStripMenuItem ToolStripMenuItem3;
private ToolStripMenuItem 选课情况ToolStripMenuItem;
private ToolStripMenuItem 成绩录入ToolStripMenuItem;
private ToolStripMenuItem 学生列表ToolStripMenuItem;
private ToolStripMenuItem 退出系统ToolStripMenuItem;
private ToolStripMenuItem 学生信息ToolStripMenuItem;
private ToolStripMenuItem 用户管理ToolStripMenuItem;
private ToolStripMenuItem 学院班级设置ToolStripMenuItem;
private ToolStripMenuItem 修改密码ToolStripMenuItem;
private IContainer components;
public MainFrm()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.选课情况ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.学生信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.成绩录入ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.学生列表ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.修改密码ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.用户管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.学院班级设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退出系统ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem1,
this.ToolStripMenuItem2,
this.ToolStripMenuItem3,
this.退出系统ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(622, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// ToolStripMenuItem1
//
this.ToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.选课情况ToolStripMenuItem,
this.学生信息ToolStripMenuItem});
this.ToolStripMenuItem1.Name = "ToolStripMenuItem1";
this.ToolStripMenuItem1.Size = new System.Drawing.Size(65, 20);
this.ToolStripMenuItem1.Text = "学生用户";
//
// 选课情况ToolStripMenuItem
//
this.选课情况ToolStripMenuItem.Name = "选课情况ToolStripMenuItem";
this.选课情况ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.选课情况ToolStripMenuItem.Text = "选课情况";
this.选课情况ToolStripMenuItem.Click += new System.EventHandler(this.选课情况ToolStripMenuItem_Click);
//
// 学生信息ToolStripMenuItem
//
this.学生信息ToolStripMenuItem.Name = "学生信息ToolStripMenuItem";
this.学生信息ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.学生信息ToolStripMenuItem.Text = "学生信息";
this.学生信息ToolStripMenuItem.Click += new System.EventHandler(this.学生信息ToolStripMenuItem_Click);
//
// ToolStripMenuItem2
//
this.ToolStripMenuItem2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.成绩录入ToolStripMenuItem,
this.学生列表ToolStripMenuItem,
this.修改密码ToolStripMenuItem});
this.ToolStripMenuItem2.Name = "ToolStripMenuItem2";
this.ToolStripMenuItem2.Size = new System.Drawing.Size(65, 20);
this.ToolStripMenuItem2.Text = "教师用户";
//
// 成绩录入ToolStripMenuItem
//
this.成绩录入ToolStripMenuItem.Name = "成绩录入ToolStripMenuItem";
this.成绩录入ToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.成绩录入ToolStripMenuItem.Text = "成绩录入(未实现)";
//
// 学生列表ToolStripMenuItem
//
this.学生列表ToolStripMenuItem.Name = "学生列表ToolStripMenuItem";
this.学生列表ToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.学生列表ToolStripMenuItem.Text = "学生列表";
this.学生列表ToolStripMenuItem.Click += new System.EventHandler(this.学生列表ToolStripMenuItem_Click);
//
// 修改密码ToolStripMenuItem
//
this.修改密码ToolStripMenuItem.Name = "修改密码ToolStripMenuItem";
this.修改密码ToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.修改密码ToolStripMenuItem.Text = "修改密码";
this.修改密码ToolStripMenuItem.Click += new System.EventHandler(this.修改密码ToolStripMenuItem_Click);
//
// ToolStripMenuItem3
//
this.ToolStripMenuItem3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.用户管理ToolStripMenuItem,
this.学院班级设置ToolStripMenuItem});
this.ToolStripMenuItem3.Name = "ToolStripMenuItem3";
this.ToolStripMenuItem3.Size = new System.Drawing.Size(65, 20);
this.ToolStripMenuItem3.Text = "系统用户";
//
// 用户管理ToolStripMenuItem
//
this.用户管理ToolStripMenuItem.Name = "用户管理ToolStripMenuItem";
this.用户管理ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.用户管理ToolStripMenuItem.Text = "用户管理";
this.用户管理ToolStripMenuItem.Click += new System.EventHandler(this.用户管理ToolStripMenuItem_Click);
//
// 学院班级设置ToolStripMenuItem
//
this.学院班级设置ToolStripMenuItem.Name = "学院班级设置ToolStripMenuItem";
this.学院班级设置ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.学院班级设置ToolStripMenuItem.Text = "班级设置";
this.学院班级设置ToolStripMenuItem.Click += new System.EventHandler(this.学院班级设置ToolStripMenuItem_Click);
//
// 退出系统ToolStripMenuItem
//
this.退出系统ToolStripMenuItem.Name = "退出系统ToolStripMenuItem";
this.退出系统ToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
this.退出系统ToolStripMenuItem.Text = "退出";
this.退出系统ToolStripMenuItem.Click += new System.EventHandler(this.退出系统ToolStripMenuItem_Click);
//
// MainFrm
//
this.ClientSize = new System.Drawing.Size(622, 488);
this.Controls.Add(this.menuStrip1);
this.IsMdiContainer = true;
this.Name = "MainFrm";
this.Load += new System.EventHandler(this.MainFrm_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
[STAThread]
static void Main()
{
//整个程序启动时先显示登录框,登录成功再显示主界面
LoginFrm login = new LoginFrm();
login.ShowDialog();
if (LoginFrm.blCanLogin == true)
{
Application.Run(new MainFrm());
}
}
private void MainFrm_Load(object sender, EventArgs e)
{
if (LoginFrm.user == "1")
{
this.ToolStripMenuItem1.Enabled = false;
this.ToolStripMenuItem2.Enabled = false;
}
else if (LoginFrm.user == "2")
{
this.ToolStripMenuItem3.Enabled = false;
this.ToolStripMenuItem1.Enabled = false;
}
else if (LoginFrm.user == "3")
{
this.ToolStripMenuItem3.Enabled = false;
this.ToolStripMenuItem2.Enabled = false;
}
}
//-----------------查询一个子窗体是否存在----------------
private bool checkChildFrmExist(string childFrmName)
{
foreach (Form childFrm in this.MdiChildren)
{
//用子窗体的Name进行判断,如果已经存在则将他激活
if (childFrm.Name == childFrmName)
{
if (childFrm.WindowState == FormWindowState.Minimized)
childFrm.WindowState = FormWindowState.Normal;
childFrm.Activate();
return true;
}
}
return false;
}
private void 退出系统ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确实要退出系统吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Close();
}
}
private void 选课情况ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.checkChildFrmExist("选课情况") == true)
{
return;
}
// 如果该窗体不存在则新生成一个商品信息维护窗体
选课情况 newFrm = new 选课情况();
newFrm.MdiParent = this;
newFrm.Show();
}
private void 学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.checkChildFrmExist("学生信息") == true)
{
return;
}
// 如果该窗体不存在则新生成一个商品信息维护窗体
学生信息 newFrm = new 学生信息();
newFrm.MdiParent = this;
newFrm.Show();
}
private void 学生列表ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.checkChildFrmExist("学生列表") == true)
{
return;
}
// 如果该窗体不存在则新生成一个商品信息维护窗体
学生列表 newFrm = new 学生列表();
newFrm.MdiParent = this;
newFrm.Show();
}
private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.checkChildFrmExist("用户管理") == true)
{
return;
}
// 如果该窗体不存在则新生成一个商品信息维护窗体
用户管理 newFrm = new 用户管理();
newFrm.MdiParent = this;
newFrm.Show();
}
private void 学院班级设置ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.checkChildFrmExist("班级设置") == true)
{
return;
}
// 如果该窗体不存在则新生成一个商品信息维护窗体
班级设置 newFrm = new 班级设置();
newFrm.MdiParent = this;
newFrm.Show();
}
private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
{
密码修改 newFrm = new 密码修改();
newFrm.Show();
}
//private void 成绩查询ToolStripMenuItem_Click(object sender, EventArgs e)
//{
// if (this.checkChildFrmExist("成绩查询") == true)
// {
// return;
// }
// // 如果该窗体不存在则新生成一个商品信息维护窗体
// WareDataManage newFrm = new WareDataManage(true);
// newFrm.MdiParent = this;
// newFrm.Show();
//}
//private void 成绩录入ToolStripMenuItem_Click(object sender, EventArgs e)
//{
// if (this.checkChildFrmExist("成绩录入") == true)
// {
// return;
// }
// // 如果该窗体不存在则新生成一个商品信息维护窗体
// WareDataManage newFrm = new WareDataManage(true);
// newFrm.MdiParent = this;
// newFrm.Show();
//}
//private void 学生列表ToolStripMenuItem_Click(object sender, EventArgs e)
//{
// if (this.checkChildFrmExist("学生列表") == true)
// {
// return;
// }
// // 如果该窗体不存在则新生成一个商品信息维护窗体
// WareDataManage newFrm = new WareDataManage(true);
// newFrm.MdiParent = this;
// newFrm.Show();
//}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -