📄 formappset.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LanMsg
{
public partial class FormAppSet : DevComponents.DotNetBar.Office2007Form// Form
{
public FormAppSet()
{
InitializeComponent();
}
private void FormAppSet_Load(object sender, EventArgs e)
{
this.labelUserID.Text = FormAccess.selfInfo.UserID;
}
private void butApp_Click(object sender, EventArgs e)
{
this.ChangePassword();
}
/// <summary>
/// 修改密码
/// </summary>
private void ChangePassword()
{
if (this.textBoxNewPassword.Text.Length < 6)
{
MessageBox.Show("新密码不能少于6位字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBoxNewPassword.Focus();
return;
}
if (this.textBoxNewPassword.Text != this.textBoxNewPasswordAffirm.Text)
{
MessageBox.Show("新密码两次输入不相同,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBoxNewPassword.Focus();
return;
}
if (this.textBoxNewPassword.Text == this.textBoxOldPassword.Text)
{
MessageBox.Show("新密码不能与旧密码相同,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBoxNewPassword.Focus();
return;
}
if (this.textBoxOldPassword.Text != FormAccess.selfPassword)
{
MessageBox.Show("旧密码不正确,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBoxOldPassword.Focus();
return;
}
//IMLibrary.ServerMsg msg = new IMLibrary.ServerMsg();
//msg
byte[] msg = IMLibrary.TextEncoder.textToBytes(FormAccess.selfInfo.UserID + "|" + this.textBoxOldPassword.Text + "|" + this.textBoxNewPassword.Text);
FormAccess.sendMsgToServer(8, new IMLibrary.ServerMsg(FormAccess.selfInfo.ID, msg));
FormAccess.isChangePasswordSuccessful = false;
DateTime tempTime = DateTime.Now;
this.butApp.Enabled = false;
this.buttonCancel.Enabled = false;
bool t=true;
while (t)
{
Application.DoEvents();
if (FormAccess.isChangePasswordSuccessful)
goto successful;
if (FormAccess.DateDiff(tempTime, System.DateTime.Now) > 5)//如果已经超时2秒,则重新发送上次的数据包
{
this.butApp.Enabled = true;
this.buttonCancel.Enabled = true;
MessageBox.Show("修改密码超时,密码修改不成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
successful:
this.butApp.Enabled = true;
this.buttonCancel.Enabled = true;
MessageBox.Show("密码成功,请记住新密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
FormAccess.selfPassword = this.textBoxNewPassword.Text ;
this.textBoxOldPassword.Text = "";
this.textBoxNewPassword.Text = "";
this.textBoxNewPasswordAffirm.Text = "";
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -