F_User.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. // 额外条件 默认0 1为盘点的成型工号的值,以后可以额外增加其他的值
  26. private int _additionalConditionValue = 0;
  27. #endregion
  28. #region 构造函数
  29. /// <summary>
  30. /// 查询窗体
  31. /// </summary>
  32. public F_User()
  33. {
  34. InitializeComponent();
  35. }
  36. #endregion
  37. #region 公有方法
  38. /// <summary>
  39. /// 设置查询条件
  40. /// </summary>
  41. public override void SetConditions(params object[] values)
  42. {
  43. if (values.Length > 1)
  44. {
  45. //this.txtUserName.Text = values[0].ToString();
  46. _isWorker = Convert.ToBoolean(values[1] + "");
  47. }
  48. if (values.Length > 2)
  49. {
  50. _additionalConditionValue = Convert.ToInt32(values[2]+"");
  51. }
  52. }
  53. /// <summary>
  54. /// 清除查询条件
  55. /// </summary>
  56. public override void ClearConditions()
  57. {
  58. this.txtUserCode.Clear();
  59. this.txtUserName.Clear();
  60. }
  61. #endregion
  62. #region 保护方法
  63. /// <summary>
  64. /// 初始化Form
  65. /// </summary>
  66. protected override void InitForm()
  67. {
  68. DataGridViewTextBoxColumn UserID = new DataGridViewTextBoxColumn();
  69. UserID.Name = "UserID";
  70. UserID.HeaderText = "用户ID";
  71. UserID.ReadOnly = true;
  72. UserID.Visible = false;
  73. UserID.SortMode = DataGridViewColumnSortMode.Automatic;
  74. UserID.DataPropertyName = "UserID";
  75. UserID.DefaultCellStyle = new DataGridViewCellStyle();
  76. DataGridViewTextBoxColumn UserCode = new DataGridViewTextBoxColumn();
  77. UserCode.Name = "UserCode";
  78. UserCode.HeaderText = "用户编码";
  79. UserCode.ReadOnly = true;
  80. UserCode.SortMode = DataGridViewColumnSortMode.Automatic;
  81. UserCode.DataPropertyName = "UserCode";
  82. DataGridViewTextBoxColumn UserName = new DataGridViewTextBoxColumn();
  83. UserName.Name = "UserName";
  84. UserName.HeaderText = "用户名称";
  85. UserName.ReadOnly = true;
  86. UserName.SortMode = DataGridViewColumnSortMode.Automatic;
  87. UserName.DataPropertyName = "UserName";
  88. this.dgvSelected.Columns.AddRange(UserID, UserCode, UserName);
  89. base.InitForm();
  90. }
  91. /// <summary>
  92. /// 查询数据。
  93. /// </summary>
  94. /// <returns>验证通过true,其他false</returns>
  95. protected override bool QueryDataFromOther()
  96. {
  97. ServiceResultEntity sre = this.GetDataTable();
  98. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  99. {
  100. this.dgvSelected.DataSource = sre.Data.Tables[0];
  101. this.dgvSelected.Rows[0].Selected = true;
  102. return true;
  103. }
  104. else
  105. {
  106. return false;
  107. }
  108. }
  109. #endregion
  110. #region 私有方法
  111. private ServiceResultEntity GetDataTable()
  112. {
  113. try
  114. {
  115. // 异步处理,获取系统参数信息
  116. ClientRequestEntity cre = new ClientRequestEntity();
  117. cre.NameSpace = "F_User";
  118. cre.Name = "GetUser";
  119. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  120. cre.Properties["UserName"] = this.txtUserName.Text.Trim();
  121. cre.Properties["IsWorker"] = _isWorker ? "1" : "0";
  122. cre.Properties["AdditionalConditionValue"] = _additionalConditionValue;
  123. // 调用服务器端获取数据集(DataSet)DoAsync(new BaseAsyncMethod(GetSystemData));
  124. ServiceResultEntity sre = null;
  125. DoAsync(() => { return CommonModuleProxy.Service.DoRequest(cre); }, out sre);
  126. if (!(sre.Status == Constant.ServiceResultStatus.Success))
  127. {
  128. //StateMessageClass.GetErrorMessageByStatus(this, sre.Status);
  129. // 提示未查找到数据
  130. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  131. MessageBoxButtons.OK, MessageBoxIcon.Information);
  132. }
  133. return sre;
  134. }
  135. catch (Exception ex)
  136. {
  137. // 对异常进行共通处理
  138. ExceptionManager.HandleEventException(this.ToString(),
  139. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  140. return null;
  141. }
  142. }
  143. #endregion
  144. }
  145. }