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

📄 frmlogin.cs

📁 实现房产销售的房屋管理 客户管理 并且在客户管理中实现了对预定客户和已购房客户的查询和修改
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace frmLogin
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class frmLogin : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lblMes;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.TextBox txtUser;
		private System.Windows.Forms.Button btnLogin;
		private System.Windows.Forms.TextBox txtPwd;
		private System.Windows.Forms.Label lblPwd;
		private System.Windows.Forms.Label lblUser;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.Button btnExit;
		private System.ComponentModel.IContainer components;
		public string username;

		public frmLogin()
		{
			//
			// 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(frmLogin));
			this.lblMes = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.txtUser = new System.Windows.Forms.TextBox();
			this.btnExit = new System.Windows.Forms.Button();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.btnLogin = new System.Windows.Forms.Button();
			this.txtPwd = new System.Windows.Forms.TextBox();
			this.lblPwd = new System.Windows.Forms.Label();
			this.lblUser = new System.Windows.Forms.Label();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// lblMes
			// 
			this.lblMes.BackColor = System.Drawing.Color.Gainsboro;
			this.lblMes.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.lblMes.ForeColor = System.Drawing.Color.Red;
			this.lblMes.Location = new System.Drawing.Point(2, 144);
			this.lblMes.Name = "lblMes";
			this.lblMes.Size = new System.Drawing.Size(296, 32);
			this.lblMes.TabIndex = 4;
			// 
			// groupBox1
			// 
			this.groupBox1.BackColor = System.Drawing.Color.LightGray;
			this.groupBox1.Controls.Add(this.txtUser);
			this.groupBox1.Controls.Add(this.btnExit);
			this.groupBox1.Controls.Add(this.btnLogin);
			this.groupBox1.Controls.Add(this.txtPwd);
			this.groupBox1.Controls.Add(this.lblPwd);
			this.groupBox1.Controls.Add(this.lblUser);
			this.groupBox1.Location = new System.Drawing.Point(0, 0);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(304, 144);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
			// 
			// txtUser
			// 
			this.txtUser.BackColor = System.Drawing.Color.LightSteelBlue;
			this.txtUser.Location = new System.Drawing.Point(128, 24);
			this.txtUser.Name = "txtUser";
			this.txtUser.Size = new System.Drawing.Size(168, 21);
			this.txtUser.TabIndex = 6;
			this.txtUser.Text = "";
			// 
			// btnExit
			// 
			this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnExit.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnExit.ForeColor = System.Drawing.Color.Tomato;
			this.btnExit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnExit.ImageIndex = 3;
			this.btnExit.ImageList = this.imageList1;
			this.btnExit.Location = new System.Drawing.Point(160, 96);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(104, 40);
			this.btnExit.TabIndex = 5;
			this.btnExit.Text = "关闭系统";
			this.btnExit.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(30, 30);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// btnLogin
			// 
			this.btnLogin.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnLogin.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnLogin.ForeColor = System.Drawing.Color.Tomato;
			this.btnLogin.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnLogin.ImageIndex = 2;
			this.btnLogin.ImageList = this.imageList1;
			this.btnLogin.Location = new System.Drawing.Point(40, 96);
			this.btnLogin.Name = "btnLogin";
			this.btnLogin.Size = new System.Drawing.Size(104, 40);
			this.btnLogin.TabIndex = 4;
			this.btnLogin.Text = "用户登录";
			this.btnLogin.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
			// 
			// txtPwd
			// 
			this.txtPwd.BackColor = System.Drawing.Color.LightSteelBlue;
			this.txtPwd.Location = new System.Drawing.Point(128, 64);
			this.txtPwd.Name = "txtPwd";
			this.txtPwd.PasswordChar = '*';
			this.txtPwd.Size = new System.Drawing.Size(168, 21);
			this.txtPwd.TabIndex = 2;
			this.txtPwd.Text = "";
			// 
			// lblPwd
			// 
			this.lblPwd.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblPwd.ForeColor = System.Drawing.Color.RoyalBlue;
			this.lblPwd.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.lblPwd.ImageIndex = 1;
			this.lblPwd.ImageList = this.imageList1;
			this.lblPwd.Location = new System.Drawing.Point(8, 64);
			this.lblPwd.Name = "lblPwd";
			this.lblPwd.Size = new System.Drawing.Size(112, 32);
			this.lblPwd.TabIndex = 1;
			this.lblPwd.Text = "  用户密码:";
			this.lblPwd.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblUser
			// 
			this.lblUser.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblUser.ForeColor = System.Drawing.Color.RoyalBlue;
			this.lblUser.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.lblUser.ImageIndex = 0;
			this.lblUser.ImageList = this.imageList1;
			this.lblUser.Location = new System.Drawing.Point(8, 24);
			this.lblUser.Name = "lblUser";
			this.lblUser.Size = new System.Drawing.Size(112, 32);
			this.lblUser.TabIndex = 0;
			this.lblUser.Text = "  操作人员:";
			this.lblUser.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// frmLogin
			// 
			this.AcceptButton = this.btnLogin;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(304, 181);
			this.Controls.Add(this.lblMes);
			this.Controls.Add(this.groupBox1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmLogin";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "房地产销售管理系统";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmLogin_Closing);
			this.Load += new System.EventHandler(this.frmLogin_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmLogin_Load(object sender, System.EventArgs e)
		{
			this.txtUser.Focus();
		}

		private void btnExit_Click(object sender, System.EventArgs e)
		{
			DialogResult dr=new DialogResult();
			dr=MessageBox.Show("您确定退出本系统吗?","消息",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
			if(dr==DialogResult.OK)
			{
				Application.Exit();
			}
			else
				return;
		}

		private void btnLogin_Click(object sender, System.EventArgs e)
		{
			
			if(this.txtUser.Text=="" || this.txtPwd.Text=="")
			{
				this.lblMes.Text="用户名或密码不能为空!";
				return;
			}
			HouseBE.Login login=new HouseBE.Login();
			HouseBS.LoginBS logins=new HouseBS.LoginBS();

			login.LoginName=this.txtUser.Text;
			login.LoginPwd=this.txtPwd.Text;
			logins.login=login;
			try
			{
				if(logins.Logins())
				{
					username=this.txtUser.Text;
					frmMain fm=new frmMain(username);
					this.Hide();
					fm.Show();
				}
				else
				{
					this.lblMes.Text="帐号或密码错误";
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void frmLogin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			DialogResult dr=new DialogResult();
			dr=MessageBox.Show("您确定退出本系统吗?","消息",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
			if(dr==DialogResult.OK)
			{
				Application.Exit();
			}
			else
				return;
		}

		private void groupBox1_Enter(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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