F_MST_0201.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0201.cs
  5. * 2.功能描述:用户管理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.SystemModule
  22. {
  23. /// <summary>
  24. /// 用户管理
  25. /// </summary>
  26. public partial class F_MST_0201 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 单例模式
  30. private static F_MST_0201 _instance;
  31. // 最后选择行
  32. private int _selecedRow;
  33. // 用户管理实体类
  34. private SUserEntity _userInfo;
  35. #endregion
  36. #region 单例模式
  37. /// <summary>
  38. /// 单例模式,防止重复创建窗体
  39. /// </summary>
  40. public static F_MST_0201 Instance
  41. {
  42. get
  43. {
  44. if (_instance == null)
  45. {
  46. _instance = new F_MST_0201();
  47. }
  48. return _instance;
  49. }
  50. }
  51. #endregion
  52. #region 构造函数
  53. public F_MST_0201()
  54. {
  55. InitializeComponent();
  56. this.Text = FormTitles.F_MST_0201;
  57. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  58. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  59. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  60. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  61. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  62. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  63. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  64. this.tsbtnResetPassword.Text = ButtonText.TSBTN_RESETPASSWORD;
  65. this.tsbtnUnlock.Text = ButtonText.TSBTN_UNLOCK;
  66. this.tsbtnFunctionRight.Text = ButtonText.TSBTN_FUNCTIONRIGHT;
  67. this.tsbtnPurviewRight.Text = ButtonText.TSBTN_PURVIEWRIGHT;
  68. this.tsbPrintUserCode.Text = ButtonText.TSBTN_PRINTUSERCODE;
  69. }
  70. #endregion
  71. #region 事件
  72. /// <summary>
  73. /// 窗体加载事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void FrmUser_Load(object sender, EventArgs e)
  78. {
  79. try
  80. {
  81. //加载权限
  82. //FormPermissionManager.FormPermissionControl(this.Name, this,
  83. // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  84. // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  85. // 设置表格不自动创建列
  86. this.dgvUser.AutoGenerateColumns = false;
  87. this.SetToolStripButtonEnable();
  88. this.scbOrganization.EditReadOnly = true;
  89. }
  90. catch (Exception ex)
  91. {
  92. // 对异常进行共通处理
  93. ExceptionManager.HandleEventException(this.ToString(),
  94. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  95. }
  96. }
  97. /// <summary>
  98. /// 用户范围权限
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void tsbtnRight_Click(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106. if (this.dgvUser.CurrentRow != null)
  107. {
  108. string UserCode = this.dgvUser.CurrentRow.Cells["UserCode"].Value.ToString();
  109. F_MST_0204 frmMST0204 = new F_MST_0204(Convert.ToInt32(this.dgvUser.CurrentRow.Cells["UserID"].Value), UserCode);
  110. DialogResult dialogResult = frmMST0204.ShowDialog();
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. /// <summary>
  121. /// 搜索按钮事件
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void btnSearch_Click(object sender, EventArgs e)
  126. {
  127. try
  128. {
  129. // 根据页面设定用户实体值
  130. this.GetUserEntityFromLayout();
  131. // 记录当前选中行
  132. int selectRowIndex = this._selecedRow;
  133. // 异步处理
  134. this.btnSearch.Enabled = false;
  135. this.btnClearCondition.Enabled = false;
  136. DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.SearchUserData));
  137. this.btnSearch.Enabled = true;
  138. this.btnClearCondition.Enabled = true;
  139. this.scbOrganization.EditReadOnly = true;
  140. if (userDataSet != null)
  141. {
  142. base.DataSource = (DataSet)userDataSet;
  143. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  144. {
  145. this.dgvUser.DataSource = this.DataSource.Tables[0];
  146. //foreach (DataGridViewRow gvrFor in this.dgvUser.Rows)
  147. //{
  148. // string ValueStr = "";
  149. // string ValueNum = gvrFor.Cells["ValueFlag"].Value.ToString();
  150. // switch (ValueNum)
  151. // {
  152. // case "1":
  153. // ValueStr = "正常";
  154. // break;
  155. // case "0":
  156. // ValueStr = "停用";
  157. // break;
  158. // default:
  159. // break;
  160. // }
  161. // gvrFor.Cells["checkValueFlag"].Value = ValueStr;
  162. // string StateStr = gvrFor.Cells["IsLocked"].Value.ToString();
  163. // if (StateStr == "1")
  164. // {
  165. // gvrFor.Cells["IsLocked"].Value = "锁死";
  166. // }
  167. // else
  168. // {
  169. // gvrFor.Cells["IsLocked"].Value = "正常";
  170. // }
  171. //}
  172. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  173. {
  174. // 提示未查找到数据
  175. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  176. MessageBoxButtons.OK, MessageBoxIcon.Information);
  177. }
  178. else
  179. {
  180. if (selectRowIndex >= Constant.INT_IS_ZERO)
  181. {
  182. if (selectRowIndex >= userDataSet.Tables[0].Rows.Count)
  183. {
  184. this.dgvUser.Rows[this.dgvUser.Rows.Count - 1].Selected = true;
  185. this.dgvUser.CurrentCell = this.dgvUser.Rows[this.dgvUser.Rows.Count - 1].Cells["UserCode"];
  186. }
  187. else
  188. {
  189. this.dgvUser.Rows[selectRowIndex].Selected = true;
  190. this.dgvUser.CurrentCell = this.dgvUser.Rows[selectRowIndex].Cells["UserCode"];
  191. }
  192. }
  193. }
  194. }
  195. }
  196. this.SetToolStripButtonEnable();
  197. }
  198. catch (Exception ex)
  199. {
  200. this.btnSearch.Enabled = true;
  201. this.btnClearCondition.Enabled = true;
  202. // 对异常进行共通处理
  203. ExceptionManager.HandleEventException(this.ToString(),
  204. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  205. }
  206. }
  207. /// <summary>
  208. /// 清空输入查询寻条件
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. private void btnClear_Click(object sender, EventArgs e)
  213. {
  214. this.txtUserCode.Clear();
  215. this.txtUserName.Clear();
  216. this.scbOrganization.ClearValue();
  217. this.txtMAC.Clear();
  218. this.txtRemarks.Clear();
  219. this.chkVYes.Checked = true;
  220. this.chkVNo.Checked = true;
  221. this.chkLYes.Checked = true;
  222. this.chkLNo.Checked = true;
  223. }
  224. /// <summary>
  225. /// 设置按钮的状态
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void dgvUser_SelectionChanged(object sender, EventArgs e)
  230. {
  231. if (dgvUser.CurrentCell == null)
  232. {
  233. this.tsbtnEdit.Enabled = false;
  234. this.tsbtnResetPassword.Enabled = false;
  235. this.tsbtnUnlock.Enabled = false;
  236. this.tsbtnPurviewRight.Enabled = false;
  237. this.tsbtnFunctionRight.Enabled = false;
  238. }
  239. else
  240. {
  241. string ValueFlag = this.dgvUser.Rows[dgvUser.CurrentCell.RowIndex].Cells["IsLocked"].Value.ToString();
  242. if (ValueFlag == "锁死" || ValueFlag == "1")
  243. {
  244. this.tsbtnUnlock.Enabled = true;
  245. }
  246. else
  247. {
  248. this.tsbtnUnlock.Enabled = false;
  249. }
  250. this.tsbtnEdit.Enabled = true;
  251. this.tsbtnResetPassword.Enabled = true;
  252. this.tsbtnPurviewRight.Enabled = true;
  253. this.tsbtnFunctionRight.Enabled = true;
  254. }
  255. }
  256. /// <summary>
  257. /// 选中行发生改变时 有效停用相互切换
  258. /// </summary>
  259. /// <param name="sender"></param>
  260. /// <param name="e"></param>
  261. private void dgvUser_CellEnter(object sender, DataGridViewCellEventArgs e)
  262. {
  263. this.SetToolStripButtonEnable();
  264. if (dgvUser.Rows.Count > Constant.INT_IS_ZERO)
  265. {
  266. this._selecedRow = this.dgvUser.CurrentCell.RowIndex;
  267. }
  268. }
  269. /// <summary>
  270. /// KeyDown事件
  271. /// </summary>
  272. /// <param name="sender"></param>
  273. /// <param name="e"></param>
  274. private void dgvUser_KeyDown(object sender, KeyEventArgs e)
  275. {
  276. try
  277. {
  278. // 拷贝
  279. if (e.KeyData == (Keys.Control | Keys.C))
  280. {
  281. if (dgvUser.CurrentRow != null
  282. && !string.IsNullOrEmpty(dgvUser.CurrentRow.Cells[dgvUser.CurrentCell.ColumnIndex].EditedFormattedValue + string.Empty))
  283. {
  284. try
  285. {
  286. Clipboard.SetText(dgvUser.CurrentRow.Cells[dgvUser.CurrentCell.ColumnIndex].EditedFormattedValue + string.Empty);
  287. }
  288. catch
  289. {
  290. }
  291. }
  292. }
  293. }
  294. catch (Exception ex)
  295. {
  296. // 对异常进行共通处理
  297. ExceptionManager.HandleEventException(this.ToString(),
  298. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  299. }
  300. }
  301. /// <summary>
  302. /// 双击进入编辑页面
  303. /// </summary>
  304. /// <param name="sender"></param>
  305. /// <param name="e"></param>
  306. private void dgvUser_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  307. {
  308. if (-Constant.INT_IS_ONE < e.RowIndex && -Constant.INT_IS_ONE < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  309. {
  310. this.tsbtnEditUser_Click(sender, e);
  311. }
  312. }
  313. /// <summary>
  314. /// 添加用户
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void tsbtnAddUser_Click(object sender, EventArgs e)
  319. {
  320. try
  321. {
  322. F_MST_0202 frmMST0202 = new F_MST_0202(Constant.FormMode.Add);
  323. DialogResult dialogResult = frmMST0202.ShowDialog();
  324. // 重新加载GridView
  325. if (dialogResult == DialogResult.OK)
  326. {
  327. List<int> userIDList = frmMST0202.UserIDList;
  328. int[] iDList = new int[userIDList.Count];
  329. for (int i = 0; i < userIDList.Count; i++)
  330. {
  331. iDList[i] = userIDList[i];
  332. }
  333. SUserEntity userInfos = new SUserEntity();
  334. DataSet userDataSet = SystemModuleProxy.Service.SearchUserData(userInfos);
  335. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  336. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  337. {
  338. this.dgvUser.DataSource = null;
  339. this.dgvUser.DataSource = userDataSet.Tables[0];
  340. // 设置ToolStripButton按钮状态
  341. this.SetToolStripButtonEnable();
  342. this.dgvUser.ReadOnly = true;
  343. }
  344. }
  345. }
  346. catch (Exception ex)
  347. {
  348. // 对异常进行共通处理
  349. ExceptionManager.HandleEventException(this.ToString(),
  350. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  351. }
  352. }
  353. /// <summary>
  354. /// 范围权限按钮事件
  355. /// </summary>
  356. /// <param name="sender"></param>
  357. /// <param name="e"></param>
  358. private void tsbtnFunctionRight_Click(object sender, EventArgs e)
  359. {
  360. try
  361. {
  362. if (this.dgvUser.CurrentRow != null)
  363. {
  364. int intUserID = Convert.ToInt32(this.dgvUser.CurrentRow.Cells["UserID"].Value);
  365. string UserCode = this.dgvUser.CurrentRow.Cells["UserCode"].Value.ToString();
  366. F_MST_0203 frmMST0203 = new F_MST_0203(intUserID, UserCode);
  367. frmMST0203.ShowDialog();
  368. }
  369. }
  370. catch (Exception ex)
  371. {
  372. // 对异常进行共通处理
  373. ExceptionManager.HandleEventException(this.ToString(),
  374. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  375. }
  376. }
  377. /// <summary>
  378. /// 窗体关闭事件
  379. /// </summary>
  380. /// <param name="sender"></param>
  381. /// <param name="e"></param>
  382. private void F_MST_0203_FormClosed(object sender, FormClosedEventArgs e)
  383. {
  384. _instance = null;
  385. }
  386. /// <summary>
  387. /// 单击编辑按钮跳转页面
  388. /// </summary>
  389. /// <param name="sender"></param>
  390. /// <param name="e"></param>
  391. private void tsbtnEditUser_Click(object sender, EventArgs e)
  392. {
  393. try
  394. {
  395. if (this.dgvUser.CurrentRow != null)
  396. {
  397. F_MST_0202 frmMST0202 = new F_MST_0202(Constant.FormMode.Edit);
  398. frmMST0202.UserID = Convert.ToInt32(this.dgvUser.CurrentRow.Cells["UserID"].Value);
  399. frmMST0202.UserCode = this.dgvUser.CurrentRow.Cells["UserCode"].Value.ToString();
  400. DialogResult dialogResult = frmMST0202.ShowDialog();
  401. if (dialogResult.Equals(DialogResult.OK))
  402. {
  403. // 重新加载GridView
  404. this.btnSearch_Click(sender, e);
  405. }
  406. }
  407. }
  408. catch (Exception ex)
  409. {
  410. // 对异常进行共通处理
  411. ExceptionManager.HandleEventException(this.ToString(),
  412. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  413. }
  414. }
  415. /// <summary>
  416. /// 复制用户
  417. /// </summary>
  418. /// <param name="sender"></param>
  419. /// <param name="e"></param>
  420. private void tsbtnCopy_Click(object sender, EventArgs e)
  421. {
  422. try
  423. {
  424. if (this.dgvUser.CurrentRow == null)
  425. {
  426. return;
  427. }
  428. F_MST_0202 frmMST0202 = new F_MST_0202(Constant.FormMode.CopyAndAdd);
  429. frmMST0202.UserID = Convert.ToInt32(this.dgvUser.CurrentRow.Cells["UserID"].Value);
  430. frmMST0202.UserCode = this.dgvUser.CurrentRow.Cells["UserCode"].Value.ToString();
  431. DialogResult dialogResult = frmMST0202.ShowDialog();
  432. // 重新加载GridView
  433. if (dialogResult == DialogResult.OK)
  434. {
  435. List<int> userIDList = frmMST0202.UserIDList;
  436. int[] iDList = new int[userIDList.Count];
  437. for (int i = 0; i < userIDList.Count; i++)
  438. {
  439. iDList[i] = userIDList[i];
  440. }
  441. SUserEntity userInfos = new SUserEntity();
  442. DataSet userDataSet = SystemModuleProxy.Service.SearchUserData(userInfos);
  443. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  444. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  445. {
  446. this.dgvUser.DataSource = null;
  447. this.dgvUser.DataSource = userDataSet.Tables[0];
  448. // 设置ToolStripButton按钮状态
  449. this.SetToolStripButtonEnable();
  450. this.dgvUser.ReadOnly = true;
  451. }
  452. }
  453. }
  454. catch (Exception ex)
  455. {
  456. // 对异常进行共通处理
  457. ExceptionManager.HandleEventException(this.ToString(),
  458. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  459. }
  460. }
  461. /// <summary>
  462. /// 重置密码按钮事件
  463. /// </summary>
  464. /// <param name="sender"></param>
  465. /// <param name="e"></param>
  466. private void tsbtnResetPassword_Click(object sender, EventArgs e)
  467. {
  468. try
  469. {
  470. if (this.dgvUser.CurrentRow != null)
  471. {
  472. // 提示用户确认重置密码
  473. DialogResult msgBoxResult = MessageBox.Show(
  474. string.Format(Messages.MSG_CMN_Q002, "该用户", "重置密码"), this.Text,
  475. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  476. if (msgBoxResult == DialogResult.Yes)
  477. {
  478. // 用户默认密码
  479. DataSet ds = (DataSet)CommonModuleProxy.Service.GetSysSettingBySettingType("S_CMN_0001");
  480. string pwd = "dongke";
  481. if (ds.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  482. {
  483. pwd = ds.Tables[0].Rows[0]["SETTINGVALUE"].ToString();
  484. }
  485. string userCode = this.dgvUser.CurrentRow.Cells["UserCode"].Value.ToString();
  486. string userName = this.dgvUser.CurrentRow.Cells["UserName"].Value.ToString();
  487. string passWord = pwd;
  488. string returenPassWord = SystemModuleProxy.Service.SaveUserPassWord(passWord, userCode, userName);
  489. this.dgvUser.ReadOnly = true;
  490. this.scbOrganization.EditReadOnly = true;
  491. //修改成功
  492. if (!string.IsNullOrEmpty(returenPassWord))
  493. {
  494. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "用户管理", "重置密码"),
  495. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  496. }
  497. else
  498. {
  499. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "用户管理", "重置密码"),
  500. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  501. }
  502. }
  503. }
  504. }
  505. catch (Exception ex)
  506. {
  507. // 对异常进行共通处理
  508. ExceptionManager.HandleEventException(this.ToString(),
  509. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  510. }
  511. }
  512. /// <summary>
  513. /// 自动适应列宽事件
  514. /// </summary>
  515. /// <param name="sender"></param>
  516. /// <param name="e"></param>
  517. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  518. {
  519. this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  520. }
  521. /// <summary>
  522. /// 窗体关闭事件
  523. /// </summary>
  524. /// <param name="sender"></param>
  525. /// <param name="e"></param>
  526. private void tsbtnClose_Click(object sender, EventArgs e)
  527. {
  528. this.Close();
  529. }
  530. /// <summary>
  531. /// 解锁按钮事件
  532. /// </summary>
  533. /// <param name="sender"></param>
  534. /// <param name="e"></param>
  535. private void tsbtnUnlock_Click(object sender, EventArgs e)
  536. {
  537. try
  538. {
  539. // 提示用户确认解锁
  540. DialogResult msgBoxResult = MessageBox.Show(
  541. string.Format(Messages.MSG_CMN_Q002, "该用户", "解锁"), this.Text,
  542. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  543. if (msgBoxResult == DialogResult.Yes)
  544. {
  545. int result = (int)DoAsync(new AsyncMethod(this.UnlockUserStatus));//解锁按钮方法
  546. if (result > Constant.INT_IS_ZERO)
  547. {
  548. // 提示信息
  549. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "用户管理", "解锁"),
  550. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  551. // 重新加载数据
  552. this.btnSearch_Click(sender, e);
  553. }
  554. else
  555. {
  556. // 提示信息
  557. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "用户管理", "解锁"),
  558. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  559. }
  560. }
  561. }
  562. catch (Exception ex)
  563. {
  564. // 对异常进行共通处理
  565. ExceptionManager.HandleEventException(this.ToString(),
  566. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  567. }
  568. }
  569. /// <summary>
  570. /// 数据表格鼠标点击事件
  571. /// </summary>
  572. /// <param name="sender"></param>
  573. /// <param name="e"></param>
  574. private void dgvUser_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  575. {
  576. //if (e.RowIndex != -Constant.INT_IS_ONE)
  577. //{
  578. // string ValueFlag = this.dgvUser.Rows[e.RowIndex].Cells["IsLocked"].Value.ToString();
  579. // if (ValueFlag == "锁死" || ValueFlag == "1")
  580. // {
  581. // this.tsbtnUnlock.Enabled = true;
  582. // }
  583. // else
  584. // {
  585. // this.tsbtnUnlock.Enabled = false;
  586. // }
  587. //}
  588. }
  589. /// <summary>
  590. /// 打印工号事件
  591. /// </summary>
  592. /// <param name="sender"></param>
  593. /// <param name="e"></param>
  594. private void tsbPrintCode_Click(object sender, EventArgs e)
  595. {
  596. try
  597. {
  598. if (this.dgvUser.Rows.Count == Constant.INT_IS_ZERO)
  599. {
  600. // 提示信息
  601. MessageBox.Show(Messages.MSG_CMN_W023,
  602. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  603. return;
  604. }
  605. List<string> codeList = new List<string>();
  606. foreach (DataGridViewRow row in this.dgvUser.Rows)
  607. {
  608. codeList.Add(row.Cells["UserCode"].Value.ToString());
  609. }
  610. F_MST_0205 fMST0205 = new F_MST_0205();
  611. fMST0205.BarcodeList = codeList;
  612. fMST0205.ShowDialog();
  613. }
  614. catch (Exception ex)
  615. {
  616. // 对异常进行共通处理
  617. ExceptionManager.HandleEventException(this.ToString(),
  618. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  619. }
  620. }
  621. #endregion
  622. #region 私有方法
  623. /// <summary>
  624. /// 获取用户列表
  625. /// </summary>
  626. /// <returns></returns>
  627. private DataSet SearchUserData()
  628. {
  629. try
  630. {
  631. return SystemModuleProxy.Service.SearchUserData(this._userInfo);
  632. }
  633. catch (Exception ex)
  634. {
  635. throw ex;
  636. }
  637. }
  638. /// <summary>
  639. /// 获取输入的用户信息
  640. /// </summary>
  641. /// <returns></returns>
  642. private SUserEntity GetUserEntityFromLayout()
  643. {
  644. this._userInfo = new SUserEntity();
  645. // 用户编码
  646. this._userInfo.UserCode = this.txtUserCode.Text.Trim();
  647. // 用户姓名
  648. this._userInfo.UserName = this.txtUserName.Text.Trim();
  649. // 所属部门
  650. this._userInfo.OrganizationCode = this.scbOrganization.SearchedValue+"";
  651. // 所属部门
  652. this._userInfo.OrganizationID = scbOrganization.SearchedPKMember;
  653. // MAC
  654. this._userInfo.LimitMAC = this.txtMAC.Text.Trim();
  655. // 备注
  656. this._userInfo.Remarks = this.txtRemarks.Text.Trim();
  657. if (this.chkVYes.Checked != this.chkVNo.Checked)
  658. {
  659. if (this.chkVNo.Checked)
  660. {
  661. this._userInfo.IsValueFlag = "0";
  662. }
  663. else if (this.chkVYes.Checked)
  664. {
  665. this._userInfo.IsValueFlag = "1";
  666. }
  667. }
  668. if (this.chkLYes.Checked != this.chkLNo.Checked)
  669. {
  670. if (this.chkLNo.Checked)
  671. {
  672. this._userInfo.IsLocked = "1";
  673. }
  674. else if (this.chkLYes.Checked)
  675. {
  676. this._userInfo.IsLocked = "0";
  677. }
  678. }
  679. return _userInfo;
  680. }
  681. /// <summary>
  682. /// 设置工具按钮的可用状态
  683. /// </summary>
  684. private void SetToolStripButtonEnable()
  685. {
  686. if (this.dgvUser.CurrentCell != null)
  687. {
  688. this.tsbtnUnlock.Enabled = true;
  689. this.tsbtnResetPassword.Enabled = true;
  690. this.tsbtnEdit.Enabled = true;
  691. this.tsbtnCopy.Enabled = true;
  692. this.tsbtnPurviewRight.Enabled = true;
  693. this.tsbtnFunctionRight.Enabled = true;
  694. //int valueFlag = Convert.ToInt32(dgvUser.CurrentRow.Cells["valueFlag"].Value.ToString());
  695. string valueFlag = this.dgvUser.Rows[dgvUser.CurrentCell.RowIndex].Cells["IsLocked"].Value.ToString();
  696. if (valueFlag == "1")
  697. {
  698. this.tsbtnUnlock.Enabled = true;
  699. }
  700. else
  701. {
  702. this.tsbtnUnlock.Enabled = false;
  703. }
  704. // admin用户不能分配权限
  705. //if ("ADMIN".Equals(dgvUser.CurrentRow.Cells["UserCode"].Value.ToString().ToUpper()))
  706. //{
  707. // this.tsbtnFunctionRight.Enabled = false;
  708. //}
  709. }
  710. else
  711. {
  712. this.tsbtnUnlock.Enabled = false;
  713. this.tsbtnResetPassword.Enabled = false;
  714. this.tsbtnEdit.Enabled = false;
  715. this.tsbtnCopy.Enabled = false;
  716. this.tsbtnPurviewRight.Enabled = false;
  717. this.tsbtnFunctionRight.Enabled = false;
  718. }
  719. }
  720. /// <summary>
  721. /// 保存组织机构
  722. /// </summary>
  723. /// <returns>影响的行数</returns>
  724. private object UnlockUserStatus()
  725. {
  726. try
  727. {
  728. return SystemModuleProxy.Service.UnlockUserStatus(Convert.ToInt32(this.dgvUser.CurrentRow.Cells["UserID"].Value));
  729. }
  730. catch (Exception ex)
  731. {
  732. throw ex;
  733. }
  734. }
  735. #endregion
  736. }
  737. }