/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_User.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_User : SearchBoxForm { #region 成员变量 private bool _isWorker; // 额外条件 默认0 1为盘点的成型工号的值,以后可以额外增加其他的值 private int _additionalConditionValue = 0; #endregion #region 构造函数 /// /// 查询窗体 /// public F_User() { InitializeComponent(); } #endregion #region 公有方法 /// /// 设置查询条件 /// public override void SetConditions(params object[] values) { if (values.Length > 1) { //this.txtUserName.Text = values[0].ToString(); _isWorker = Convert.ToBoolean(values[1] + ""); } if (values.Length > 2) { _additionalConditionValue = Convert.ToInt32(values[2]+""); } } /// /// 清除查询条件 /// public override void ClearConditions() { this.txtUserCode.Clear(); this.txtUserName.Clear(); } #endregion #region 保护方法 /// /// 初始化Form /// protected override void InitForm() { DataGridViewTextBoxColumn UserID = new DataGridViewTextBoxColumn(); UserID.Name = "UserID"; UserID.HeaderText = "用户ID"; UserID.ReadOnly = true; UserID.Visible = false; UserID.SortMode = DataGridViewColumnSortMode.Automatic; UserID.DataPropertyName = "UserID"; UserID.DefaultCellStyle = new DataGridViewCellStyle(); DataGridViewTextBoxColumn UserCode = new DataGridViewTextBoxColumn(); UserCode.Name = "UserCode"; UserCode.HeaderText = "用户编码"; UserCode.ReadOnly = true; UserCode.SortMode = DataGridViewColumnSortMode.Automatic; UserCode.DataPropertyName = "UserCode"; DataGridViewTextBoxColumn UserName = new DataGridViewTextBoxColumn(); UserName.Name = "UserName"; UserName.HeaderText = "用户名称"; UserName.ReadOnly = true; UserName.SortMode = DataGridViewColumnSortMode.Automatic; UserName.DataPropertyName = "UserName"; this.dgvSelected.Columns.AddRange(UserID, UserCode, UserName); 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_User"; cre.Name = "GetUser"; cre.Properties["UserCode"] = this.txtUserCode.Text.Trim(); cre.Properties["UserName"] = this.txtUserName.Text.Trim(); cre.Properties["IsWorker"] = _isWorker ? "1" : "0"; cre.Properties["AdditionalConditionValue"] = _additionalConditionValue; // 调用服务器端获取数据集(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); } return sre; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); return null; } } #endregion } }