📄 frmlogin.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ExamSystem.BusinessFacade.TeacherFac;
using ExamSystem.Common.Objects;
namespace TeachersClient
{
/// <summary>
/// FrmLogin 的摘要说明。
/// </summary>
public class FrmLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtPass;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private FrmMain main;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnExit;
private bool isLogin;
/// <summary>
/// 判断是否登陆成功
/// </summary>
public bool IsLogin
{
get
{
return isLogin;
}
}
public FrmLogin()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
public FrmLogin(FrmMain main): this()
{
this.main=main;
}
/// <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.label1 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtPass = new System.Windows.Forms.TextBox();
this.btnLogin = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(14, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 18);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(64, 10);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(146, 21);
this.txtName.TabIndex = 1;
this.txtName.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(18, 50);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 20);
this.label2.TabIndex = 2;
this.label2.Text = "密码:";
//
// txtPass
//
this.txtPass.Location = new System.Drawing.Point(62, 48);
this.txtPass.Name = "txtPass";
this.txtPass.PasswordChar = '*';
this.txtPass.Size = new System.Drawing.Size(146, 21);
this.txtPass.TabIndex = 3;
this.txtPass.Text = "";
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(40, 86);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(60, 24);
this.btnLogin.TabIndex = 4;
this.btnLogin.Text = "登陆";
this.btnLogin.Click += new System.EventHandler(this.button1_Click);
//
// btnExit
//
this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnExit.Location = new System.Drawing.Point(150, 86);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(58, 24);
this.btnExit.TabIndex = 5;
this.btnExit.Text = "退出";
this.btnExit.Click += new System.EventHandler(this.button2_Click);
//
// FrmLogin
//
this.AcceptButton = this.btnLogin;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(242, 119);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.txtPass);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmLogin";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "考试系统后台管理-登陆";
this.Load += new System.EventHandler(this.FrmLogin_Load);
this.ResumeLayout(false);
}
#endregion
private void FrmLogin_Load(object sender, System.EventArgs e)
{
this.isLogin=false;
}
private void button1_Click(object sender, System.EventArgs e)
{
ManagerFac manFac=new ManagerFac();
Teacher tea=manFac.login(txtName.Text,txtPass.Text);
if(tea!=null)
{
this.isLogin=true;
if(main!=null)
{
main.CurTeacher=tea;
}
this.Close();
return;
}
MessageBox.Show("用户名或密码错误","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -