F_MST_0208.cs 16 KB

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