F_SYS_0210.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_SYS_0209.cs
  5. * 2.功能描述:修改密码页面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/08/27 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Reflection;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.Library;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client
  20. {
  21. /// <summary>
  22. /// 修改密码页面
  23. /// </summary>
  24. public partial class F_SYS_0210 : FormBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_SYS_0210 _instance;
  29. #endregion
  30. #region 构造函数
  31. /// <summary>
  32. /// 构造函数
  33. /// </summary>
  34. private F_SYS_0210()
  35. {
  36. InitializeComponent();
  37. this.SetFromTitleInfo();
  38. }
  39. #endregion
  40. #region 单例模式
  41. /// <summary>
  42. /// 单例模式,防止重复创建窗体
  43. /// </summary>
  44. public static F_SYS_0210 Instance
  45. {
  46. get
  47. {
  48. if (_instance == null)
  49. {
  50. _instance = new F_SYS_0210();
  51. }
  52. return _instance;
  53. }
  54. }
  55. #endregion
  56. #region 事件处理
  57. /// <summary>
  58. /// 窗体加载事件
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. private void F_SYS_0209_Load(object sender, EventArgs e)
  63. {
  64. try
  65. {
  66. FormPermissionManager.FormPermissionControl(this.Name, this,
  67. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  68. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  69. }
  70. catch (Exception ex)
  71. {
  72. // 对异常进行共通处理
  73. ExceptionManager.HandleEventException(this.ToString(),
  74. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  75. }
  76. }
  77. /// <summary>
  78. /// 保存按钮
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void btnSave_Click(object sender, EventArgs e)
  83. {
  84. try
  85. {
  86. if (this.CheckPassWord())
  87. {
  88. string userCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  89. string userName = LogInUserInfo.CurrentUser.CurrentUserEntity.UserName;
  90. string passWord = this.txtPassword.Text.Trim();
  91. string returenPassWord = (string)DoAsync(new BaseAsyncMethod(() =>
  92. {
  93. return SystemModuleProxy.Service.SaveUserPassWord(passWord, userCode, userName);
  94. }));
  95. // 修改成功
  96. if (!string.IsNullOrEmpty(returenPassWord))
  97. {
  98. LogInUserInfo.CurrentUser.SetUserInfoPassWord(returenPassWord);
  99. ProxySettings.LoginUserInfo.Password = returenPassWord;
  100. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "密码", "修改"), this.Text,
  101. MessageBoxButtons.OK, MessageBoxIcon.Information);
  102. this.Close();
  103. }
  104. else
  105. {
  106. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "密码", "修改"), this.Text,
  107. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  108. }
  109. }
  110. }
  111. catch (Exception ex)
  112. {
  113. // 对异常进行共通处理
  114. ExceptionManager.HandleEventException(this.ToString(),
  115. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  116. }
  117. }
  118. /// <summary>
  119. /// 取消按钮
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void btnCancel_Click(object sender, EventArgs e)
  124. {
  125. this.Close();
  126. }
  127. /// <summary>
  128. /// 关闭窗体
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. private void F_SYS_0209_FormClosed(object sender, FormClosedEventArgs e)
  133. {
  134. _instance = null;
  135. }
  136. #endregion
  137. #region 私有方法
  138. /// <summary>
  139. /// 设置窗体按钮的文本信息
  140. /// </summary>
  141. private void SetFromTitleInfo()
  142. {
  143. // 窗口标题
  144. this.Text = FormTitles.F_SYS_0210;
  145. // 设置窗口按钮文本
  146. this.btnSave.Text = ButtonText.BTN_SAVE;
  147. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  148. }
  149. /// <summary>
  150. /// 验证密码
  151. /// </summary>
  152. /// <returns></returns>
  153. private bool CheckPassWord()
  154. {
  155. string strPassword = this.txtPassword.Text.Trim();
  156. string strPasswordCheck = this.txtPasswordCheck.Text.Trim();
  157. string strOldPassword = this.txtOldPassword.Text.Trim();
  158. // 判断原密码是否为空,如果为空提示
  159. if (string.IsNullOrEmpty(strOldPassword))
  160. {
  161. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "原密码"), this.Text,
  162. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  163. this.txtOldPassword.Focus();
  164. return false;
  165. }
  166. // 判断原密码是否正确,不正确给提示
  167. if (!LogInUserInfo.CurrentUser.CurrentUserEntity.Password.ToUpper().Equals(Encryption.GetMD5String(strOldPassword)))
  168. {
  169. MessageBox.Show(string.Format(Messages.MSG_CMN_W003, "原密码"), this.Text,
  170. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  171. this.txtOldPassword.Clear();
  172. this.txtOldPassword.Focus();
  173. return false;
  174. }
  175. // 判断新密码是否为空,如果为空提示
  176. if (string.IsNullOrEmpty(strPassword))
  177. {
  178. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "新密码"), this.Text,
  179. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  180. this.txtPassword.Focus();
  181. return false;
  182. }
  183. // 判断确认密码是否为空,如果为空提示
  184. if (string.IsNullOrEmpty(strPasswordCheck))
  185. {
  186. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "确认密码"), this.Text,
  187. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  188. this.txtPasswordCheck.Focus();
  189. return false;
  190. }
  191. // 判断两次输入的密码是否一致,不一致提示
  192. if (!strPasswordCheck.Equals(strPassword))
  193. {
  194. MessageBox.Show(Messages.MSG_SYS_W021, this.Text,
  195. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  196. this.txtPassword.Clear();
  197. this.txtPasswordCheck.Clear();
  198. this.txtPassword.Focus();
  199. return false;
  200. }
  201. return true;
  202. }
  203. #endregion
  204. }
  205. }