F_Goods.cs 4.6 KB

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