/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PAM_0201.cs * 2.功能描述:工价分类 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/08/18 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.DockPanel; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService; using Dongke.IBOSS.PRD.WCF.DataModels.PAMModule; namespace Dongke.IBOSS.PRD.Client.PAMModule { public partial class F_PAM_0401 : DockPanelBase { #region 成员变量 //单例模式 private static F_PAM_0401 _instance; // 最后选择行 private int _selecedRow; #endregion #region 构造函数 public F_PAM_0401() { InitializeComponent(); this.Text = FormTitles.F_PAM_0401; this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PAM_0401 Instance { get { if (_instance == null) { _instance = new F_PAM_0401(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// private void F_PAM_0201_Load(object sender, EventArgs e) { this.dgvJobsPayPlan.AutoGenerateColumns = false; // 绑定工资方案数据源 DataSet dsPayPlan = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetPayPlan(); })); if (dsPayPlan != null && dsPayPlan.Tables[0].Rows.Count > 0) { DataRow dr = dsPayPlan.Tables[0].NewRow(); dr["PayPlanName"] = ""; dr["PayPlanID"] = -1; dsPayPlan.Tables[0].Rows.InsertAt(dr, 0); cmbPayPlan.DataSource = dsPayPlan.Tables[0]; cmbPayPlan.DisplayMember = "PayPlanName"; cmbPayPlan.ValueMember = "PayPlanID"; } tsbtnEdit.Size = new System.Drawing.Size(60,25); } /// /// 查询事件 /// private void btnSearch_Click(object sender, EventArgs e) { try { // 记录当前选中行 int selectRowIndex = this._selecedRow; // 异步处理 this.btnSearch.Enabled = false; this.btnClearCondition.Enabled = false; int? PayPlanID = null; if (cmbPayPlan.Text != "") { PayPlanID = Convert.ToInt32(cmbPayPlan.SelectedValue); } DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetQualityASSList(this.txtName.Text.Trim(), PayPlanID); })); this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; if (dsProductionData != null) { base.DataSource = dsProductionData; if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO) { this.dgvJobsPayPlan.DataSource = this.DataSource.Tables[0]; if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (selectRowIndex >= Constant.INT_IS_ZERO) { if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count) { this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Selected = true; this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Cells["QualityTacticsName"]; } else { this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true; this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["QualityTacticsName"]; } } } } } } catch (Exception ex) { this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 清空事件 /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtName.Text = ""; this.cmbPayPlan.SelectedValue = -1; } /// /// 关闭窗体事件 /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 自适应事件 /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ; } /// /// 窗体关闭事件 /// private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 添加事件 /// private void tsbtnAdd_Click(object sender, EventArgs e) { try { //以新建模式打开信息窗体 F_PAM_0402 frmPAM0402 = new F_PAM_0402(Constant.FormMode.Add, Constant.INT_IS_ZERO); DialogResult dialogResult = frmPAM0402.ShowDialog(); if (dialogResult == DialogResult.OK) { btnSearch_Click(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// ///编辑事件 /// private void tsbtnEdit_Click(object sender, EventArgs e) { } #endregion /// /// 编辑按钮事件 /// /// /// private void tsbtnEdit_Click_1(object sender, EventArgs e) { try { if (this.dgvJobsPayPlan.CurrentRow != null) { F_PAM_0402 frmPAM0302 = new F_PAM_0402(Constant.FormMode.Edit, Convert.ToInt32(this.dgvJobsPayPlan.CurrentRow.Cells["QualityASSTacticsID"].Value)); DialogResult dialogResult = frmPAM0302.ShowDialog(); if (dialogResult.Equals(DialogResult.OK)) { btnSearch_Click(sender, e); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } } }