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

📄 mainform.cs

📁 本设备管理系统采用了三层结构的设计思想
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
using System.Data;

namespace HotelManage
{
	/// <summary>
	/// Form1 的摘要说明。
	/// writer 汪孝宜
	/// qq 183974033
	/// MSN wxy81088hotmail.com
	/// mail wxy8108@sina.com
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuItem10;
		private System.Windows.Forms.MenuItem menuItem11;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.MenuItem menuItem12;
		private System.Windows.Forms.ToolBar toolBar2;
		private System.Windows.Forms.ToolBarButton type;
		private System.Windows.Forms.ToolBarButton describe;
		private System.Windows.Forms.ToolBarButton query;
		private System.Windows.Forms.ToolBarButton order;
		private System.Windows.Forms.ToolBarButton checkin;
		private System.Windows.Forms.ToolBarButton quit;
		private System.ComponentModel.IContainer components;

		public MainForm()
		{
			//
			// 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.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem12 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem10 = new System.Windows.Forms.MenuItem();
			this.menuItem11 = new System.Windows.Forms.MenuItem();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.toolBar2 = new System.Windows.Forms.ToolBar();
			this.type = new System.Windows.Forms.ToolBarButton();
			this.describe = new System.Windows.Forms.ToolBarButton();
			this.query = new System.Windows.Forms.ToolBarButton();
			this.order = new System.Windows.Forms.ToolBarButton();
			this.checkin = new System.Windows.Forms.ToolBarButton();
			this.quit = new System.Windows.Forms.ToolBarButton();
			this.SuspendLayout();
			// 
			// splitter1
			// 
			this.splitter1.BackColor = System.Drawing.SystemColors.Desktop;
			this.splitter1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
			this.splitter1.Location = new System.Drawing.Point(0, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(644, 3);
			this.splitter1.TabIndex = 1;
			this.splitter1.TabStop = false;
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem4,
																					  this.menuItem7});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem12,
																					  this.menuItem3});
			this.menuItem1.Text = "系统管理(&M)";
			// 
			// menuItem12
			// 
			this.menuItem12.Index = 0;
			this.menuItem12.Text = "系统帮助(&H)";
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "退出系统(&E)";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem5,
																					  this.menuItem6});
			this.menuItem4.Text = "数据维护(&D)";
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 0;
			this.menuItem5.Text = "客房类型(&T)";
			this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 1;
			this.menuItem6.Text = "客房信息(&R)";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 2;
			this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem8,
																					  this.menuItem9,
																					  this.menuItem10,
																					  this.menuItem11});
			this.menuItem7.Text = "前台操作(&H)";
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 0;
			this.menuItem8.Text = "客房查询(&S)";
			this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 1;
			this.menuItem9.Text = "客户查询(&P)";
			this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
			// 
			// menuItem10
			// 
			this.menuItem10.Index = 2;
			this.menuItem10.Text = "客户入住(&B)";
			this.menuItem10.Click += new System.EventHandler(this.menuItem8_Click);
			// 
			// menuItem11
			// 
			this.menuItem11.Index = 3;
			this.menuItem11.Text = "客户结算(&C)";
			this.menuItem11.Click += new System.EventHandler(this.menuItem9_Click);
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// toolBar2
			// 
			this.toolBar2.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.type,
																						this.describe,
																						this.query,
																						this.order,
																						this.checkin,
																						this.quit});
			this.toolBar2.DropDownArrows = true;
			this.toolBar2.ImageList = this.imageList1;
			this.toolBar2.Location = new System.Drawing.Point(0, 3);
			this.toolBar2.Name = "toolBar2";
			this.toolBar2.ShowToolTips = true;
			this.toolBar2.Size = new System.Drawing.Size(644, 28);
			this.toolBar2.TabIndex = 5;
			this.toolBar2.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			this.toolBar2.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar2_ButtonClick);
			// 
			// type
			// 
			this.type.ImageIndex = 0;
			this.type.Text = "客房类型";
			this.type.ToolTipText = "客房类型";
			// 
			// describe
			// 
			this.describe.ImageIndex = 1;
			this.describe.Text = "客房信息";
			this.describe.ToolTipText = "客房信息";
			// 
			// query
			// 
			this.query.ImageIndex = 2;
			this.query.Text = "客房查询";
			this.query.ToolTipText = "客房查询";
			// 
			// order
			// 
			this.order.ImageIndex = 3;
			this.order.Text = "入住";
			this.order.ToolTipText = "入住";
			// 
			// checkin
			// 
			this.checkin.ImageIndex = 5;
			this.checkin.Text = "退房";
			this.checkin.ToolTipText = "退房";
			// 
			// quit
			// 
			this.quit.ImageIndex = 7;
			this.quit.Text = "退出";
			this.quit.ToolTipText = "退出";
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Desktop;
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(644, 525);
			this.Controls.Add(this.toolBar2);
			this.Controls.Add(this.splitter1);
			this.ForeColor = System.Drawing.SystemColors.Desktop;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.IsMdiContainer = true;
			this.Menu = this.mainMenu1;
			this.Name = "MainForm";
			this.Text = "主窗体";
			this.Load += new System.EventHandler(this.MainForm_Load);
			this.ResumeLayout(false);

		}
		#endregion
		static void Main() 
		{
			Thread thread = Thread.CurrentThread;
			thread.ApartmentState = ApartmentState.STA;
			Application.Run(new MainForm());
		}	

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]			

		

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			Form RoomTypeForm=new RoomTypeForm();						
			for(int x=0;x<this.MdiChildren.Length;x++)
			{
				Form tempChild = (Form)this.MdiChildren[x];
				tempChild.Close();
			}
			RoomTypeForm.MdiParent = this;//setup MdiParent for expertMaintenance form
			RoomTypeForm.WindowState = FormWindowState.Maximized;          			
			RoomTypeForm.Show();		
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			Form RoomForm=new RoomManageForm();						
			for(int x=0;x<this.MdiChildren.Length;x++)
			{
				Form tempChild = (Form)this.MdiChildren[x];
				tempChild.Close();
			}
			RoomForm.MdiParent = this;//setup MdiParent for expertMaintenance form
			RoomForm.WindowState = FormWindowState.Maximized;          			
			RoomForm.Show();				
		}		

		private void menuItem8_Click(object sender, System.EventArgs e)
		{
			Form RoomOrder=new RoomFindForm();						
			for(int x=0;x<this.MdiChildren.Length;x++)
			{
				Form tempChild = (Form)this.MdiChildren[x];
				tempChild.Close();
			}
			RoomOrder.MdiParent = this;//setup MdiParent for expertMaintenance form
			RoomOrder.WindowState = FormWindowState.Maximized;          			
			RoomOrder.Show();				
			
		}

		private void menuItem9_Click(object sender, System.EventArgs e)
		{
			Form GuesterFindForm=new GuesterFindForm();						
			for(int x=0;x<this.MdiChildren.Length;x++)
			{
				Form tempChild = (Form)this.MdiChildren[x];
				tempChild.Close();
			}
			GuesterFindForm.MdiParent = this;//setup MdiParent for expertMaintenance form
			GuesterFindForm.WindowState = FormWindowState.Maximized;          			
			GuesterFindForm.Show();	
		
		}

		private void MainForm_Load(object sender, System.EventArgs e)
		{
			//Form RoomOrder=new InitialForm();			
			//RoomOrder.MdiParent = this;//setup MdiParent for expertMaintenance form
			//RoomOrder.WindowState = FormWindowState.Maximized;          			
			//RoomOrder.Show();				
		
		}

		private void toolBar2_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(toolBar2.Buttons.IndexOf(e.Button))
			{//根据单击ToolBar上的Button的索引不同而触发不同的事件
				case 0:
					Form RoomTypeForm=new RoomTypeForm();
					//创建RoomType的实例	
					for(int x=0;x<this.MdiChildren.Length;x++)
					{
						Form tempChild = (Form)this.MdiChildren[x];
						tempChild.Close();
					}
					//关闭主窗体的其他子窗体
					RoomTypeForm.MdiParent = this;
					//设置主窗体为父窗体
					RoomTypeForm.WindowState = FormWindowState.Maximized;
					//最大化子窗体
					RoomTypeForm.Show();		
					break; //跳出Switch
				case 1:
					Form RoomManageForm=new RoomManageForm();						
					for(int x=0;x<this.MdiChildren.Length;x++)
					{
						Form tempChild = (Form)this.MdiChildren[x];
						tempChild.Close();
					}
					RoomManageForm.MdiParent = this;//setup MdiParent for expertMaintenance form
					RoomManageForm.WindowState = FormWindowState.Maximized;          			
					RoomManageForm.Show();		
					break; 								
				case 2:
					Form RoomFindForm=new RoomFindForm();						
					for(int x=0;x<this.MdiChildren.Length;x++)
					{
						Form tempChild = (Form)this.MdiChildren[x];
						tempChild.Close();
					}
					RoomFindForm.MdiParent = this;//setup MdiParent for expertMaintenance form
					RoomFindForm.WindowState = FormWindowState.Maximized;          			
					RoomFindForm.Show();				
					break;					 
				
				case 3:
					Form RoomOrder=new RoomFindForm();						
					for(int x=0;x<this.MdiChildren.Length;x++)
					{
						Form tempChild = (Form)this.MdiChildren[x];
						tempChild.Close();
					}
					RoomOrder.MdiParent = this;//setup MdiParent for expertMaintenance form
					RoomOrder.WindowState = FormWindowState.Maximized;          			
					RoomOrder.Show();		

					break; 				
				case 4:	
					Form GuesterFindForm=new GuesterFindForm();						
					for(int x=0;x<this.MdiChildren.Length;x++)
					{
						Form tempChild = (Form)this.MdiChildren[x];
						tempChild.Close();
					}
					GuesterFindForm.MdiParent = this;//setup MdiParent for expertMaintenance form
					GuesterFindForm.WindowState = FormWindowState.Maximized;          			
					GuesterFindForm.Show();	
					break;
				case 5:
					Application.Exit();
					break;
			}
		}
	}
}

⌨️ 快捷键说明

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