F_User.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_User.cs
  5. * 2.功能描述:工号Search查询页面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2018/07/23 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using Dongke.IBOSS.PRD.Basics.BaseResources;
  13. using Dongke.IBOSS.PRD.Client.CommonModule;
  14. using Dongke.IBOSS.PRD.WCF.DataModels;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. namespace Dongke.IBOSS.PRD.Client.Controls.SearchBox
  17. {
  18. /// <summary>
  19. /// 工号
  20. /// </summary>
  21. public partial class F_User : SearchBoxForm
  22. {
  23. #region 成员变量
  24. private bool _isWorker;
  25. #endregion
  26. #region 构造函数
  27. /// <summary>
  28. /// 查询窗体
  29. /// </summary>
  30. public F_User()
  31. {
  32. InitializeComponent();
  33. }
  34. #endregion
  35. #region 公有方法
  36. /// <summary>
  37. /// 设置查询条件
  38. /// </summary>
  39. public override void SetConditions(params object[] values)
  40. {
  41. if (values.Length > 1)
  42. {
  43. //this.txtUserName.Text = values[0].ToString();
  44. _isWorker = Convert.ToBoolean(values[1] + "");
  45. }
  46. }
  47. /// <summary>
  48. /// 清除查询条件
  49. /// </summary>
  50. public override void ClearConditions()
  51. {
  52. this.txtUserCode.Clear();
  53. this.txtUserName.Clear();
  54. }
  55. #endregion
  56. #region 保护方法
  57. /// <summary>
  58. /// 初始化Form
  59. /// </summary>
  60. protected override void InitForm()
  61. {
  62. DataGridViewTextBoxColumn UserID = new DataGridViewTextBoxColumn();
  63. UserID.Name = "UserID";
  64. UserID.HeaderText = "用户ID";
  65. UserID.ReadOnly = true;
  66. UserID.Visible = false;
  67. UserID.SortMode = DataGridViewColumnSortMode.Automatic;
  68. UserID.DataPropertyName = "UserID";
  69. UserID.DefaultCellStyle = new DataGridViewCellStyle();
  70. DataGridViewTextBoxColumn UserCode = new DataGridViewTextBoxColumn();
  71. UserCode.Name = "UserCode";
  72. UserCode.HeaderText = "用户编码";
  73. UserCode.ReadOnly = true;
  74. UserCode.SortMode = DataGridViewColumnSortMode.Automatic;
  75. UserCode.DataPropertyName = "UserCode";
  76. DataGridViewTextBoxColumn UserName = new DataGridViewTextBoxColumn();
  77. UserName.Name = "UserName";
  78. UserName.HeaderText = "用户名称";
  79. UserName.ReadOnly = true;
  80. UserName.SortMode = DataGridViewColumnSortMode.Automatic;
  81. UserName.DataPropertyName = "UserName";
  82. this.dgvSelected.Columns.AddRange(UserID, UserCode, UserName);
  83. base.InitForm();
  84. }
  85. /// <summary>
  86. /// 查询数据。
  87. /// </summary>
  88. /// <returns>验证通过true,其他false</returns>
  89. protected override bool QueryDataFromOther()
  90. {
  91. ServiceResultEntity sre = this.GetDataTable();
  92. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  93. {
  94. this.dgvSelected.DataSource = sre.Data.Tables[0];
  95. this.dgvSelected.Rows[0].Selected = true;
  96. return true;
  97. }
  98. else
  99. {
  100. return false;
  101. }
  102. }
  103. #endregion
  104. #region 私有方法
  105. private ServiceResultEntity GetDataTable()
  106. {
  107. try
  108. {
  109. // 异步处理,获取系统参数信息
  110. ClientRequestEntity cre = new ClientRequestEntity();
  111. cre.NameSpace = "F_User";
  112. cre.Name = "GetUser";
  113. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  114. cre.Properties["UserName"] = this.txtUserName.Text.Trim();
  115. cre.Properties["IsWorker"] = _isWorker ? "1" : "0";
  116. // 调用服务器端获取数据集(DataSet)DoAsync(new BaseAsyncMethod(GetSystemData));
  117. ServiceResultEntity sre = null;
  118. DoAsync(() => { return CommonModuleProxy.Service.DoRequest(cre); }, out sre);
  119. if (!(sre.Status == Constant.ServiceResultStatus.Success))
  120. {
  121. //StateMessageClass.GetErrorMessageByStatus(this, sre.Status);
  122. // 提示未查找到数据
  123. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  124. MessageBoxButtons.OK, MessageBoxIcon.Information);
  125. }
  126. return sre;
  127. }
  128. catch (Exception ex)
  129. {
  130. // 对异常进行共通处理
  131. ExceptionManager.HandleEventException(this.ToString(),
  132. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  133. return null;
  134. }
  135. }
  136. #endregion
  137. }
  138. }