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

📄 dlgfrmlogin.cs

📁 报刊广告管理系统。CSharp编写
💻 CS
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;namespace WWAM.Forms.Dlg{	public class DlgFrmLogin : WWAM.Forms.Dlg.DlgBase	{
		#region DlgFrmLogin
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private DevExpress.XtraEditors.TextEdit txtCode;
		private DevExpress.XtraEditors.TextEdit txtPassword;		private System.ComponentModel.IContainer components = null;		public DlgFrmLogin()		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		public DlgFrmLogin(Form form):base(form)		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		/// <summary>		/// 清理所有正在使用的资源。		/// </summary>		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		#region 设计器生成的代码		/// <summary>		/// 设计器支持所需的方法 - 不要使用代码编辑器修改		/// 此方法的内容。		/// </summary>		private void InitializeComponent()		{			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.txtCode = new DevExpress.XtraEditors.TextEdit();
			this.txtPassword = new DevExpress.XtraEditors.TextEdit();
			((System.ComponentModel.ISupportInitialize)(this.txtCode.Properties)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.txtPassword.Properties)).BeginInit();
			this.SuspendLayout();
			// 
			// btnAccept
			// 
			this.btnAccept.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
			this.btnAccept.LookAndFeel.UseWindowsXPTheme = false;
			this.btnAccept.Name = "btnAccept";
			this.btnAccept.TabIndex = 2;
			// 
			// btnCancel
			// 
			this.btnCancel.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
			this.btnCancel.LookAndFeel.UseWindowsXPTheme = false;
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 3;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 23);
			this.label1.TabIndex = 2;
			this.label1.Text = "用户帐号:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(16, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 23);
			this.label2.TabIndex = 3;
			this.label2.Text = "用户密码:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtCode
			// 
			this.txtCode.EditValue = "";
			this.txtCode.EnterMoveNextControl = true;
			this.txtCode.Location = new System.Drawing.Point(104, 24);
			this.txtCode.Name = "txtCode";
			// 
			// txtCode.Properties
			// 
			this.txtCode.Properties.AppearanceFocused.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.txtCode.Properties.AppearanceFocused.Options.UseBackColor = true;
			this.txtCode.Size = new System.Drawing.Size(176, 21);
			this.txtCode.TabIndex = 0;
			this.txtCode.EditValueChanged += new System.EventHandler(this.BaseEditor_EditValueChanged);
			// 
			// txtPassword
			// 
			this.txtPassword.EnterMoveNextControl = true;
			this.txtPassword.Location = new System.Drawing.Point(104, 64);
			this.txtPassword.Name = "txtPassword";
			// 
			// txtPassword.Properties
			// 
			this.txtPassword.Properties.AppearanceFocused.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.txtPassword.Properties.AppearanceFocused.Options.UseBackColor = true;
			this.txtPassword.Properties.PasswordChar = '*';
			this.txtPassword.Size = new System.Drawing.Size(176, 21);
			this.txtPassword.TabIndex = 1;
			this.txtPassword.EditValueChanged += new System.EventHandler(this.BaseEditor_EditValueChanged);
			// 
			// DlgFrmLogin
			// 
			this.AcceptButton = this.btnAccept;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(314, 152);
			this.Controls.Add(this.txtPassword);
			this.Controls.Add(this.txtCode);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "DlgFrmLogin";
			this.Text = "系统登录";
			this.Controls.SetChildIndex(this.label1, 0);
			this.Controls.SetChildIndex(this.btnCancel, 0);
			this.Controls.SetChildIndex(this.btnAccept, 0);
			this.Controls.SetChildIndex(this.label2, 0);
			this.Controls.SetChildIndex(this.txtCode, 0);
			this.Controls.SetChildIndex(this.txtPassword, 0);
			((System.ComponentModel.ISupportInitialize)(this.txtCode.Properties)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.txtPassword.Properties)).EndInit();
			this.ResumeLayout(false);

		}		#endregion		#endregion
		#region Variable		string verify = "";		int status = 0;//0-登录 1-更换用户 2-系统锁定		public string UserCode		{get{return this.txtCode.Text.Trim();}}		public string UserPassword		{get{return WWAM.BLL.Verify.LocalEncodeString(txtPassword.Text.Trim());}}		#endregion		#region OnFormShow		protected override void OnFormShow()
		{
			base.OnFormShow ();
			if(this.txtCode.Enabled)
			{
				txtCode.Focus();
				this.btnAccept.Left = 128;
				this.btnCancel.Visible = true;
			}
			else
			{
				txtPassword.Focus();
				this.btnAccept.Left = 224;
				this.btnCancel.Visible = false;
			}
		}
		#endregion		#region CanClose		protected override bool CanClose()
		{
			if(txtCode.Enabled)
				if(ControlEmpty(txtCode,"请输入帐号"))return false;
			if(ControlEmpty(txtPassword,"请输入密码"))return false;
			if(status == 1 && txtCode.Text.Trim()==this.verify)
			{
				txtCode.Focus();
				SetToolTip(txtCode,"更换用户与当前用户一致");
				return false;
			}
			if(status == 2 && WWAM.BLL.Verify.LocalEncodeString(txtPassword.Text.Trim())!=this.verify)
			{
				txtPassword.Text = "";
				txtPassword.Focus();
				SetToolTip(txtPassword,"密码错误");
				return false;
			}
			return base.CanClose ();
		}
		#endregion
		#region ShowDialog
		public new DialogResult ShowDialog()
		{
			this.Text = "系统登录";
			this.status = 0;
			this.txtCode.Text = "";
			this.txtPassword.Text = "";
			this.txtCode.Enabled = true;
			return base.ShowDialog();
		}

		public DialogResult ShowDialog(string code)
		{
			this.Text = "更换用户";
			this.status = 1;
			this.txtCode.Text = "";
			this.txtPassword.Text = "";
			this.txtCode.Enabled = true;
			this.verify = code;
			return base.ShowDialog();
		}

		public DialogResult ShowDialog(string code ,string password)
		{
			this.Text = "系统解锁";
			this.status = 2;
			this.txtCode.Text = code;
			this.txtPassword.Text = "";
			this.txtCode.Enabled = false;
			this.verify = password;
			return base.ShowDialog();
		}
		#endregion

	}}

⌨️ 快捷键说明

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