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

📄 frmlogin.cs

📁 考试管理系统CS架构 不需更多说明
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ExamSystem.Common.Objects;
using ExamSystem.BusinessFacade.StudentFacsde;
using System.Data;
using ExamSystem.BusinessFacade.TeacherFac;
namespace StudentsClient
{
	/// <summary>
	/// FrmLogin 的摘要说明。
	/// </summary>
	public class FrmLogin : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.Button btnLogin;
		private System.Windows.Forms.Label lblPwd;
		private System.Windows.Forms.Label lblName;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.ComboBox cmbClass;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox txtPass;
		private System.Windows.Forms.NumericUpDown nudNum;
		private void fillClass()
		{
			ClassFac clsFac=new ClassFac();
			DataSet dsClass=clsFac.getClass(-1,"",-1);
			cmbClass.DataSource=dsClass.Tables[0];
			cmbClass.DisplayMember="ClassName";
			cmbClass.ValueMember="ClassID";
			if(cmbClass.Items.Count>0)
			{
				cmbClass.SelectedIndex=0;
			}
		}
		public FrmLogin()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			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.btnExit = new System.Windows.Forms.Button();
			this.btnLogin = new System.Windows.Forms.Button();
			this.txtPass = new System.Windows.Forms.TextBox();
			this.lblPwd = new System.Windows.Forms.Label();
			this.lblName = new System.Windows.Forms.Label();
			this.cmbClass = new System.Windows.Forms.ComboBox();
			this.nudNum = new System.Windows.Forms.NumericUpDown();
			this.label1 = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)(this.nudNum)).BeginInit();
			this.SuspendLayout();
			// 
			// btnExit
			// 
			this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnExit.Location = new System.Drawing.Point(136, 108);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(58, 24);
			this.btnExit.TabIndex = 11;
			this.btnExit.Text = "退出";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// btnLogin
			// 
			this.btnLogin.Location = new System.Drawing.Point(64, 108);
			this.btnLogin.Name = "btnLogin";
			this.btnLogin.Size = new System.Drawing.Size(60, 24);
			this.btnLogin.TabIndex = 10;
			this.btnLogin.Text = "登录";
			this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
			// 
			// txtPass
			// 
			this.txtPass.Location = new System.Drawing.Point(88, 76);
			this.txtPass.Name = "txtPass";
			this.txtPass.PasswordChar = '*';
			this.txtPass.Size = new System.Drawing.Size(128, 21);
			this.txtPass.TabIndex = 9;
			this.txtPass.Text = "";
			// 
			// lblPwd
			// 
			this.lblPwd.Location = new System.Drawing.Point(52, 78);
			this.lblPwd.Name = "lblPwd";
			this.lblPwd.Size = new System.Drawing.Size(44, 14);
			this.lblPwd.TabIndex = 8;
			this.lblPwd.Text = "密码:";
			// 
			// lblName
			// 
			this.lblName.Location = new System.Drawing.Point(52, 18);
			this.lblName.Name = "lblName";
			this.lblName.Size = new System.Drawing.Size(56, 14);
			this.lblName.TabIndex = 6;
			this.lblName.Text = "班别:";
			// 
			// cmbClass
			// 
			this.cmbClass.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbClass.Location = new System.Drawing.Point(88, 14);
			this.cmbClass.Name = "cmbClass";
			this.cmbClass.Size = new System.Drawing.Size(110, 20);
			this.cmbClass.TabIndex = 12;
			// 
			// nudNum
			// 
			this.nudNum.Location = new System.Drawing.Point(92, 44);
			this.nudNum.Minimum = new System.Decimal(new int[] {
																   1,
																   0,
																   0,
																   0});
			this.nudNum.Name = "nudNum";
			this.nudNum.Size = new System.Drawing.Size(62, 21);
			this.nudNum.TabIndex = 13;
			this.nudNum.Value = new System.Decimal(new int[] {
																 1,
																 0,
																 0,
																 0});
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(52, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(42, 16);
			this.label1.TabIndex = 14;
			this.label1.Text = "学号:";
			// 
			// FrmLogin
			// 
			this.AcceptButton = this.btnLogin;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnExit;
			this.ClientSize = new System.Drawing.Size(266, 149);
			this.Controls.Add(this.nudNum);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.cmbClass);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnLogin);
			this.Controls.Add(this.txtPass);
			this.Controls.Add(this.lblPwd);
			this.Controls.Add(this.lblName);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FrmLogin";
			this.ShowInTaskbar = false;
			this.Text = "学生登录";
			this.Load += new System.EventHandler(this.FrmLogin_Load);
			((System.ComponentModel.ISupportInitialize)(this.nudNum)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void FrmLogin_Load(object sender, System.EventArgs e)
		{
			fillClass();
		}

		private void btnLogin_Click(object sender, System.EventArgs e)
		{
			if(cmbClass.SelectedIndex<0)
			{
				MessageBox.Show("请选择班级","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			StudentFacade stuFac=new StudentFacade();
			CommVal.CurrentStu=stuFac.login((int)this.nudNum.Value,(int)cmbClass.SelectedValue,txtPass.Text);
			if(CommVal.CurrentStu!=null)
			{
				this.DialogResult=DialogResult.OK;
			}
			else
			{
				MessageBox.Show("用户名或密码错误","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

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

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

⌨️ 快捷键说明

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