141 lines
4.4 KiB
C#
141 lines
4.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using AllBase;
|
|
using TemuKJD.BaseForms;
|
|
using Work;
|
|
|
|
namespace TemuKJD.UserForm
|
|
{
|
|
public partial class ResetPasswordForm : BaseForm
|
|
{
|
|
private Point mouseOffset;//记录鼠标指针的坐标
|
|
private bool isMouseDown;//记录鼠标左键是否按下
|
|
public delegate void delegateView();
|
|
public ResetPasswordForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void closePanel_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void panelEx2_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (isMouseDown)
|
|
{//获取鼠标的位置
|
|
Point mousePos = MousePosition;
|
|
mousePos.Offset(mouseOffset.X, mouseOffset.Y);
|
|
Location = mousePos;
|
|
}
|
|
}
|
|
|
|
private void panelEx2_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
mouseOffset = new Point(-e.X, -e.Y);
|
|
isMouseDown = true;
|
|
}
|
|
}
|
|
|
|
private void panelEx2_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
isMouseDown = false;
|
|
}
|
|
|
|
private void sendCodePanel_Click(object sender, EventArgs e)
|
|
{
|
|
string m = mobile.Text;
|
|
if (m.Length != 11)
|
|
{
|
|
BaseMsgForm.ShowInfo("请先输入正确的手机号码\r\n仅支持中国大陆手机号码\r\n请不要加0086", "提示");
|
|
return;
|
|
}
|
|
bool success;
|
|
string message = UserLogin.SendCode(m, out success);
|
|
if (!success)
|
|
{
|
|
BaseMsgForm.ShowError(message, "发送短信错误");
|
|
return;
|
|
}
|
|
BaseMsgForm.ShowInfo("短信发送成功,请不要重复点击", "提示");
|
|
sendCodePanel.Enabled = false;
|
|
new Thread(SetCodeEnable).Start();
|
|
}
|
|
|
|
public void SetCodeEnable()
|
|
{
|
|
Thread.Sleep(10 * 1000);
|
|
Invoke(new delegateView(SetCodeEnableGet));
|
|
}
|
|
public void SetCodeEnableGet()
|
|
{
|
|
sendCodePanel.Enabled = true;
|
|
|
|
}
|
|
|
|
private void mobile_TextChanged(object sender, EventArgs e)
|
|
{
|
|
mobile.Text = BaseRegex.GetMatchRegexString(mobile.Text, @"([\d]+)");
|
|
}
|
|
|
|
private void code_TextChanged(object sender, EventArgs e)
|
|
{
|
|
code.Text = BaseRegex.GetMatchRegexString(code.Text, @"([\d]+)");
|
|
}
|
|
|
|
private void regeditPanel_Click(object sender, EventArgs e)
|
|
{
|
|
if (mobile.Text.Length != 11)
|
|
{
|
|
BaseMsgForm.ShowInfo("请输入正确的手机号码", "提示");
|
|
mobile.Focus();
|
|
return;
|
|
}
|
|
if (code.Text.Length != 5)
|
|
{
|
|
BaseMsgForm.ShowInfo("请输入正确的验证码", "提示");
|
|
code.Focus();
|
|
return;
|
|
}
|
|
if (password1.Text.Length < 6)
|
|
{
|
|
BaseMsgForm.ShowInfo("请输入长度不小于6位的密码", "提示");
|
|
password1.Focus();
|
|
return;
|
|
}
|
|
if (password1.Text != password2.Text)
|
|
{
|
|
BaseMsgForm.ShowInfo("两次输入的密码不一致", "提示");
|
|
password1.Text = "";
|
|
password2.Text = "";
|
|
password1.Focus();
|
|
return;
|
|
}
|
|
UserLogin ul = new UserLogin();
|
|
string message;
|
|
bool ok = ul.ResetPassword(mobile.Text, code.Text, password1.Text, out message);
|
|
if (!ok)
|
|
{
|
|
BaseMsgForm.ShowError(message, "提交错误");
|
|
return;
|
|
}
|
|
BaseMsgForm.ShowInfo("恭喜你重置密码成功\r\n请牢记新密码", "重置成功");
|
|
Close();
|
|
}
|
|
|
|
private void ResetPasswordForm_Load(object sender, EventArgs e)
|
|
{
|
|
if (BaseClass.Ico != null)
|
|
Icon = BaseClass.Ico;
|
|
Text = "找回密码 " + BaseClass.ToolName;
|
|
if (BaseClass.LoginImage != null)
|
|
panelEx2.Style.BackgroundImage = BaseClass.LoginImage;
|
|
}
|
|
}
|
|
}
|