📄 frmmain.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 酒店管理系统
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
internal System.Windows.Forms.MainMenu MainMenu1;
internal System.Windows.Forms.MenuItem mnBasic;
internal System.Windows.Forms.MenuItem mnRoomType;
internal System.Windows.Forms.MenuItem mnRoomInfo;
internal System.Windows.Forms.MenuItem mnManage;
internal System.Windows.Forms.MenuItem mnReserve;
internal System.Windows.Forms.MenuItem mnReside;
internal System.Windows.Forms.MenuItem mnConsume;
internal System.Windows.Forms.MenuItem mnCash;
internal System.Windows.Forms.MenuItem mnRoomState;
internal System.Windows.Forms.MenuItem mnExit;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <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.MainMenu1 = new System.Windows.Forms.MainMenu();
this.mnBasic = new System.Windows.Forms.MenuItem();
this.mnRoomType = new System.Windows.Forms.MenuItem();
this.mnRoomInfo = new System.Windows.Forms.MenuItem();
this.mnManage = new System.Windows.Forms.MenuItem();
this.mnReserve = new System.Windows.Forms.MenuItem();
this.mnReside = new System.Windows.Forms.MenuItem();
this.mnConsume = new System.Windows.Forms.MenuItem();
this.mnCash = new System.Windows.Forms.MenuItem();
this.mnRoomState = new System.Windows.Forms.MenuItem();
this.mnExit = new System.Windows.Forms.MenuItem();
//
// MainMenu1
//
this.MainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnBasic,
this.mnManage,
this.mnRoomState,
this.mnExit});
//
// mnBasic
//
this.mnBasic.Index = 0;
this.mnBasic.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnRoomType,
this.mnRoomInfo});
this.mnBasic.Text = "基础设置(&W)";
//
// mnRoomType
//
this.mnRoomType.Index = 0;
this.mnRoomType.Text = "客房类型设置(&Y)";
this.mnRoomType.Click += new System.EventHandler(this.mnRoomType_Click);
//
// mnRoomInfo
//
this.mnRoomInfo.Index = 1;
this.mnRoomInfo.Text = "客房信息设置(&Z)";
this.mnRoomInfo.Click += new System.EventHandler(this.mnRoomInfo_Click);
//
// mnManage
//
this.mnManage.Index = 1;
this.mnManage.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnReserve,
this.mnReside,
this.mnConsume,
this.mnCash});
this.mnManage.Text = "业务管理(&X)";
//
// mnReserve
//
this.mnReserve.Index = 0;
this.mnReserve.Text = "预订管理(&W)";
this.mnReserve.Click += new System.EventHandler(this.mnReserve_Click);
//
// mnReside
//
this.mnReside.Index = 1;
this.mnReside.Text = "入住管理(&X)";
this.mnReside.Click += new System.EventHandler(this.mnReside_Click);
//
// mnConsume
//
this.mnConsume.Index = 2;
this.mnConsume.Text = "消费记帐(&Y)";
this.mnConsume.Click += new System.EventHandler(this.mnConsume_Click);
//
// mnCash
//
this.mnCash.Index = 3;
this.mnCash.Text = "收银退房(&Z)";
this.mnCash.Click += new System.EventHandler(this.mnCash_Click);
//
// mnRoomState
//
this.mnRoomState.Index = 2;
this.mnRoomState.Text = "房态管理(&Y)";
this.mnRoomState.Click += new System.EventHandler(this.mnRoomState_Click);
//
// mnExit
//
this.mnExit.Index = 3;
this.mnExit.Text = "退出系统(&Z)";
this.mnExit.Click += new System.EventHandler(this.mnExit_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(384, 233);
this.IsMdiContainer = true;
this.Menu = this.MainMenu1;
this.Name = "Form1";
this.Text = "酒店管理系统";
}
#endregion
private bool GetInstanceState( string name )
{
// 获得frmMain窗体的子窗体的数量
int i = this.MdiChildren.Length;
// 循环判断是否有名为name的子窗体实例
for ( i = 0; i < this.MdiChildren.Length; i ++ )
{
// 存在名为name的子窗体,是子窗体获得焦点并返回true
this.MdiChildren[ i ].Focus();
return true;
}
// 不存在名为Name的子窗体false
return false;
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void mnRoomType_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmRoomType" ) )
return;
frmRoomType childFrm = new frmRoomType();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnRoomInfo_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmRoomInfo" ) )
return;
frmRoomInfo childFrm = new frmRoomInfo();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnReserve_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmReserve" ) )
return;
frmReserve childFrm = new frmReserve();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnReside_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmReside" ) )
return;
frmReside childFrm = new frmReside();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnConsume_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmConsume" ) )
return;
frmConsume childFrm = new frmConsume();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnCash_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "" ) )
return;
frmCash childFrm = new frmCash();
childFrm.MdiParent = this;
childFrm.Show();
}
private void mnRoomState_Click(object sender, System.EventArgs e)
{
if ( GetInstanceState( "frmRoomState" ) )
return;
frmRoomState childFrm = new frmRoomState();
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 + -