F_MST_0208.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0208.cs
  5. * 2.功能描述:用户管理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 孔赫 2024/06/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_0208 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 单例模式
  30. private static F_MST_0208 _instance;
  31. // 最后选择行
  32. private int _selecedRow;
  33. // 用户管理实体类
  34. private SUserEntity _userInfo;
  35. public enum ActionTypeEnum
  36. {
  37. /// <summary>
  38. /// pc登录
  39. /// </summary>
  40. pc登录 = 0,
  41. /// <summary>
  42. /// PC登出
  43. /// </summary>
  44. PC登出 = 1,
  45. /// <summary>
  46. /// 移动设备登录
  47. /// </summary>
  48. 移动设备登录 = 2,
  49. /// <summary>
  50. /// 移动设备登出
  51. /// </summary>
  52. 移动设备登出 = 3,
  53. /// <summary>
  54. /// PC登录MBC
  55. /// </summary>
  56. PC登录MBC = 4,
  57. /// <summary>
  58. /// PC登出MBC
  59. /// </summary>
  60. /// <param name=""></param>
  61. PC登出MBC = 5
  62. }
  63. #endregion
  64. #region 单例模式
  65. /// <summary>
  66. /// 单例模式,防止重复创建窗体
  67. /// </summary>
  68. public static F_MST_0208 Instance
  69. {
  70. get
  71. {
  72. if (_instance == null)
  73. {
  74. _instance = new F_MST_0208();
  75. }
  76. return _instance;
  77. }
  78. }
  79. #endregion
  80. #region 构造函数
  81. public F_MST_0208()
  82. {
  83. InitializeComponent();
  84. this.Text = FormTitles.F_MST_0208;
  85. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  86. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  87. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  88. DataTable dt = new DataTable();
  89. dt.Columns.Add("id", typeof(string));
  90. dt.Columns.Add("actiontype", typeof(string));
  91. DataRow dr = dt.NewRow();
  92. int d = 0;
  93. var type = typeof(ActionTypeEnum);
  94. foreach (string name in Enum.GetNames(type))
  95. {
  96. dr = dt.NewRow();
  97. dr[0] = (int)Enum.Parse(type, name);
  98. dr[1] = name;
  99. dt.Rows.Add(dr);
  100. d++;
  101. }
  102. cbActionType.DisplayMember = "actiontype";
  103. cbActionType.DataSource = dt;
  104. cbActionType.Text = "";
  105. }
  106. #endregion
  107. #region 事件
  108. /// <summary>
  109. /// 窗体加载事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void FrmUser_Load(object sender, EventArgs e)
  114. {
  115. try
  116. {
  117. //加载权限
  118. //FormPermissionManager.FormPermissionControl(this.Name, this,
  119. // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  120. // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  121. // 设置表格不自动创建列
  122. this.dgvUserLogin.AutoGenerateColumns = false;
  123. this.SetToolStripButtonEnable();
  124. this.scbOrganization.EditReadOnly = true;
  125. }
  126. catch (Exception ex)
  127. {
  128. // 对异常进行共通处理
  129. ExceptionManager.HandleEventException(this.ToString(),
  130. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  131. }
  132. }
  133. /// <summary>
  134. /// 搜索按钮事件
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void btnSearch_Click(object sender, EventArgs e)
  139. {
  140. try
  141. {
  142. this.btnSearch.Enabled = false;
  143. this.btnClearCondition.Enabled = false;
  144. DataSet userDataSet = this.SearchUserData();
  145. this.btnSearch.Enabled = true;
  146. this.btnClearCondition.Enabled = true;
  147. this.scbOrganization.EditReadOnly = true;
  148. if (userDataSet != null)
  149. {
  150. base.DataSource = (DataSet)userDataSet;
  151. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  152. {
  153. this.dgvUserLogin.DataSource = this.DataSource.Tables[0];
  154. //foreach (DataGridViewRow gvrFor in this.dgvUser.Rows)
  155. //{
  156. // string ValueStr = "";
  157. // string ValueNum = gvrFor.Cells["ValueFlag"].Value.ToString();
  158. // switch (ValueNum)
  159. // {
  160. // case "1":
  161. // ValueStr = "正常";
  162. // break;
  163. // case "0":
  164. // ValueStr = "停用";
  165. // break;
  166. // default:
  167. // break;
  168. // }
  169. // gvrFor.Cells["checkValueFlag"].Value = ValueStr;
  170. // string StateStr = gvrFor.Cells["IsLocked"].Value.ToString();
  171. // if (StateStr == "1")
  172. // {
  173. // gvrFor.Cells["IsLocked"].Value = "锁死";
  174. // }
  175. // else
  176. // {
  177. // gvrFor.Cells["IsLocked"].Value = "正常";
  178. // }
  179. //}
  180. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  181. {
  182. // 提示未查找到数据
  183. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  184. MessageBoxButtons.OK, MessageBoxIcon.Information);
  185. }
  186. }
  187. }
  188. this.SetToolStripButtonEnable();
  189. }
  190. catch (Exception ex)
  191. {
  192. this.btnSearch.Enabled = true;
  193. this.btnClearCondition.Enabled = true;
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. /// <summary>
  200. /// 清空输入查询寻条件
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void btnClear_Click(object sender, EventArgs e)
  205. {
  206. this.txtUserCode.Clear();
  207. this.txtUserName.Clear();
  208. this.scbOrganization.ClearValue();
  209. this.cbActionType.Text = "";
  210. }
  211. /// <summary>
  212. /// 窗体关闭事件
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. private void F_MST_0203_FormClosed(object sender, FormClosedEventArgs e)
  217. {
  218. _instance = null;
  219. }
  220. /// <summary>
  221. /// 自动适应列宽事件
  222. /// </summary>
  223. /// <param name="sender"></param>
  224. /// <param name="e"></param>
  225. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  226. {
  227. this.dgvUserLogin.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  228. }
  229. /// <summary>
  230. /// 窗体关闭事件
  231. /// </summary>
  232. /// <param name="sender"></param>
  233. /// <param name="e"></param>
  234. private void tsbtnClose_Click(object sender, EventArgs e)
  235. {
  236. this.Close();
  237. }
  238. /// <summary>
  239. /// 数据表格鼠标点击事件
  240. /// </summary>
  241. /// <param name="sender"></param>
  242. /// <param name="e"></param>
  243. private void dgvUser_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  244. {
  245. //if (e.RowIndex != -Constant.INT_IS_ONE)
  246. //{
  247. // string ValueFlag = this.dgvUser.Rows[e.RowIndex].Cells["IsLocked"].Value.ToString();
  248. // if (ValueFlag == "锁死" || ValueFlag == "1")
  249. // {
  250. // this.tsbtnUnlock.Enabled = true;
  251. // }
  252. // else
  253. // {
  254. // this.tsbtnUnlock.Enabled = false;
  255. // }
  256. //}
  257. }
  258. /// <summary>
  259. /// 打印工号事件
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. private void tsbPrintCode_Click(object sender, EventArgs e)
  264. {
  265. try
  266. {
  267. if (this.dgvUserLogin.Rows.Count == Constant.INT_IS_ZERO)
  268. {
  269. // 提示信息
  270. MessageBox.Show(Messages.MSG_CMN_W023,
  271. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  272. return;
  273. }
  274. List<string> codeList = new List<string>();
  275. foreach (DataGridViewRow row in this.dgvUserLogin.Rows)
  276. {
  277. codeList.Add(row.Cells["UserCode"].Value.ToString());
  278. }
  279. F_MST_0205 fMST0205 = new F_MST_0205();
  280. fMST0205.BarcodeList = codeList;
  281. fMST0205.ShowDialog();
  282. }
  283. catch (Exception ex)
  284. {
  285. // 对异常进行共通处理
  286. ExceptionManager.HandleEventException(this.ToString(),
  287. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  288. }
  289. }
  290. #endregion
  291. #region 私有方法
  292. /// <summary>
  293. /// 获取用户列表
  294. /// </summary>
  295. /// <returns></returns>
  296. private DataSet SearchUserData()
  297. {
  298. try
  299. {
  300. ClientRequestEntity cre = new ClientRequestEntity();
  301. cre.NameSpace = "F_MST_0208";
  302. cre.Name = "GetUserLoginLog";
  303. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  304. cre.Properties["UserName"] = this.txtUserName.Text.Trim();
  305. cre.Properties["Organization"] = this.scbOrganization.CheckedValue + "";
  306. cre.Properties["ActionType"] = cbActionType.Text;
  307. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  308. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  309. {
  310. return sre.Data;
  311. }
  312. return null;
  313. }
  314. catch (Exception ex)
  315. {
  316. throw ex;
  317. }
  318. }
  319. /// <summary>
  320. /// 获取输入的用户信息
  321. /// </summary>
  322. /// <returns></returns>
  323. private SUserEntity GetUserEntityFromLayout()
  324. {
  325. this._userInfo = new SUserEntity();
  326. // 用户编码
  327. this._userInfo.UserCode = this.txtUserCode.Text.Trim();
  328. // 用户姓名
  329. this._userInfo.UserName = this.txtUserName.Text.Trim();
  330. // 所属部门
  331. this._userInfo.OrganizationCode = this.scbOrganization.SearchedValue + "";
  332. // 所属部门
  333. this._userInfo.OrganizationID = scbOrganization.SearchedPKMember;
  334. // MAC
  335. //this._userInfo.LimitMAC = this.txtMAC.Text.Trim();
  336. //// 备注
  337. //this._userInfo.Remarks = this.txtRemarks.Text.Trim();
  338. //if (this.chkVYes.Checked != this.chkVNo.Checked)
  339. //{
  340. // if (this.chkVNo.Checked)
  341. // {
  342. // this._userInfo.IsValueFlag = "0";
  343. // }
  344. // else if (this.chkVYes.Checked)
  345. // {
  346. // this._userInfo.IsValueFlag = "1";
  347. // }
  348. //}
  349. //if (this.chkLYes.Checked != this.chkLNo.Checked)
  350. //{
  351. // if (this.chkLNo.Checked)
  352. // {
  353. // this._userInfo.IsLocked = "1";
  354. // }
  355. // else if (this.chkLYes.Checked)
  356. // {
  357. // this._userInfo.IsLocked = "0";
  358. // }
  359. //}
  360. return _userInfo;
  361. }
  362. /// <summary>
  363. /// 设置工具按钮的可用状态
  364. /// </summary>
  365. private void SetToolStripButtonEnable()
  366. {
  367. //if (this.dgvUserLogin.CurrentCell != null)
  368. //{
  369. // //this.tsbtnUnlock.Enabled = true;
  370. // //this.tsbtnResetPassword.Enabled = true;
  371. // //this.tsbtnEdit.Enabled = true;
  372. // //this.tsbtnCopy.Enabled = true;
  373. // //this.tsbtnPurviewRight.Enabled = true;
  374. // //this.tsbtnFunctionRight.Enabled = true;
  375. // //int valueFlag = Convert.ToInt32(dgvUser.CurrentRow.Cells["valueFlag"].Value.ToString());
  376. // string valueFlag = this.dgvUserLogin.Rows[dgvUserLogin.CurrentCell.RowIndex].Cells["IsLocked"].Value.ToString();
  377. // if (valueFlag == "1")
  378. // {
  379. // //this.tsbtnUnlock.Enabled = true;
  380. // }
  381. // else
  382. // {
  383. // //this.tsbtnUnlock.Enabled = false;
  384. // }
  385. // // admin用户不能分配权限
  386. // //if ("ADMIN".Equals(dgvUser.CurrentRow.Cells["UserCode"].Value.ToString().ToUpper()))
  387. // //{
  388. // // this.tsbtnFunctionRight.Enabled = false;
  389. // //}
  390. //}
  391. //else
  392. //{
  393. // //this.tsbtnUnlock.Enabled = false;
  394. // //this.tsbtnResetPassword.Enabled = false;
  395. // //this.tsbtnEdit.Enabled = false;
  396. // //this.tsbtnCopy.Enabled = false;
  397. // //this.tsbtnPurviewRight.Enabled = false;
  398. // //this.tsbtnFunctionRight.Enabled = false;
  399. //}
  400. }
  401. /// <summary>
  402. /// 保存组织机构
  403. /// </summary>
  404. /// <returns>影响的行数</returns>
  405. private object UnlockUserStatus()
  406. {
  407. try
  408. {
  409. return SystemModuleProxy.Service.UnlockUserStatus(Convert.ToInt32(this.dgvUserLogin.CurrentRow.Cells["UserID"].Value));
  410. }
  411. catch (Exception ex)
  412. {
  413. throw ex;
  414. }
  415. }
  416. #endregion
  417. }
  418. }