📄 changepassword.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CallCenter.BusinessInterfaces.MainForms
{
/// <summary>
/// ChangePassword 的摘要说明。
/// </summary>
public class ChangePassword : UserControl
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtOldPass;
private System.Windows.Forms.TextBox txtNewPass;
private System.Windows.Forms.TextBox txtNewPassC;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Panel panel1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public ChangePassword()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtOldPass = new System.Windows.Forms.TextBox();
this.txtNewPass = new System.Windows.Forms.TextBox();
this.txtNewPassC = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(56, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 24);
this.label1.TabIndex = 0;
this.label1.Text = "原密码";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(56, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 24);
this.label2.TabIndex = 1;
this.label2.Text = "新密码";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(56, 88);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 24);
this.label3.TabIndex = 2;
this.label3.Text = "新密码确认";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtOldPass
//
this.txtOldPass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtOldPass.Location = new System.Drawing.Point(128, 24);
this.txtOldPass.Name = "txtOldPass";
this.txtOldPass.PasswordChar = '*';
this.txtOldPass.Size = new System.Drawing.Size(144, 21);
this.txtOldPass.TabIndex = 3;
this.txtOldPass.Text = "textBox1";
//
// txtNewPass
//
this.txtNewPass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtNewPass.Location = new System.Drawing.Point(128, 56);
this.txtNewPass.Name = "txtNewPass";
this.txtNewPass.PasswordChar = '*';
this.txtNewPass.Size = new System.Drawing.Size(144, 21);
this.txtNewPass.TabIndex = 4;
this.txtNewPass.Text = "textBox1";
//
// txtNewPassC
//
this.txtNewPassC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtNewPassC.Location = new System.Drawing.Point(128, 88);
this.txtNewPassC.Name = "txtNewPassC";
this.txtNewPassC.PasswordChar = '*';
this.txtNewPassC.Size = new System.Drawing.Size(144, 21);
this.txtNewPassC.TabIndex = 5;
this.txtNewPassC.Text = "textBox1";
//
// btnOK
//
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.Location = new System.Drawing.Point(152, 144);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 24);
this.btnOK.TabIndex = 6;
this.btnOK.Text = "确定";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnClear
//
this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClear.Location = new System.Drawing.Point(264, 144);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(75, 24);
this.btnClear.TabIndex = 7;
this.btnClear.Text = "清空";
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// panel1
//
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.txtOldPass);
this.panel1.Controls.Add(this.txtNewPass);
this.panel1.Controls.Add(this.txtNewPassC);
this.panel1.Controls.Add(this.btnOK);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.btnClear);
this.panel1.Location = new System.Drawing.Point(56, 48);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(424, 264);
this.panel1.TabIndex = 8;
//
// ChangePassword
//
this.AutoScroll = true;
this.Controls.Add(this.panel1);
this.Name = "ChangePassword";
this.Size = new System.Drawing.Size(552, 349);
this.Load += new System.EventHandler(this.ChangePassword_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnOK_Click(object sender, System.EventArgs e)
{
if(!this.validate()){
return ;
}
CallCenter.BusinessLayer.SysoperatorBLL bll = new CallCenter.BusinessLayer.SysoperatorBLL();
int flag = bll.changePassword(CallCenter.BusinessInterfaces.MainForms.ShareClass.Operator,this.txtOldPass.Text,this.txtNewPass.Text);
if(1 == flag)
{
MessageBox.Show(this,"密码修改成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.txtOldPass.Text="";
this.txtNewPass.Text="";
this.txtNewPassC.Text="";
}
else if(-1 == flag)
{
MessageBox.Show(this,"原密码错误,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtOldPass.Focus();
}
else{
MessageBox.Show(this,"密码修改失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private bool validate(){
if(this.txtOldPass.Text.Length>10)
{
MessageBox.Show(this,"密码长度不能超过10个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtOldPass.Focus();
return false;
}
if(this.txtNewPass.Text.Length>10){
MessageBox.Show(this,"密码长度不能超过10个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtNewPass.Focus();
return false;
}
if(!this.txtNewPass.Text.Equals(this.txtNewPassC.Text))
{
MessageBox.Show(this,"新密码与确认密码不一致,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtNewPass.Focus();
return false;
}
return true;
}
private void btnClear_Click(object sender, System.EventArgs e)
{
this.txtOldPass.Text="";
this.txtNewPass.Text="";
this.txtNewPassC.Text="";
}
private void ChangePassword_Load(object sender, System.EventArgs e)
{
this.txtOldPass.Text="";
this.txtNewPass.Text="";
this.txtNewPassC.Text="";
this.txtOldPass.Focus();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -