You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
319 lines
9.4 KiB
C#
319 lines
9.4 KiB
C#
using POSV.Card;
|
|
using POSV.Component;
|
|
using POSV.Entity;
|
|
using POSV.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace POSV.Shift
|
|
{
|
|
public partial class EditUserPasswdForm : BusinessForm
|
|
{
|
|
|
|
public EditUserPasswdForm()
|
|
{
|
|
InitializeComponent();
|
|
this.controlBox.Text = "收银员修改密码";
|
|
|
|
this.controlBox.BackColor = Color.DarkRed;
|
|
|
|
this.controlBox.ShowApplicationVersion = false;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (this.DesignMode) return;
|
|
|
|
this.Focus();
|
|
this.numericTextBox1.Focus();
|
|
|
|
this.ActiveControl = this.numericTextBox1;
|
|
}
|
|
|
|
private void OnCloseTouchClick(object sender, EventArgs e)
|
|
{
|
|
//先关闭父窗体
|
|
if (this.Owner != null)
|
|
{
|
|
this.Owner.Close();
|
|
}
|
|
//再关闭当前窗体
|
|
this.Close();
|
|
}
|
|
|
|
private void OnTouchClick(object sender, Component.TouchEventArgs e)
|
|
{
|
|
switch (e.Value)
|
|
{
|
|
case "clear":
|
|
{
|
|
//如果当前焦点控件是输入框
|
|
if (this.ActiveControl is NumericTextBox)
|
|
{
|
|
var activeControl = this.ActiveControl as NumericTextBox;
|
|
activeControl.Text = string.Empty;
|
|
}
|
|
}
|
|
break;
|
|
case "close":
|
|
{
|
|
this.OnCloseTouchClick(e,EventArgs.Empty);
|
|
}
|
|
break;
|
|
case "accept":
|
|
{
|
|
var valid = InputOkVerify();
|
|
if (valid)
|
|
{
|
|
|
|
this.UserPwdEdit();
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
InputSimulatorUtils.SendKey(KeyCodes.Map[e.Value]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void UserPwdEdit()
|
|
{
|
|
bool isSuccess = false;
|
|
|
|
try
|
|
{
|
|
var request = new WorkerUpdatePwdRequest();
|
|
request.StoreId = Global.Instance.Authc.StoreId;
|
|
request.PosNo = Global.Instance.Authc.PosNo;
|
|
request.WorkerId = Global.Instance.Worker.Id;
|
|
request.WorkerNo = Global.Instance.Worker.No;
|
|
request.Passwd = DesUtils.Encrypt(this.numericTextBox1.Text);
|
|
request.NewPasswd = DesUtils.Encrypt(this.numericTextBox3.Text);
|
|
|
|
var response = WorkerUtils.WorkerUpdatePwd(request);
|
|
//成功
|
|
if (response.Item1)
|
|
{
|
|
isSuccess = true;
|
|
|
|
ShowMessage(this.lblInfo, response.Item2, false);
|
|
}
|
|
else
|
|
{
|
|
isSuccess = false;
|
|
|
|
ShowMessage(this.lblInfo, response.Item2, true);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
isSuccess = false;
|
|
|
|
ShowMessage(this.lblInfo, "密码修改失败了", true);
|
|
|
|
LOGGER.Error(ex, "密码修改异常");
|
|
}
|
|
finally
|
|
{
|
|
if (isSuccess)
|
|
{
|
|
string newPasswd = BCrypt.HashPassword(this.numericTextBox3.Text);
|
|
//更新本地密码
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
{
|
|
using (var trans = db.GetTransaction())
|
|
{
|
|
db.Execute("update pos_worker set [passwd] = @0 where [no] = @1", newPasswd, Global.Instance.Worker.No);
|
|
|
|
trans.Complete();
|
|
}
|
|
}
|
|
//更新中的当前操作员密码
|
|
Global.Instance.Worker.Passwd = newPasswd;
|
|
|
|
this.numericTextBox1.Text = "";
|
|
this.numericTextBox2.Text = "";
|
|
this.numericTextBox3.Text = "";
|
|
|
|
this.numericTextBox1.Focus();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 输入是否验证通过
|
|
/// </summary>
|
|
private bool InputOkVerify()
|
|
{
|
|
if (string.IsNullOrEmpty(this.numericTextBox1.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请输入旧密码", true);
|
|
|
|
this.numericTextBox1.SelectAll();
|
|
this.numericTextBox1.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (this.numericTextBox1.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox1.SelectAll();
|
|
this.numericTextBox1.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(this.numericTextBox2.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请输入新密码", true);
|
|
|
|
this.numericTextBox2.SelectAll();
|
|
this.numericTextBox2.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (this.numericTextBox2.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox2.SelectAll();
|
|
this.numericTextBox2.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(this.numericTextBox3.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请再次输入新密码", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (this.numericTextBox3.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
if (!(this.numericTextBox3.Text.Trim().Equals(this.numericTextBox2.Text.Trim())))
|
|
{
|
|
ShowMessage(this.lblInfo, "两次输入的密码不一致", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnOrgPwdEnterClick(object sender, EnterEventArg e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.numericTextBox1.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请输入旧密码", true);
|
|
|
|
this.numericTextBox1.SelectAll();
|
|
this.numericTextBox1.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
if (this.numericTextBox1.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox1.SelectAll();
|
|
this.numericTextBox1.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
this.numericTextBox2.Focus();
|
|
this.numericTextBox2.SelectAll();
|
|
|
|
}
|
|
|
|
private void OnNewPwdEnterClick(object sender, EnterEventArg e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.numericTextBox2.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请输入新密码", true);
|
|
|
|
this.numericTextBox2.SelectAll();
|
|
this.numericTextBox2.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
if (this.numericTextBox2.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "新密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox2.SelectAll();
|
|
this.numericTextBox2.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
this.numericTextBox3.Focus();
|
|
this.numericTextBox3.SelectAll();
|
|
}
|
|
|
|
private void OnReNewPwdEnterClick(object sender, EnterEventArg e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.numericTextBox3.Text.Trim()))
|
|
{
|
|
ShowMessage(this.lblInfo, "请输入确认新密码", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
if (this.numericTextBox3.Text.Trim().Length != 6)
|
|
{
|
|
ShowMessage(this.lblInfo, "新密码长度必须为6位,请输入...", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
if (!(this.numericTextBox3.Text.Trim().Equals(this.numericTextBox2.Text.Trim())))
|
|
{
|
|
ShowMessage(this.lblInfo, "两次输入的密码不一致", true);
|
|
|
|
this.numericTextBox3.SelectAll();
|
|
this.numericTextBox3.Focus();
|
|
|
|
return;
|
|
}
|
|
|
|
UserPwdEdit();
|
|
}
|
|
}
|
|
}
|