F_MST_0208.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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. this.opentime.Value = DateTime.Now.AddHours(-1);
  126. this.closetime.Value = DateTime.Now;
  127. }
  128. catch (Exception ex)
  129. {
  130. // 对异常进行共通处理
  131. ExceptionManager.HandleEventException(this.ToString(),
  132. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  133. }
  134. }
  135. /// <summary>
  136. /// 搜索按钮事件
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. private void btnSearch_Click(object sender, EventArgs e)
  141. {
  142. try
  143. {
  144. this.btnSearch.Enabled = false;
  145. this.btnClearCondition.Enabled = false;
  146. DataSet userDataSet = this.SearchUserData();
  147. this.btnSearch.Enabled = true;
  148. this.btnClearCondition.Enabled = true;
  149. this.scbOrganization.EditReadOnly = true;
  150. if (userDataSet != null)
  151. {
  152. base.DataSource = (DataSet)userDataSet;
  153. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  154. {
  155. this.dgvUserLogin.DataSource = this.DataSource.Tables[0];
  156. #region
  157. //foreach (DataGridViewRow gvrFor in this.dgvUser.Rows)
  158. //{
  159. // string ValueStr = "";
  160. // string ValueNum = gvrFor.Cells["ValueFlag"].Value.ToString();
  161. // switch (ValueNum)
  162. // {
  163. // case "1":
  164. // ValueStr = "正常";
  165. // break;
  166. // case "0":
  167. // ValueStr = "停用";
  168. // break;
  169. // default:
  170. // break;
  171. // }
  172. // gvrFor.Cells["checkValueFlag"].Value = ValueStr;
  173. // string StateStr = gvrFor.Cells["IsLocked"].Value.ToString();
  174. // if (StateStr == "1")
  175. // {
  176. // gvrFor.Cells["IsLocked"].Value = "锁死";
  177. // }
  178. // else
  179. // {
  180. // gvrFor.Cells["IsLocked"].Value = "正常";
  181. // }
  182. //}
  183. #endregion
  184. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  185. {
  186. // 提示未查找到数据
  187. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  188. MessageBoxButtons.OK, MessageBoxIcon.Information);
  189. }
  190. }
  191. }
  192. this.SetToolStripButtonEnable();
  193. }
  194. catch (Exception ex)
  195. {
  196. this.btnSearch.Enabled = true;
  197. this.btnClearCondition.Enabled = true;
  198. // 对异常进行共通处理
  199. ExceptionManager.HandleEventException(this.ToString(),
  200. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  201. }
  202. }
  203. /// <summary>
  204. /// 清空输入查询寻条件
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void btnClear_Click(object sender, EventArgs e)
  209. {
  210. this.txtUserCode.Clear();
  211. this.txtUserName.Clear();
  212. this.scbOrganization.ClearValue();
  213. this.cbActionType.Text = "";
  214. this.opentime.Value = DateTime.Now.AddHours(-1);
  215. this.closetime.Value = DateTime.Now;
  216. }
  217. /// <summary>
  218. /// 窗体关闭事件
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. private void F_MST_0203_FormClosed(object sender, FormClosedEventArgs e)
  223. {
  224. _instance = null;
  225. }
  226. /// <summary>
  227. /// 自动适应列宽事件
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  232. {
  233. this.dgvUserLogin.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  234. }
  235. /// <summary>
  236. /// 窗体关闭事件
  237. /// </summary>
  238. /// <param name="sender"></param>
  239. /// <param name="e"></param>
  240. private void tsbtnClose_Click(object sender, EventArgs e)
  241. {
  242. this.Close();
  243. }
  244. /// <summary>
  245. /// 数据表格鼠标点击事件
  246. /// </summary>
  247. /// <param name="sender"></param>
  248. /// <param name="e"></param>
  249. private void dgvUser_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  250. {
  251. //if (e.RowIndex != -Constant.INT_IS_ONE)
  252. //{
  253. // string ValueFlag = this.dgvUser.Rows[e.RowIndex].Cells["IsLocked"].Value.ToString();
  254. // if (ValueFlag == "锁死" || ValueFlag == "1")
  255. // {
  256. // this.tsbtnUnlock.Enabled = true;
  257. // }
  258. // else
  259. // {
  260. // this.tsbtnUnlock.Enabled = false;
  261. // }
  262. //}
  263. }
  264. /// <summary>
  265. /// 打印工号事件
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void tsbPrintCode_Click(object sender, EventArgs e)
  270. {
  271. try
  272. {
  273. if (this.dgvUserLogin.Rows.Count == Constant.INT_IS_ZERO)
  274. {
  275. // 提示信息
  276. MessageBox.Show(Messages.MSG_CMN_W023,
  277. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  278. return;
  279. }
  280. List<string> codeList = new List<string>();
  281. foreach (DataGridViewRow row in this.dgvUserLogin.Rows)
  282. {
  283. codeList.Add(row.Cells["UserCode"].Value.ToString());
  284. }
  285. F_MST_0205 fMST0205 = new F_MST_0205();
  286. fMST0205.BarcodeList = codeList;
  287. fMST0205.ShowDialog();
  288. }
  289. catch (Exception ex)
  290. {
  291. // 对异常进行共通处理
  292. ExceptionManager.HandleEventException(this.ToString(),
  293. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  294. }
  295. }
  296. #endregion
  297. #region 私有方法
  298. /// <summary>
  299. /// 获取用户列表
  300. /// </summary>
  301. /// <returns></returns>
  302. private DataSet SearchUserData()
  303. {
  304. try
  305. {
  306. ClientRequestEntity cre = new ClientRequestEntity();
  307. cre.NameSpace = "F_MST_0208";
  308. cre.Name = "GetUserLoginLog";
  309. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  310. cre.Properties["UserName"] = this.txtUserName.Text.Trim();
  311. cre.Properties["Organization"] = this.scbOrganization.CheckedValue + "";
  312. cre.Properties["ActionType"] = cbActionType.Text;
  313. cre.Properties["opentime"] =this.opentime.Value;
  314. cre.Properties["closetime"] = this.closetime.Value;
  315. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  316. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  317. {
  318. return sre.Data;
  319. }
  320. return null;
  321. }
  322. catch (Exception ex)
  323. {
  324. throw ex;
  325. }
  326. }
  327. /// <summary>
  328. /// 获取输入的用户信息
  329. /// </summary>
  330. /// <returns></returns>
  331. private SUserEntity GetUserEntityFromLayout()
  332. {
  333. this._userInfo = new SUserEntity();
  334. // 用户编码
  335. this._userInfo.UserCode = this.txtUserCode.Text.Trim();
  336. // 用户姓名
  337. this._userInfo.UserName = this.txtUserName.Text.Trim();
  338. // 所属部门
  339. this._userInfo.OrganizationCode = this.scbOrganization.SearchedValue + "";
  340. // 所属部门
  341. this._userInfo.OrganizationID = scbOrganization.SearchedPKMember;
  342. // MAC
  343. //this._userInfo.LimitMAC = this.txtMAC.Text.Trim();
  344. //// 备注
  345. //this._userInfo.Remarks = this.txtRemarks.Text.Trim();
  346. //if (this.chkVYes.Checked != this.chkVNo.Checked)
  347. //{
  348. // if (this.chkVNo.Checked)
  349. // {
  350. // this._userInfo.IsValueFlag = "0";
  351. // }
  352. // else if (this.chkVYes.Checked)
  353. // {
  354. // this._userInfo.IsValueFlag = "1";
  355. // }
  356. //}
  357. //if (this.chkLYes.Checked != this.chkLNo.Checked)
  358. //{
  359. // if (this.chkLNo.Checked)
  360. // {
  361. // this._userInfo.IsLocked = "1";
  362. // }
  363. // else if (this.chkLYes.Checked)
  364. // {
  365. // this._userInfo.IsLocked = "0";
  366. // }
  367. //}
  368. return _userInfo;
  369. }
  370. /// <summary>
  371. /// 设置工具按钮的可用状态
  372. /// </summary>
  373. private void SetToolStripButtonEnable()
  374. {
  375. //if (this.dgvUserLogin.CurrentCell != null)
  376. //{
  377. // //this.tsbtnUnlock.Enabled = true;
  378. // //this.tsbtnResetPassword.Enabled = true;
  379. // //this.tsbtnEdit.Enabled = true;
  380. // //this.tsbtnCopy.Enabled = true;
  381. // //this.tsbtnPurviewRight.Enabled = true;
  382. // //this.tsbtnFunctionRight.Enabled = true;
  383. // //int valueFlag = Convert.ToInt32(dgvUser.CurrentRow.Cells["valueFlag"].Value.ToString());
  384. // string valueFlag = this.dgvUserLogin.Rows[dgvUserLogin.CurrentCell.RowIndex].Cells["IsLocked"].Value.ToString();
  385. // if (valueFlag == "1")
  386. // {
  387. // //this.tsbtnUnlock.Enabled = true;
  388. // }
  389. // else
  390. // {
  391. // //this.tsbtnUnlock.Enabled = false;
  392. // }
  393. // // admin用户不能分配权限
  394. // //if ("ADMIN".Equals(dgvUser.CurrentRow.Cells["UserCode"].Value.ToString().ToUpper()))
  395. // //{
  396. // // this.tsbtnFunctionRight.Enabled = false;
  397. // //}
  398. //}
  399. //else
  400. //{
  401. // //this.tsbtnUnlock.Enabled = false;
  402. // //this.tsbtnResetPassword.Enabled = false;
  403. // //this.tsbtnEdit.Enabled = false;
  404. // //this.tsbtnCopy.Enabled = false;
  405. // //this.tsbtnPurviewRight.Enabled = false;
  406. // //this.tsbtnFunctionRight.Enabled = false;
  407. //}
  408. }
  409. /// <summary>
  410. /// 保存组织机构
  411. /// </summary>
  412. /// <returns>影响的行数</returns>
  413. private object UnlockUserStatus()
  414. {
  415. try
  416. {
  417. return SystemModuleProxy.Service.UnlockUserStatus(Convert.ToInt32(this.dgvUserLogin.CurrentRow.Cells["UserID"].Value));
  418. }
  419. catch (Exception ex)
  420. {
  421. throw ex;
  422. }
  423. }
  424. #endregion
  425. }
  426. }