/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PAM_0102.cs * 2.功能描述:工种工资方案 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/08/17 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; namespace Dongke.IBOSS.PRD.Client.PAMModule { /// /// 工种工资方案 /// public partial class F_PAM_0102 : DockPanelBase { #region 成员变量 //单例模式 private static F_PAM_0102 _instance; // 最后选择行 private int _selecedRow; #endregion #region 构造函数 public F_PAM_0102() { InitializeComponent(); this.Text = FormTitles.F_PAM_0102; 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_0102 Instance { get { if (_instance == null) { _instance = new F_PAM_0102(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// private void F_PAM_0102_Load(object sender, EventArgs e) { this.dgvJobsPayPlan.AutoGenerateColumns = false; } /// /// 查询事件 /// private void btnSearch_Click(object sender, EventArgs e) { try { // 记录当前选中行 int selectRowIndex = this._selecedRow; // 异步处理 this.btnSearch.Enabled = false; this.btnClearCondition.Enabled = false; DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetJobsPayPlanList(this.txtJobsCode.Text.Trim(), this.txtPayPlanName.Text.Trim(), this.txtJobsName.Text.Trim()); })); 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["JobsName"]; } else { this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true; this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["JobsName"]; } } } } } } 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.txtJobsCode.Text = string.Empty; this.txtPayPlanName.Text = string.Empty; this.txtJobsName.Text = string.Empty; } /// /// 关闭窗体事件 /// 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_0102_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 添加事件 /// private void tsbtnAdd_Click(object sender, EventArgs e) { try { //以新建模式打开信息窗体 F_PAM_0103 frmPAM0103 = new F_PAM_0103(Constant.FormMode.Add, Constant.INT_IS_ZERO); DialogResult dialogResult = frmPAM0103.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) { try { DataGridViewRow currentRow = this.dgvJobsPayPlan.CurrentRow; if (currentRow != null) { //获取需要的信息ID int entityId = Convert.ToInt32(currentRow.Cells["PayPlanID"].Value); //以复制模式打开信息窗体 F_PAM_0103 frmPAM0103= new F_PAM_0103(Constant.FormMode.Edit, entityId); DialogResult dialogResult = frmPAM0103.ShowDialog(); //操作成功后刷新数据源 if (dialogResult == DialogResult.OK) { btnSearch_Click(sender, e); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion } }