/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_MST_1201.cs * 2.功能描述:工号分组一览 * 编辑履历: * 作者 日期 版本 修改内容 * 陈晓野 2016/11/10 1.00 新建 *******************************************************************************/ using System; using System.Reflection; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.Controls; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.WinForm.Controls; namespace Dongke.IBOSS.PRD.Client.SystemModule { public partial class F_MST_1201 : DKDockPanelBase { #region 成员变量 private ClientRequestEntity _clientRequestEntity = null; // 查询条件实体 private static F_MST_1201 _instance = null; #endregion #region 构造函数 public F_MST_1201() { InitializeComponent(); // 窗口标题 this.Text = "工号分组(缺陷类型)"; // 工具栏按钮文本赋值 this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; // 查询、清空条件按钮文本赋值 this.tsbtnSearch.Text = ButtonText.BTN_SEARCH; this.tsbtnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; // 设置表格不自动创建列 this.dgvGroup.AutoGenerateColumns = false; this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes; // 编辑、导出和预览按钮不可用 this.tsbtnEdit.Enabled = false; this.tsbtnStop.Visible = false; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_MST_1201 Instance { get { if (_instance == null) { _instance = new F_MST_1201(); } return _instance; } } #endregion #region 控件事件 /// /// 打开画面 /// /// /// private void F_MST_1201_Load(object sender, EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 画面关闭 /// /// /// private void F_MST_012001_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 查询 /// /// /// private void tsbtnSearch_Click(object sender, EventArgs e) { try { this.QueryDataFromOther(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 清空查询条件 /// /// /// private void tsbtnClearCondition_Click(object sender, EventArgs e) { this.ClearConditions(); } /// /// 点击新建票据按钮,新建票据 /// /// /// private void tsbtnAddInvoice_Click(object sender, System.EventArgs e) { try { F_MST_1202 frm012002 = new F_MST_1202(0); DialogResult dialogresult = frm012002.ShowDialog(); if (DialogResult.OK == dialogresult) { QueryDataFromOther(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 点击编辑按钮,编辑现有票据基本信息 /// /// /// private void tsbtnEdit_Click(object sender, EventArgs e) { try { // 获取活动行 DataGridViewRow currentRow = this.dgvGroup.CurrentRow; if (currentRow != null) { int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value); F_MST_1202 frm012002 = new F_MST_1202(id); DialogResult dialogresult = frm012002.ShowDialog(); if (DialogResult.OK == dialogresult) { QueryDataFromOther(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 单击自适应列宽,将所有的列宽都自动去适应内容 /// /// /// private void tsbtnAdaptive_Click(object sender, System.EventArgs e) { this.dgvGroup.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// KeyDown事件 /// /// /// private void dgvInvoice_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyData == (Keys.Control | Keys.C)) { if (dgvGroup.CurrentRow != null && !string.IsNullOrEmpty(dgvGroup.CurrentRow.Cells [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + "")) { try { Clipboard.SetText(dgvGroup.CurrentRow.Cells [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + ""); } catch { } } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭页面 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 所选数据发生改变时 /// /// /// private void dgvInvoice_SelectionChanged(object sender, EventArgs e) { try { if (this.dgvGroup.CurrentCell == null) { this.tsbtnEdit.Enabled = false; this.tsbtnStop.Visible = false; } else { this.tsbtnEdit.Enabled = true; this.tsbtnStop.Visible = true; } DataGridViewRow currentRow = this.dgvGroup.CurrentRow; if (currentRow != null) { string flag = currentRow.Cells["valueflag"].Value.ToString(); if ("1" == flag) { this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE; } else { this.tsbtnStop.Text = "启用(&S)"; } this.tsbtnStop.Tag = flag; int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value); ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "MST_WorkerGroup"; cre.Name = "GetWorkerGroupList"; cre.Properties["WorkerGroupDetail"] = 1; cre.Properties["GroupID"] = id; this.dgvUser.DataSource = null; ServiceResultEntity sre = DoAsync(() => { return SystemModuleProxy.Service.DoBarCodePrint(cre); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { // 查询成功 this.dgvUser.DataSource = sre.Data.Tables[0]; if (sre.Data.Tables[0].Rows.Count > 0) { this.dgvUser.Rows[0].Selected = true; } } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 双击进入编辑页面 /// /// /// private void dgvInvoice_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (-1 < e.RowIndex && -1 < e.ColumnIndex && this.tsbtnEdit.Enabled) { this.tsbtnEdit_Click(sender, e); } } /// /// 停用 /// /// /// private void tsbtnStop_Click(object sender, EventArgs e) { try { DataGridViewRow currentRow = this.dgvGroup.CurrentRow; if (currentRow != null) { string flag = currentRow.Cells["valueflag"].Value.ToString(); int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value); ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "MST_WorkerGroup"; cre.Name = "SetWorkerGroupValueFlag"; cre.Properties["ValueFlag"] = ("1" == flag ? "0" : "1"); cre.Properties["GroupID"] = id; ServiceResultEntity sre = DoAsync(() => { return SystemModuleProxy.Service.DoBarCodePrint(cre); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { // 查询成功 QueryDataFromOther(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 重写方法 /// /// 查询数据 /// /// 验证通过true,其他false private void QueryDataFromOther() { try { this.SearchSelectEntity(); this.dgvGroup.DataSource = null; this.dgvUser.DataSource = null; ServiceResultEntity sre = DoAsync(() => { return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { // 查询成功 this.dgvGroup.DataSource = sre.Data.Tables[0]; if (sre.Data.Tables[0].Rows.Count > 0) { this.dgvGroup.Rows[0].Selected = true; } this.dgvUser.DataSource = sre.Data.Tables[1]; } } catch (Exception ex) { throw ex; } } /// /// 清除查询条件 /// public void ClearConditions() { this.txtGroupName.Text = string.Empty; this.dkDefectTypeNameSearchBox1.ClearControl(); this.txtRemarks.Text = string.Empty; this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes; } #endregion #region 私有方法 /// /// 获取查询实体 /// private void SearchSelectEntity() { this._clientRequestEntity = new ClientRequestEntity(); this._clientRequestEntity.NameSpace = "MST_WorkerGroup"; this._clientRequestEntity.Name = "GetWorkerGroupList"; // 模板名称 this._clientRequestEntity.Properties["GroupName"] = this.txtGroupName.Text.Trim(); this._clientRequestEntity.Properties["Remarks"] = this.txtRemarks.Text; if (!string.IsNullOrEmpty(this.dkDefectTypeNameSearchBox1.DefectTypeIDS)) { this._clientRequestEntity.Properties["DefectTypes"] = "," +this.dkDefectTypeNameSearchBox1.DefectTypeIDS + ","; } // 正常标识 if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.Yes) { this._clientRequestEntity.Properties["valueflag"] = "1"; } else if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.No) { this._clientRequestEntity.Properties["valueflag"] = "0"; } } #endregion } }