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

📄 login.cs

📁 Microsoft Visual C++ 6.0
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace CJGL
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Login : System.Windows.Forms.Form
	{
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.ComboBox Uname;
		private System.Windows.Forms.TextBox UPWD;
		private System.Windows.Forms.ComboBox ULogin;
		private System.Windows.Forms.Button newLogin;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Login()
		{
			//
			// 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Login));
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.Uname = new System.Windows.Forms.ComboBox();
			this.UPWD = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.ULogin = new System.Windows.Forms.ComboBox();
			this.button3 = new System.Windows.Forms.Button();
			this.newLogin = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(352, 50);
			this.pictureBox1.TabIndex = 0;
			this.pictureBox1.TabStop = false;
			this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(32, 64);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 23);
			this.label1.TabIndex = 1;
			this.label1.Text = "登录帐号:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 96);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 23);
			this.label2.TabIndex = 2;
			this.label2.Text = "登录密码:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// Uname
			// 
			this.Uname.Location = new System.Drawing.Point(120, 64);
			this.Uname.Name = "Uname";
			this.Uname.Size = new System.Drawing.Size(144, 20);
			this.Uname.TabIndex = 0;
			// 
			// UPWD
			// 
			this.UPWD.Location = new System.Drawing.Point(120, 96);
			this.UPWD.Name = "UPWD";
			this.UPWD.PasswordChar = '*';
			this.UPWD.Size = new System.Drawing.Size(144, 21);
			this.UPWD.TabIndex = 4;
			this.UPWD.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(32, 128);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 23);
			this.label3.TabIndex = 7;
			this.label3.Text = "登录模式:";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// ULogin
			// 
			this.ULogin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.ULogin.Items.AddRange(new object[] {
														"学生用户登录",
														"系统管理员登录"});
			this.ULogin.Location = new System.Drawing.Point(120, 128);
			this.ULogin.Name = "ULogin";
			this.ULogin.Size = new System.Drawing.Size(144, 20);
			this.ULogin.TabIndex = 5;
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(140, 160);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(70, 22);
			this.button3.TabIndex = 10;
			this.button3.Text = "取消";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// newLogin
			// 
			this.newLogin.Location = new System.Drawing.Point(248, 160);
			this.newLogin.Name = "newLogin";
			this.newLogin.Size = new System.Drawing.Size(70, 22);
			this.newLogin.TabIndex = 11;
			this.newLogin.Text = "注册";
			this.newLogin.Click += new System.EventHandler(this.button4_Click);
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.Color.WhiteSmoke;
			this.button2.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
			this.button2.Location = new System.Drawing.Point(32, 160);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(70, 22);
			this.button2.TabIndex = 6;
			this.button2.Text = "登录";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// Login
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(235)), ((System.Byte)(246)), ((System.Byte)(255)));
			this.ClientSize = new System.Drawing.Size(350, 191);
			this.Controls.Add(this.newLogin);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.ULogin);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.UPWD);
			this.Controls.Add(this.Uname);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.pictureBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(360, 220);
			this.MinimumSize = new System.Drawing.Size(360, 220);
			this.Name = "Login";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "用户登录";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Login());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.ULogin.SelectedIndex=0;
		}

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

		private void button2_Click(object sender, System.EventArgs e)
		{
			string username,password,logintype;
			if (Uname.Text.Trim()!=""&&UPWD.Text.Trim()!=""&&ULogin.Text.Trim()!="")
			{
				username=Uname.Text.Trim();
				password=UPWD.Text.Trim();
				logintype=ULogin.Text.Trim();
				DataAccess data=new DataAccess();
				if (logintype=="系统管理员登录")
				{
					if (data.CheckAdmin(username,password))
					{
						WinMain winmain=new WinMain();
						winmain.user="管理员";
						winmain.Show();						
                	}
					else
					{
						MessageBox.Show("您输入的帐号或密码有误,请重新登录!");
					}
				}
				else 
				{
					if (data.CheckUser(username,password))
					{
						WinMain winmain=new WinMain();
						winmain.user="学生";
						winmain.Show();						
					}
					else
					{
						MessageBox.Show("您输入的帐号或密码有误,请重新登录!");
					}
				}
			}
			else
				MessageBox.Show("请输入或选择您的用户帐号和密码后进行登录");
		}

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

		private void button4_Click(object sender, System.EventArgs e)
		{
			WinNewUser winnewuser =new WinNewUser();
			winnewuser.Show();
			
		}
	}
}

⌨️ 快捷键说明

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