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

📄 locksystemui.cs

📁 一个基本的酒店管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace UI
{
	/// <summary>
	/// LockSystemUI 的摘要说明。
	/// </summary>
	public class LockSystemUI : System.Windows.Forms.Form
	{
		private string LockPass="";
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.TextBox textPass1;
		private System.Windows.Forms.TextBox textPass2;
		private System.Windows.Forms.Label labpass1;
		private System.Windows.Forms.Label labpass2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public LockSystemUI()
		{
			//
			// 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.button1 = new System.Windows.Forms.Button();
			this.labpass1 = new System.Windows.Forms.Label();
			this.textPass1 = new System.Windows.Forms.TextBox();
			this.textPass2 = new System.Windows.Forms.TextBox();
			this.labpass2 = new System.Windows.Forms.Label();
			this.button2 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.button1.Location = new System.Drawing.Point(20, 88);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(96, 32);
			this.button1.TabIndex = 0;
			this.button1.Text = "锁定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// labpass1
			// 
			this.labpass1.AutoSize = true;
			this.labpass1.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.labpass1.Location = new System.Drawing.Point(20, 12);
			this.labpass1.Name = "labpass1";
			this.labpass1.Size = new System.Drawing.Size(98, 24);
			this.labpass1.TabIndex = 1;
			this.labpass1.Text = "锁   定   码:";
			this.labpass1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// textPass1
			// 
			this.textPass1.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textPass1.Location = new System.Drawing.Point(128, 12);
			this.textPass1.Name = "textPass1";
			this.textPass1.PasswordChar = '*';
			this.textPass1.Size = new System.Drawing.Size(128, 23);
			this.textPass1.TabIndex = 2;
			this.textPass1.Text = "";
			// 
			// textPass2
			// 
			this.textPass2.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textPass2.Location = new System.Drawing.Point(128, 52);
			this.textPass2.Name = "textPass2";
			this.textPass2.PasswordChar = '*';
			this.textPass2.Size = new System.Drawing.Size(128, 23);
			this.textPass2.TabIndex = 3;
			this.textPass2.Text = "";
			// 
			// labpass2
			// 
			this.labpass2.AutoSize = true;
			this.labpass2.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.labpass2.Location = new System.Drawing.Point(20, 52);
			this.labpass2.Name = "labpass2";
			this.labpass2.Size = new System.Drawing.Size(106, 24);
			this.labpass2.TabIndex = 1;
			this.labpass2.Text = "确认锁定码:";
			this.labpass2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// button2
			// 
			this.button2.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.button2.Location = new System.Drawing.Point(156, 88);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(96, 32);
			this.button2.TabIndex = 0;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// LockSystemUI
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(284, 137);
			this.ControlBox = false;
			this.Controls.Add(this.textPass1);
			this.Controls.Add(this.textPass2);
			this.Controls.Add(this.labpass2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.labpass1);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "LockSystemUI";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "锁定系统";
			this.Click += new System.EventHandler(this.LockSystemUI_Click);
			this.SizeChanged += new System.EventHandler(this.LockSystemUI_SizeChanged);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(this.button1.Text=="锁定")
			{
				string pass1=this.textPass1.Text.Trim();
				string pass2=this.textPass2.Text.Trim();
				if(pass1.Length<4)
				{
					MessageBox.Show("锁定码不能小于4位");
					return;
				}
				if(pass1==pass2)
				{
					this.WindowState=FormWindowState.Maximized;
					this.LockPass=pass1;
					this.button1.Text="解锁";
					this.textPass1.Text="";
					this.textPass2.Text="";
					this.Text="系统已被锁定";
					this.textPass2.Enabled=false;
					this.button2.Enabled=false;
					MessageBox.Show("系统已成功锁定!");
				}
				else
				{
					MessageBox.Show("锁定码和确认锁定码不相同!");
				}
			}
			else
			{
				string pass1=this.textPass1.Text.Trim();
				if(pass1==this.LockPass)
				{
					this.button1.Text="锁定";
					this.textPass1.Text="";
					this.textPass2.Enabled=true;
					this.button2.Enabled=true;
					MessageBox.Show("解锁成功!");
					this.Close();
				}
				else
				{
					MessageBox.Show("解锁码错误!");
				}
			}

		}

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

		private void LockSystemUI_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show("系统锁定中,请输入解锁码!");
		}

		private void LockSystemUI_SizeChanged(object sender, System.EventArgs e)
		{
			this.WindowState=FormWindowState.Maximized;
		}
	}
}

⌨️ 快捷键说明

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