📄 frmload.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ExamCenter.BLCTier;
using System.Configuration;
namespace ExamCenter.FormTier
{
/// <summary>
/// FrmLoad 的摘要说明。
/// </summary>
public class FrmLoad : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
//
//以下四个变量是我自己定义的,其中前三个是静态变量,用来返回登陆窗体的结果
//PassedOrNot返回是否通过验证 ,FirstTimeLoad表示是否是第一次调用这个对话框,UserId返回登陆用户的账号
//ErrorTimes表示验证密码时,错误的次数
//
private static int intUserId=0 ;
private static bool blnPassedOrNot=false;
public static bool blnFirstTimeLoad=true;
private int intErrorTimes=0;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label lblEmpId;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.TextBox txtUserEName;
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Label lblExit;
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public static bool BlnPassedOrNot
{
get{ return blnPassedOrNot;}
set{ blnPassedOrNot=value;}
}
public static int IntUserID
{
get {return intUserId;}
set {intUserId=value;}
}
public FrmLoad()
{
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmLoad));
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtPassword = new System.Windows.Forms.TextBox();
this.lblEmpId = new System.Windows.Forms.Label();
this.lblPassword = new System.Windows.Forms.Label();
this.txtUserEName = new System.Windows.Forms.TextBox();
this.lblTitle = new System.Windows.Forms.Label();
this.lblExit = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// btnOk
//
this.btnOk.BackColor = System.Drawing.Color.Transparent;
this.btnOk.Location = new System.Drawing.Point(104, 130);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(64, 23);
this.btnOk.TabIndex = 2;
this.btnOk.Text = "确定";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.BackColor = System.Drawing.Color.Transparent;
this.btnCancel.Location = new System.Drawing.Point(216, 130);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(64, 23);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(160, 88);
this.txtPassword.MaxLength = 10;
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(136, 21);
this.txtPassword.TabIndex = 1;
this.txtPassword.Text = "";
//
// lblEmpId
//
this.lblEmpId.BackColor = System.Drawing.Color.Transparent;
this.lblEmpId.Location = new System.Drawing.Point(80, 48);
this.lblEmpId.Name = "lblEmpId";
this.lblEmpId.Size = new System.Drawing.Size(72, 16);
this.lblEmpId.TabIndex = 4;
this.lblEmpId.Text = "登录名称:";
//
// lblPassword
//
this.lblPassword.BackColor = System.Drawing.Color.Transparent;
this.lblPassword.Location = new System.Drawing.Point(96, 88);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(48, 16);
this.lblPassword.TabIndex = 5;
this.lblPassword.Text = "密码:";
//
// txtUserEName
//
this.txtUserEName.Location = new System.Drawing.Point(160, 48);
this.txtUserEName.MaxLength = 10;
this.txtUserEName.Multiline = true;
this.txtUserEName.Name = "txtUserEName";
this.txtUserEName.Size = new System.Drawing.Size(136, 21);
this.txtUserEName.TabIndex = 0;
this.txtUserEName.Text = "";
//
// lblTitle
//
this.lblTitle.BackColor = System.Drawing.Color.Transparent;
this.lblTitle.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblTitle.Location = new System.Drawing.Point(120, 6);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(100, 16);
this.lblTitle.TabIndex = 6;
this.lblTitle.Text = " 用 户 登 录";
//
// lblExit
//
this.lblExit.BackColor = System.Drawing.Color.Transparent;
this.lblExit.Location = new System.Drawing.Point(304, 0);
this.lblExit.Name = "lblExit";
this.lblExit.Size = new System.Drawing.Size(16, 16);
this.lblExit.TabIndex = 7;
this.lblExit.Click += new System.EventHandler(this.lblExit_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(22, 41);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(50, 48);
this.pictureBox1.TabIndex = 8;
this.pictureBox1.TabStop = false;
//
// FrmLoad
//
this.AcceptButton = this.btnOk;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Bitmap)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(324, 177);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.lblExit,
this.lblTitle,
this.lblPassword,
this.lblEmpId,
this.txtPassword,
this.txtUserEName,
this.btnCancel,
this.btnOk});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmLoad";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "登陆界面";
this.Load += new System.EventHandler(this.FrmLoad_Load);
this.ResumeLayout(false);
}
#endregion
private void btnOk_Click(object sender, System.EventArgs e)
{
//if(Rockey.FindRockey()!=true)
//{
// MessageBox.Show("您未获得授权使用本系统、请与程序供应商联系");
// this.Close();
// return;
//}
UserBLC myUserBLC=new UserBLC ();
if(myUserBLC.VerifyPassword (this.txtUserEName .Text .Trim (),this.txtPassword .Text.Trim () )==true)
{
FrmLoad.BlnPassedOrNot=true;
FrmLoad.blnFirstTimeLoad =false;//从此以后的登陆就不再是第一次登陆
this.Close ();
}
else
{
MessageBox.Show ("密码错误!","错误");
this.intErrorTimes ++;
if(this.intErrorTimes ==3)
{
MessageBox.Show ("三次密码错误,系统将结束!","警告");
Application.Exit ();
}
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
if (FrmLoad.blnFirstTimeLoad ==true)//该窗体是第一次使用还是重新登陆?
{
Application .Exit ();
}
else
{
this.Close ();
}
}
private void lblExit_Click(object sender, System.EventArgs e)
{
if (FrmLoad.blnFirstTimeLoad ==true)//该窗体是第一次使用还是重新登陆?
{
//Application .Exit ();
this.Close();
}
else
{
this.Close ();
}
}
private void FrmLoad_Load(object sender, System.EventArgs e)
{
loadConnectStr();
}
private void loadConnectStr()
{
//string serverip=Encryption.Decrypt(ConfigurationSettings.AppSettings["serverip"],"11111111");
//string databasename=Encryption.Decrypt(ConfigurationSettings.AppSettings["databasename"],"11111111");
//string uid=Encryption.Decrypt(ConfigurationSettings.AppSettings["uid"],"11111111");
//string pwd=Encryption.Decrypt(ConfigurationSettings.AppSettings["pwd"],"11111111");
//ADLCTier.BaseADLC.strConn="Data source="+serverip+";"+"initial catalog="+databasename+";"+"user id="+uid+";"+"password="+pwd+";";
ADLCTier.BaseADLC.strConn = "Data source=HXZK;" + "initial catalog=examcenter;" + "user id=sa;" + "password=sa;";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -