using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using static Org.BouncyCastle.Math.EC.ECCurve; namespace GeBoShi.UI.User { public partial class ModifyPWFrm : Form { User _FatherUser; public ModifyPWFrm(User fatherUser) { InitializeComponent(); this.uiTitel1.ShowContrlBox(false, false, true); this.uiTitel1.FatherForm = this; _FatherUser = fatherUser; log1.Text = log2.Text = log3.Text = ""; //log1.Visible = log2.Visible = log3.Visible = false; } private void btnSave_Click(object sender, EventArgs e) { UserService service = new UserService(); try { string pw = this.txtPW.Text.Trim(); //pw = Utils.Util.GetMD5(pw); string newpw = this.txtNewPW.Text.Trim(); string newpw2 = this.txtNewPW2.Text.Trim(); if (newpw == "") { log2.Text = "请输入新密码!"; return; } else log2.Text = ""; if (newpw.Length < 3) { log2.Text = "新密码长度至少3位!"; return; } else log2.Text = ""; if (newpw2 != newpw) { log3.Text = "确认新密码输入不一致!"; return; } else log3.Text = ""; if (string.IsNullOrWhiteSpace(_FatherUser.Password)) _FatherUser.Password = ""; if (_FatherUser.Password != pw) { log1.Text = "旧密码错误!"; return; } else log1.Text = ""; if (!service.ModifyPw(_FatherUser.Id, (newpw))) throw new Exception("密码修改失败!"); MessageBox.Show("修改成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }