using SSWMS.Common; using System; using System.Windows; using System.Windows.Controls; namespace SSWMS.Client { /// /// Password.xaml 的交互逻辑 /// public partial class Password : Window { private string _USER_CODE; /// /// 构造函数 /// public Password(string USER_CODE) { InitializeComponent(); this._USER_CODE = USER_CODE; Window_Loaded(null, null); } /// /// 加载窗体 /// private void Window_Loaded(object sender, RoutedEventArgs e) { this.txtUserCode.Text = this._USER_CODE; this.txtUserCode.IsEnabled = false; this.txtOldPwd.Focus(); } /// /// 按钮事件 /// private void WrapPanel_Click(object sender, RoutedEventArgs e) { Button btn = e.OriginalSource as Button; if (btn != null) { switch (btn.Name) { case "btnOK": this.SavePwd(); break; case "btnCancel": this.Close(); break; } } } /// /// 修改密码 /// private void SavePwd() { if (string.IsNullOrEmpty(this.txtOldPwd.Password)) { this.txtOldPwd.Focus(); MessageDialog.ShowException("请填写旧密码!"); return; } if (string.IsNullOrEmpty(this.txtNewPwd.Password.ToString())) { this.txtNewPwd.Focus(); MessageDialog.ShowException("请填写新密码!"); return; } if (string.IsNullOrEmpty(this.txtConfirmPwd.Password.ToString())) { this.txtConfirmPwd.Focus(); MessageDialog.ShowException("请填写确认密码!"); return; } if (this.txtNewPwd.Password != this.txtConfirmPwd.Password) { this.txtConfirmPwd.Focus(); MessageDialog.ShowException("新密码和确认密码不一致!"); return; } string sResult = string.Empty; bool bResult = true; try { bResult = WCFChannel._I_SystemService.ChangePassword(this.txtUserCode.Text, this.txtOldPwd.Password, this.txtNewPwd.Password, out sResult); this.txtOldPwd.Focus(); this.DialogResult = bResult; } catch (Exception ex) { bResult = false; sResult = ex.Message; } //判断结果 if (bResult) { this.Close(); } MessageDialog.ShowResult(bResult, sResult); } } }