/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PAM_0601.cs * 2.功能描述:工资结算一览 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/08/28 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.Proxys; namespace Dongke.IBOSS.PRD.Client.PAMModule { /// /// 工资结算一览 /// public partial class F_PAM_0601 : DockPanelBase { #region 成员变量 //单例模式 private static F_PAM_0601 _instance; // 最后选择行 private int _selecedRow; #endregion #region 构造函数 public F_PAM_0601() { InitializeComponent(); this.Text = FormTitles.F_PAM_0601; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.tsbtnPay.Text = ButtonText.TSBTN_PAY; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PAM_0601 Instance { get { if (_instance == null) { _instance = new F_PAM_0601(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// private void F_PAM_0201_Load(object sender, EventArgs e) { this.dgvPayroll.AutoGenerateColumns = false; this.dgvPiecework.AutoGenerateColumns = false; this.dgvDamageSubsidy.AutoGenerateColumns = false; this.dgvRepairSubsidy.AutoGenerateColumns = false; this.dgvQualityASS.AutoGenerateColumns = false; DateTime dt = DateTime.Now.Date; dtpStartTime.Value = new DateTime(dt.Year, dt.Month, 1); tsbtnPay.Size = new System.Drawing.Size(60, 25); tsbtnChangePay.Size = new System.Drawing.Size(65, 25); } /// /// 关闭窗体事件 /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 自适应事件 /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvPayroll.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvPiecework.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvDamageSubsidy.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvRepairSubsidy.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvQualityASS.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 窗体关闭事件 /// private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 搜索按钮事件 /// /// /// private void btnSearch_Click_1(object sender, EventArgs e) { try { // 记录当前选中行 int selectRowIndex = this._selecedRow; // 异步处理 this.btnSearch.Enabled = false; string year = dtpStartTime.Value.Year.ToString(); string month = dtpStartTime.Value.Month.ToString().Length < 2 ? "0" + dtpStartTime.Value.Month.ToString() : dtpStartTime.Value.Month.ToString(); this.dgvPayroll.DataSource = null; this.dgvPiecework.DataSource = null; this.dgvDamageSubsidy.DataSource = null; this.dgvRepairSubsidy.DataSource = null; this.dgvQualityASS.DataSource = null; DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetPayroll(year + month); })); this.btnSearch.Enabled = true; if (dsProductionData != null) { base.DataSource = dsProductionData; if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO) { this.dgvPayroll.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.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Selected = true; this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Cells["YYYYMM"]; } else { this.dgvPayroll.Rows[selectRowIndex].Selected = true; this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[selectRowIndex].Cells["YYYYMM"]; } } } } //this.tabControl1.SelectTab(0); this.tabControl1.Controls[0].Text = year + "-" + month + "工资单"; } } catch (Exception ex) { this.btnSearch.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 单元格选定事件 /// /// /// private void dgvPayroll_SelectionChanged(object sender, EventArgs e) { } /// /// 结算按钮事件 /// /// /// private void tsbtnPay_Click(object sender, EventArgs e) { try { F_PAM_0602 fpam0602 = new F_PAM_0602(); fpam0602.ShowDialog(); if (fpam0602.DialogResult == DialogResult.OK) { btnSearch_Click_1(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 工资调整按钮事件 /// /// /// private void tsbtnChange_Click(object sender, EventArgs e) { try { F_PAM_0603 fpam0603 = new F_PAM_0603(); fpam0603.ShowDialog(); if (fpam0603.DialogResult == DialogResult.OK) { btnSearch_Click_1(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 审核按钮事件 /// /// /// private void tsbtnApproval_Click(object sender, EventArgs e) { try { F_PAM_0604 fpam0604 = new F_PAM_0604(); fpam0604.ShowDialog(); if (fpam0604.DialogResult == DialogResult.OK) { btnSearch_Click_1(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion /// /// 单元格双击事件 /// /// /// private void dgvPayroll_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (this.dgvPayroll.CurrentCell != null) { //if (!this.tsbtnClose.ReadOnly) //{ if (e.RowIndex < 0) { return; } DataGridViewColumn columnItem = this.dgvPayroll.Columns[e.ColumnIndex]; this._selecedRow = this.dgvPayroll.CurrentCell.RowIndex; //this.dgvDefect.DataSource = null; int staffid = Convert.ToInt32(this.dgvPayroll.Rows[_selecedRow].Cells["staffid"].Value.ToString()); string yyyymm = this.dgvPayroll.Rows[_selecedRow].Cells["YYYYMM"].Value.ToString(); DataSet ds = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetPayrollInfo(yyyymm, staffid); })); if (ds != null) { //if (columnItem.Name == "Piecework") //{ // this.tabControl1.SelectTab(1); //} //else if (columnItem.Name == "DamageSubsidy") //{ // this.tabControl1.SelectTab(2); //} //else if (columnItem.Name == "RepairSubsidy") //{ // this.tabControl1.SelectTab(3); //} //else if (columnItem.Name == "QualityEXA") //{ // this.tabControl1.SelectTab(4); //} // this.tabPage2.Select(); this.tabControl1.SelectTab(1); this.dgvPiecework.DataSource = ds.Tables[0]; this.dgvDamageSubsidy.DataSource = ds.Tables[1]; this.dgvRepairSubsidy.DataSource = ds.Tables[2]; this.dgvQualityASS.DataSource = ds.Tables[3]; } //} } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 反结算按钮事件 /// /// /// private void tsbtnChangePay_Click(object sender, EventArgs e) { //try //{ // if (this.dgvPayroll.CurrentCell != null) // { // DialogResult msgBoxResult = MessageBox.Show( // string.Format(Messages.MSG_CMN_Q002, "工资", "反结算"), this.Text, // MessageBoxButtons.YesNo, MessageBoxIcon.Question); // if (msgBoxResult == DialogResult.Yes) // { // this._selecedRow = this.dgvPayroll.CurrentCell.RowIndex; // int staffid = Convert.ToInt32(this.dgvPayroll.Rows[_selecedRow].Cells["staffid"].Value.ToString()); // string yyyymm = this.dgvPayroll.Rows[_selecedRow].Cells["YYYYMM"].Value.ToString(); // int resultvalue = (int)DoAsync(() => // { // return PAMModuleProxy.Service.ChangePayPiecework(yyyymm); // } // ); // this.dgvPayroll.ReadOnly = true; // // 修改成功 // if (resultvalue > Constant.INT_IS_ZERO) // { // MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工资", "反结算"), // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); // this.btnSearch_Click_1(sender, e); // } // else // { // MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工资", "反结算"), // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); // } // } // } //} //catch (Exception ex) //{ // // 对异常进行共通处理 // ExceptionManager.HandleEventException(this.ToString(), // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); //} try { F_PAM_0605 fpam0605 = new F_PAM_0605(); fpam0605.ShowDialog(); if (fpam0605.DialogResult == DialogResult.OK) { btnSearch_Click_1(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void tsbtnAdd_Click(object sender, EventArgs e) { } private void tsbtnEdit_Click_1(object sender, EventArgs e) { } } }