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

📄 loginfrm.cs

📁 《Csharp案例开发》源代码,希望对大家有用~
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using UserData;

namespace LtsClient
{
	/// <summary>
	/// Form2 的摘要说明。
	/// </summary>
	public class loginFrm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox shopname;
		private System.Windows.Forms.TextBox shoppswd;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Button loginbtn;
		private System.Windows.Forms.Button cancelbtn;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public loginFrm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.shopname = new System.Windows.Forms.TextBox();
			this.shoppswd = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.loginbtn = new System.Windows.Forms.Button();
			this.cancelbtn = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(106, 69);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(109, 25);
			this.label1.TabIndex = 0;
			this.label1.Text = "登录系统";
			// 
			// shopname
			// 
			this.shopname.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.shopname.Location = new System.Drawing.Point(114, 103);
			this.shopname.MaxLength = 30;
			this.shopname.Name = "shopname";
			this.shopname.Size = new System.Drawing.Size(109, 21);
			this.shopname.TabIndex = 1;
			this.shopname.Text = "";
			// 
			// shoppswd
			// 
			this.shoppswd.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.shoppswd.Location = new System.Drawing.Point(114, 138);
			this.shoppswd.MaxLength = 30;
			this.shoppswd.Name = "shoppswd";
			this.shoppswd.Size = new System.Drawing.Size(109, 21);
			this.shoppswd.TabIndex = 2;
			this.shoppswd.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(29, 108);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(77, 17);
			this.label2.TabIndex = 3;
			this.label2.Text = "分店代号";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(29, 140);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(77, 17);
			this.label3.TabIndex = 4;
			this.label3.Text = "登录密码";
			// 
			// loginbtn
			// 
			this.loginbtn.Location = new System.Drawing.Point(61, 181);
			this.loginbtn.Name = "loginbtn";
			this.loginbtn.Size = new System.Drawing.Size(83, 25);
			this.loginbtn.TabIndex = 5;
			this.loginbtn.Text = "连接服务器";
			this.loginbtn.Click += new System.EventHandler(this.loginbtn_Click);
			// 
			// cancelbtn
			// 
			this.cancelbtn.Location = new System.Drawing.Point(149, 181);
			this.cancelbtn.Name = "cancelbtn";
			this.cancelbtn.Size = new System.Drawing.Size(83, 25);
			this.cancelbtn.TabIndex = 6;
			this.cancelbtn.Text = "取消连接";
			this.cancelbtn.Click += new System.EventHandler(this.cancelbtn_Click);
			// 
			// loginFrm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(319, 294);
			this.Controls.Add(this.cancelbtn);
			this.Controls.Add(this.loginbtn);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.shoppswd);
			this.Controls.Add(this.shopname);
			this.Controls.Add(this.label1);
			this.Name = "loginFrm";
			this.Text = "登录服务器";
			this.ResumeLayout(false);

		}
		#endregion

		private void loginbtn_Click(object sender, System.EventArgs e)
		{
			string UserCode=shopname.Text.Trim();
			string UserPswd=shoppswd.Text.Trim();
			if(UserCode=="")
			{
				MessageBox.Show("请输入分店代号");
			}
			else
			{
				
				SqlDataReader usdr=FPara.SqlReader("select top 1 * from DepartMent where UserID='"+UserCode+"'",FPara.connStr);
				if(usdr!=null){
					if(usdr.Read()){
						if(usdr["Pswd"].ToString()!=UserPswd)
						{
							MessageBox.Show("用户名和密码不相符");
						}
						else{
							FPara.ShopCode=usdr["UserID"].ToString();
							MessageBox.Show("登录成功");
							this.Close();
						}
					}
					usdr.Close();
				}
			}
		}

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

	}
}

⌨️ 快捷键说明

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