/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_Goods.cs * 2.功能描述:产品档案Search查询页面 * 编辑履历: * 作者 日期 版本 修改内容 * 付斌 2018/07/23 1.00 新建 *******************************************************************************/ using System; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.Controls.SearchBox { /// /// 产品档案 /// public partial class F_Goods : SearchBoxForm { #region 构造函数 /// /// 查询窗体 /// public F_Goods() { InitializeComponent(); } #endregion #region 公有方法 /// /// 设置查询条件 /// //public override void SetConditions(params object[] values) //{ // if (values.Length > 1) // { // //this.txtGoodsName.Text = values[0].ToString(); // } //} /// /// 清除查询条件 /// public override void ClearConditions() { this.txtGoodsCode.Clear(); this.txtGoodsName.Clear(); } #endregion #region 保护方法 /// /// 初始化Form /// protected override void InitForm() { DataGridViewTextBoxColumn GoodsID = new DataGridViewTextBoxColumn(); GoodsID.Name = "GoodsID"; GoodsID.HeaderText = "产品ID"; GoodsID.ReadOnly = true; GoodsID.Visible = false; GoodsID.SortMode = DataGridViewColumnSortMode.Automatic; GoodsID.DataPropertyName = "GoodsID"; GoodsID.DefaultCellStyle = new DataGridViewCellStyle(); DataGridViewTextBoxColumn GoodsCode = new DataGridViewTextBoxColumn(); GoodsCode.Name = "GoodsCode"; GoodsCode.HeaderText = "产品编码"; GoodsCode.ReadOnly = true; GoodsCode.SortMode = DataGridViewColumnSortMode.Automatic; GoodsCode.DataPropertyName = "GoodsCode"; DataGridViewTextBoxColumn GoodsName = new DataGridViewTextBoxColumn(); GoodsName.Name = "GoodsName"; GoodsName.HeaderText = "产品名称"; GoodsName.ReadOnly = true; GoodsName.SortMode = DataGridViewColumnSortMode.Automatic; GoodsName.DataPropertyName = "GoodsName"; this.dgvSelected.Columns.AddRange(GoodsID, GoodsCode, GoodsName); base.InitForm(); } /// /// 查询数据。 /// /// 验证通过true,其他false protected override bool QueryDataFromOther() { ServiceResultEntity sre = this.GetDataTable(); if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0) { this.dgvSelected.DataSource = sre.Data.Tables[0]; this.dgvSelected.Rows[0].Selected = true; return true; } else { return false; } } #endregion #region 私有方法 private ServiceResultEntity GetDataTable() { try { // 异步处理,获取系统参数信息 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_Goods"; cre.Name = "GetGoods"; cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim(); cre.Properties["GoodsName"] = this.txtGoodsName.Text.Trim(); // 调用服务器端获取数据集(DataSet)DoAsync(new BaseAsyncMethod(GetSystemData)); ServiceResultEntity sre = null; DoAsync(() => { return CommonModuleProxy.Service.DoRequest(cre); }, out sre); //if (!(sre.Status == Constant.ServiceResultStatus.Success)) //{ // //StateMessageClass.GetErrorMessageByStatus(this, sre.Status); // // 提示未查找到数据 // MessageBox.Show(Messages.MSG_CMN_I002, this.Text, // MessageBoxButtons.OK, MessageBoxIcon.Information); //} if (sre.Status == Constant.ServiceResultStatus.NoSearchResults || sre.Data == null || sre.Data.Tables.Count == 0 || sre.Data.Tables[0].Rows.Count == 0) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } return sre; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); return null; } } #endregion } }