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

📄 returnbackform.cs

📁 超市管理系统的完整版文档
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication1
{
	/// <summary>
	/// ReturnBackForm 的摘要说明。
	/// </summary>
	public class ReturnBackForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button m_OKButton;
		private System.Windows.Forms.Button m_CancelButton;
		
		private string password;
		private bool isCorrect;
		private System.Windows.Forms.TextBox m_PasswordText;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ReturnBackForm(string password)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.password=password;
			//
			// 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.label1 = new System.Windows.Forms.Label();
			this.m_PasswordText = new System.Windows.Forms.TextBox();
			this.m_OKButton = new System.Windows.Forms.Button();
			this.m_CancelButton = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Dock = System.Windows.Forms.DockStyle.Top;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(248, 23);
			this.label1.TabIndex = 0;
			this.label1.Text = "请在下面的输入框中输入您的密码:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// m_PasswordText
			// 
			this.m_PasswordText.Location = new System.Drawing.Point(40, 32);
			this.m_PasswordText.Name = "m_PasswordText";
			this.m_PasswordText.PasswordChar = '*';
			this.m_PasswordText.Size = new System.Drawing.Size(160, 21);
			this.m_PasswordText.TabIndex = 1;
			this.m_PasswordText.Text = "";
			// 
			// m_OKButton
			// 
			this.m_OKButton.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.m_OKButton.Location = new System.Drawing.Point(32, 64);
			this.m_OKButton.Name = "m_OKButton";
			this.m_OKButton.Size = new System.Drawing.Size(72, 24);
			this.m_OKButton.TabIndex = 2;
			this.m_OKButton.Text = "确定";
			this.m_OKButton.Click += new System.EventHandler(this.m_OKButton_Click);
			// 
			// m_CancelButton
			// 
			this.m_CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.m_CancelButton.Location = new System.Drawing.Point(136, 64);
			this.m_CancelButton.Name = "m_CancelButton";
			this.m_CancelButton.Size = new System.Drawing.Size(72, 24);
			this.m_CancelButton.TabIndex = 3;
			this.m_CancelButton.Text = "取消";
			this.m_CancelButton.Click += new System.EventHandler(this.m_CancelButton_Click);
			// 
			// ReturnBackForm
			// 
			this.AcceptButton = this.m_OKButton;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.m_CancelButton;
			this.ClientSize = new System.Drawing.Size(248, 94);
			this.Controls.Add(this.m_CancelButton);
			this.Controls.Add(this.m_OKButton);
			this.Controls.Add(this.m_PasswordText);
			this.Controls.Add(this.label1);
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(256, 128);
			this.MinimizeBox = false;
			this.MinimumSize = new System.Drawing.Size(256, 128);
			this.Name = "ReturnBackForm";
			this.Text = "输入密码";
			this.ResumeLayout(false);

		}
		#endregion

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

		private void m_OKButton_Click(object sender, System.EventArgs e)
		{
			if (m_PasswordText.Text.Equals(""))
			{
				MessageBox.Show(this,"密码不能为空,请重新输入!","错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			else
			{
				if (m_PasswordText.Text.Equals(password))
				{
					this.isCorrect=true;
					this.Close();
				}
				else
				{
					MessageBox.Show(this,"密码错误,请重新输入!","错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
					m_PasswordText.Text="";
					m_PasswordText.Focus();
				}
			}
		}

		public bool IsCorrect
		{
			get 
			{
				return this.isCorrect;
			}
		}
	}
}

⌨️ 快捷键说明

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