?? modifypassword.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Model;
using Business_Logic;
namespace Railroad_Trip
{
/// <summary>
/// ModifyPassword 的摘要說明。
/// </summary>
public class ModifyPassword : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.TextBox txtOldPass;
private System.Windows.Forms.TextBox txtNewPass;
private System.Windows.Forms.TextBox txtANewPass;
private string userName,oldPass,newPass,aNewPass;
private System.Windows.Forms.Label lblCancel;
private System.Windows.Forms.Label lblOK;//用戶名,舊密碼,新密碼,重復(fù)的新密碼
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public ModifyPassword()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ModifyPassword));
this.txtUserName = new System.Windows.Forms.TextBox();
this.txtOldPass = new System.Windows.Forms.TextBox();
this.txtNewPass = new System.Windows.Forms.TextBox();
this.txtANewPass = new System.Windows.Forms.TextBox();
this.lblCancel = new System.Windows.Forms.Label();
this.lblOK = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtUserName
//
this.txtUserName.Location = new System.Drawing.Point(288, 16);
this.txtUserName.Name = "txtUserName";
this.txtUserName.Size = new System.Drawing.Size(108, 21);
this.txtUserName.TabIndex = 0;
this.txtUserName.Text = "";
//
// txtOldPass
//
this.txtOldPass.Location = new System.Drawing.Point(288, 48);
this.txtOldPass.Name = "txtOldPass";
this.txtOldPass.PasswordChar = '*';
this.txtOldPass.Size = new System.Drawing.Size(108, 21);
this.txtOldPass.TabIndex = 1;
this.txtOldPass.Text = "";
//
// txtNewPass
//
this.txtNewPass.Location = new System.Drawing.Point(288, 80);
this.txtNewPass.Name = "txtNewPass";
this.txtNewPass.PasswordChar = '*';
this.txtNewPass.Size = new System.Drawing.Size(108, 21);
this.txtNewPass.TabIndex = 2;
this.txtNewPass.Text = "";
//
// txtANewPass
//
this.txtANewPass.Location = new System.Drawing.Point(288, 112);
this.txtANewPass.Name = "txtANewPass";
this.txtANewPass.PasswordChar = '*';
this.txtANewPass.Size = new System.Drawing.Size(108, 21);
this.txtANewPass.TabIndex = 3;
this.txtANewPass.Text = "";
//
// lblCancel
//
this.lblCancel.BackColor = System.Drawing.Color.Transparent;
this.lblCancel.Location = new System.Drawing.Point(196, 168);
this.lblCancel.Name = "lblCancel";
this.lblCancel.Size = new System.Drawing.Size(88, 24);
this.lblCancel.TabIndex = 6;
this.lblCancel.Click += new System.EventHandler(this.lblCancel_Click);
//
// lblOK
//
this.lblOK.BackColor = System.Drawing.Color.Transparent;
this.lblOK.Location = new System.Drawing.Point(312, 168);
this.lblOK.Name = "lblOK";
this.lblOK.Size = new System.Drawing.Size(92, 24);
this.lblOK.TabIndex = 7;
this.lblOK.Click += new System.EventHandler(this.lblOK_Click);
//
// ModifyPassword
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(422, 279);
this.Controls.Add(this.lblOK);
this.Controls.Add(this.lblCancel);
this.Controls.Add(this.txtANewPass);
this.Controls.Add(this.txtNewPass);
this.Controls.Add(this.txtOldPass);
this.Controls.Add(this.txtUserName);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "ModifyPassword";
this.Text = "修改密碼";
this.ResumeLayout(false);
}
#endregion
#region 確定提交修改事件
private void lblOK_Click(object sender, System.EventArgs e)
{
//確定事件
userName=txtUserName.Text;
oldPass=txtOldPass.Text;
newPass=txtNewPass.Text;
aNewPass=txtANewPass.Text;
if(txtUserName.Text=="")
{
//判斷用戶名是否輸入
MessageBox.Show("用戶名不能為空!","提示");
return;
}
else
{
if(txtOldPass.Text=="")
{
//判斷舊密碼是否輸入
MessageBox.Show("舊密碼不能為空!","提示");
return;
}
else
{
if(txtNewPass.Text=="")
{
//判斷新密碼是否輸入
MessageBox.Show("新密碼不能為空!","提示");
return;
}
else
{
if(newPass.Length<6)
{
MessageBox.Show("密碼的長度至少為6位!","提示");
return;
}
else
{}
if(txtANewPass.Text=="")
{
//判斷重復(fù)輸入的新密碼是否輸入
MessageBox.Show("請?jiān)佥斎胍淮涡旅艽a!","提示");
return;
}
else
{
if(aNewPass.Length<6)
{
MessageBox.Show("確認(rèn)密碼的長度至少為6位!","提示");
return;
}
else
{}
if(newPass==aNewPass)
{
//判斷舊密碼與用戶名對應(yīng)否?
LoginEntity data2=new LoginEntity();
data2._UserName=userName;
data2._PassWord=oldPass;
data2._NewPass=aNewPass;
Handle panduan2=new Handle();
if(panduan2.ILogin(data2))
{
//判斷修改是否成功
if(panduan2.ModifyPass(data2))
{
MessageBox.Show("修改成功!","提示");
this.Dispose();
}
else
{
MessageBox.Show("修改失敗! 稍后再試。","提示");
txtOldPass.Text="";
txtNewPass.Text="";
txtANewPass.Text="";
}
}
else
{
MessageBox.Show("用戶名與舊密碼不對應(yīng)!","提示");
txtOldPass.Text="";
return;
}
}
else
{
MessageBox.Show("新密碼兩次輸入的不相同!","提示");
return;
}
}
}
}
}
}
#endregion
private void lblCancel_Click(object sender, System.EventArgs e)
{
//取消事件
this.Dispose();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -