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

📄 登录.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;

namespace 自动化考试系统
{
	/// <summary>
	/// Form登录 的摘要说明。
	/// </summary>
	public class 登录 : System.Windows.Forms.Form
	{
		public int loginflag=0;
		public string displaystyle="";
		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 denglu;
		private System.Windows.Forms.Button tuichu;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
	
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public 登录()
		{
			//
			// 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(登录));
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.denglu = new System.Windows.Forms.Button();
			this.tuichu = new System.Windows.Forms.Button();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
			this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(88, 64);
			this.pictureBox1.TabIndex = 0;
			this.pictureBox1.TabStop = false;
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.Font = new System.Drawing.Font("华文中宋", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.Color.White;
			this.label1.Location = new System.Drawing.Point(104, 40);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(184, 40);
			this.label1.TabIndex = 1;
			this.label1.Text = "用 户 登 录";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.Transparent;
			this.label2.Font = new System.Drawing.Font("黑体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.ForeColor = System.Drawing.Color.White;
			this.label2.Location = new System.Drawing.Point(40, 120);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 32);
			this.label2.TabIndex = 2;
			this.label2.Text = "用户名:";
			// 
			// label3
			// 
			this.label3.BackColor = System.Drawing.Color.Transparent;
			this.label3.Font = new System.Drawing.Font("黑体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label3.ForeColor = System.Drawing.Color.White;
			this.label3.Location = new System.Drawing.Point(40, 168);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 32);
			this.label3.TabIndex = 2;
			this.label3.Text = "密码:";
			// 
			// denglu
			// 
			this.denglu.BackColor = System.Drawing.Color.Transparent;
			this.denglu.ForeColor = System.Drawing.Color.White;
			this.denglu.Location = new System.Drawing.Point(40, 208);
			this.denglu.Name = "denglu";
			this.denglu.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.denglu.Size = new System.Drawing.Size(72, 32);
			this.denglu.TabIndex = 4;
			this.denglu.Text = "登录";
			this.denglu.Click += new System.EventHandler(this.denglu_Click);
			// 
			// tuichu
			// 
			this.tuichu.BackColor = System.Drawing.Color.Transparent;
			this.tuichu.ForeColor = System.Drawing.Color.White;
			this.tuichu.Location = new System.Drawing.Point(208, 208);
			this.tuichu.Name = "tuichu";
			this.tuichu.Size = new System.Drawing.Size(72, 32);
			this.tuichu.TabIndex = 4;
			this.tuichu.Text = "退出";
			this.tuichu.Click += new System.EventHandler(this.button2_Click);
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(112, 120);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(160, 21);
			this.textBox1.TabIndex = 5;
			this.textBox1.Text = "";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(112, 168);
			this.textBox2.Name = "textBox2";
			this.textBox2.PasswordChar = '*';
			this.textBox2.Size = new System.Drawing.Size(160, 21);
			this.textBox2.TabIndex = 5;
			this.textBox2.Text = "";
			// 
			// 登录
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(352, 272);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.denglu);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.tuichu);
			this.Controls.Add(this.textBox2);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "登录";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Load += new System.EventHandler(this.登录_Load);
			this.ResumeLayout(false);

		}
		#endregion

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

		private void denglu_Click(object sender, System.EventArgs e)
		{
			string stl="Provider=Microsoft.Jet.OLEDB.4.0;Data source=hua.mdb";
			string stl1="select * from ws where name='"+this.textBox1.Text+"'";
			OleDbConnection con=new OleDbConnection(stl);
			OleDbCommand com=new OleDbCommand(stl1,con);
			OleDbDataReader ord=null;
			con.Open();
			ord=com.ExecuteReader();
			ord.Read();

			try
			{
				if(this.textBox1.Text==""||this.textBox2.Text=="")
				{
					MessageBox.Show("请填完!","信息");
				}
				else if(this.textBox1.Text!=ord["name"].ToString())
				{
					MessageBox.Show("用户名不对","信息");
				}
				else if(this.textBox2.Text!=ord["ps"].ToString())
				{
					MessageBox.Show("密码错误","信息");
				}
				else if(ord["lx"].ToString()=="管理员")
				{
					this.Hide();
					guanliyuan an=new guanliyuan();
					an.ShowDialog();
				}
				else if(ord["lx"].ToString()=="老师")
				{
					this.Hide();
				jiaoshi sn=new jiaoshi();
					sn.Show();
				}
				else
				{
				MessageBox.Show("没有权限!","信息");
				}
			}
			catch(System.Exception aa)
			{
			MessageBox.Show(aa.Message);
			}
		}

		private void 登录_Load(object sender, System.EventArgs e)
		{
			this.textBox1.Focus();
		}

	}
}

⌨️ 快捷键说明

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