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

📄 form_logon.cs

📁 一个很简单的考试系统。实用性很强啊!数据库在里面
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace bizdb
{
	/// <summary>
	/// Form_logon 的摘要说明。
	/// </summary>
	public class Form_logon : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lbl_dlm;
		private System.Windows.Forms.Label lbl_kl;
		private System.Windows.Forms.TextBox txt_dlm;
		private System.Windows.Forms.TextBox txt_kl;
		private System.Windows.Forms.Button btn_qd;
		private System.Windows.Forms.Button btn_lk;
		private dbAccess db = new dbAccess();
		private common c = new common();

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form_logon()
		{
			//
			// 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.lbl_dlm = new System.Windows.Forms.Label();
			this.lbl_kl = new System.Windows.Forms.Label();
			this.txt_dlm = new System.Windows.Forms.TextBox();
			this.txt_kl = new System.Windows.Forms.TextBox();
			this.btn_qd = new System.Windows.Forms.Button();
			this.btn_lk = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// lbl_dlm
			// 
			this.lbl_dlm.Location = new System.Drawing.Point(9, 32);
			this.lbl_dlm.Name = "lbl_dlm";
			this.lbl_dlm.Size = new System.Drawing.Size(84, 27);
			this.lbl_dlm.TabIndex = 0;
			this.lbl_dlm.Text = "登录名";
			// 
			// lbl_kl
			// 
			this.lbl_kl.Location = new System.Drawing.Point(9, 93);
			this.lbl_kl.Name = "lbl_kl";
			this.lbl_kl.Size = new System.Drawing.Size(84, 26);
			this.lbl_kl.TabIndex = 1;
			this.lbl_kl.Text = "口令";
			// 
			// txt_dlm
			// 
			this.txt_dlm.Location = new System.Drawing.Point(93, 32);
			this.txt_dlm.Name = "txt_dlm";
			this.txt_dlm.Size = new System.Drawing.Size(117, 21);
			this.txt_dlm.TabIndex = 2;
			this.txt_dlm.Text = "";
			// 
			// txt_kl
			// 
			this.txt_kl.Location = new System.Drawing.Point(93, 93);
			this.txt_kl.Name = "txt_kl";
			this.txt_kl.PasswordChar = '*';
			this.txt_kl.Size = new System.Drawing.Size(117, 21);
			this.txt_kl.TabIndex = 3;
			this.txt_kl.Text = "";
			// 
			// btn_qd
			// 
			this.btn_qd.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btn_qd.Location = new System.Drawing.Point(234, 32);
			this.btn_qd.Name = "btn_qd";
			this.btn_qd.Size = new System.Drawing.Size(87, 27);
			this.btn_qd.TabIndex = 4;
			this.btn_qd.Text = "确定";
			this.btn_qd.Click += new System.EventHandler(this.btn_qd_Click);
			// 
			// btn_lk
			// 
			this.btn_lk.Location = new System.Drawing.Point(234, 93);
			this.btn_lk.Name = "btn_lk";
			this.btn_lk.Size = new System.Drawing.Size(87, 26);
			this.btn_lk.TabIndex = 5;
			this.btn_lk.Text = "离开";
			this.btn_lk.Click += new System.EventHandler(this.btn_lk_Click);
			// 
			// Form_logon
			// 
			this.AcceptButton = this.btn_qd;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(340, 149);
			this.ControlBox = false;
			this.Controls.Add(this.btn_lk);
			this.Controls.Add(this.btn_qd);
			this.Controls.Add(this.txt_kl);
			this.Controls.Add(this.txt_dlm);
			this.Controls.Add(this.lbl_kl);
			this.Controls.Add(this.lbl_dlm);
			this.Name = "Form_logon";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "阜和教育课程体系试题库与考试系统";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.Form_logon_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void btn_qd_Click(object sender, System.EventArgs e)
		{
			try
			{
				
				SqlConnection myConn = new SqlConnection();
				myConn.ConnectionString = db.connStr;
				string strCom = "SELECT empd_password FROM employeeDictionary WHERE emp_id='" + txt_dlm.Text +"'";
				System.Data.SqlClient.SqlCommand comm;
				comm = myConn.CreateCommand();
				comm.CommandText = strCom;
				SqlDataAdapter mydataA= new SqlDataAdapter();
				mydataA.SelectCommand = comm;
				DataSet	myDataSet = new DataSet ( ) ;
				try
				{
					myConn.Open();
				}
				catch
				{
					MessageBox.Show("数据库连接失败,请重新配置数据库连接",c.sysname+"课程体系试题库系统提示");
					return;
				}	
				mydataA.Fill(myDataSet,"employeedictionary");
				myConn.Close ( ) ;
				string str=myDataSet.Tables["employeedictionary"].Rows[0]["empd_password"].ToString();
				if(txt_kl.Text==str)
				{
					
					strCom = "SELECT rol_no FROM Employee WHERE emp_id='" + txt_dlm.Text +"'";
					comm.CommandText = strCom;
					mydataA.SelectCommand = comm;
					myConn.Open( );
					mydataA.Fill(myDataSet,"employee");
					myConn.Close ( ) ;
					string rolno=myDataSet.Tables["employee"].Rows[0]["rol_no"].ToString();

					strCom = "SELECT rol_code FROM role WHERE rol_no='" + rolno +"'";
					comm.CommandText = strCom;
					mydataA.SelectCommand = comm;
					myConn.Open( );
					mydataA.Fill(myDataSet,"role");
					myConn.Close ( ) ;
					
					c.role = myDataSet.Tables["role"].Rows[0]["rol_code"].ToString();
					c.emplid = txt_dlm.Text;
					this.Hide();
					Form_main fr = new Form_main();
					fr.Show();
				}
				else
				{
					MessageBox.Show("口令错误",c.sysname+"课程体系试题库系统提示");  
				}	
			}
			catch
			{

				MessageBox.Show("用户名不存在",c.sysname+"课程体系试题库系统提示");
				this.Show();
			}
		}

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

		private void Form_logon_Load(object sender, System.EventArgs e)
		{
			this.Text = c.sysname+"课程体系试题库系统";
			this.Activate();
		}





	}
}

⌨️ 快捷键说明

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