📄 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 DevExpress.XtraEditors.PanelControl panelControl1;
private DevExpress.XtraEditors.TextEdit txtOldPass;
private DevExpress.XtraEditors.TextEdit txtNewPass;
private DevExpress.XtraEditors.TextEdit txtNewPassC;
private DevExpress.XtraEditors.SimpleButton btnOK;
private DevExpress.XtraEditors.SimpleButton btnClear;
/// <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.panelControl1 = new DevExpress.XtraEditors.PanelControl();
this.txtNewPassC = new DevExpress.XtraEditors.TextEdit();
this.txtNewPass = new DevExpress.XtraEditors.TextEdit();
this.btnClear = new DevExpress.XtraEditors.SimpleButton();
this.btnOK = new DevExpress.XtraEditors.SimpleButton();
this.txtOldPass = new DevExpress.XtraEditors.TextEdit();
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
this.panelControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txtNewPassC.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtNewPass.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtOldPass.Properties)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
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.BackColor = System.Drawing.Color.Transparent;
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.BackColor = System.Drawing.Color.Transparent;
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;
//
// panelControl1
//
this.panelControl1.Appearance.BackColor = System.Drawing.Color.Transparent;
this.panelControl1.Appearance.Options.UseBackColor = true;
this.panelControl1.Controls.Add(this.txtNewPassC);
this.panelControl1.Controls.Add(this.txtNewPass);
this.panelControl1.Controls.Add(this.label2);
this.panelControl1.Controls.Add(this.label3);
this.panelControl1.Controls.Add(this.label1);
this.panelControl1.Controls.Add(this.btnClear);
this.panelControl1.Controls.Add(this.btnOK);
this.panelControl1.Controls.Add(this.txtOldPass);
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl1.Location = new System.Drawing.Point(0, 0);
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(552, 349);
this.panelControl1.TabIndex = 5;
this.panelControl1.Text = "panelControl1";
//
// txtNewPassC
//
this.txtNewPassC.EditValue = "";
this.txtNewPassC.Location = new System.Drawing.Point(136, 88);
this.txtNewPassC.Name = "txtNewPassC";
//
// txtNewPassC.Properties
//
this.txtNewPassC.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txtNewPassC.Properties.PasswordChar = '*';
this.txtNewPassC.Size = new System.Drawing.Size(184, 21);
this.txtNewPassC.TabIndex = 7;
//
// txtNewPass
//
this.txtNewPass.EditValue = "";
this.txtNewPass.Location = new System.Drawing.Point(136, 56);
this.txtNewPass.Name = "txtNewPass";
//
// txtNewPass.Properties
//
this.txtNewPass.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txtNewPass.Properties.PasswordChar = '*';
this.txtNewPass.Size = new System.Drawing.Size(184, 21);
this.txtNewPass.TabIndex = 6;
//
// btnClear
//
this.btnClear.Location = new System.Drawing.Point(224, 152);
this.btnClear.Name = "btnClear";
this.btnClear.TabIndex = 2;
this.btnClear.Text = "清空";
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(120, 152);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 1;
this.btnOK.Text = "确定";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// txtOldPass
//
this.txtOldPass.EditValue = "";
this.txtOldPass.Location = new System.Drawing.Point(136, 24);
this.txtOldPass.Name = "txtOldPass";
//
// txtOldPass.Properties
//
this.txtOldPass.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txtOldPass.Properties.PasswordChar = '*';
this.txtOldPass.Size = new System.Drawing.Size(184, 21);
this.txtOldPass.TabIndex = 0;
//
// ChangePassword
//
this.AutoScroll = true;
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(141)), ((System.Byte)(193)), ((System.Byte)(230)));
this.Controls.Add(this.panelControl1);
this.Name = "ChangePassword";
this.Size = new System.Drawing.Size(552, 349);
this.Load += new System.EventHandler(this.ChangePassword_Load);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
this.panelControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.txtNewPassC.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtNewPass.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtOldPass.Properties)).EndInit();
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 + -