/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PAM_0603.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.WCF.Proxys; using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.DockPanel; namespace Dongke.IBOSS.PRD.Client.PAMModule { /// /// 工资调整 /// public partial class F_PAM_0603 : DockPanelBase { #region 成员变量 //单例模式 private static F_PAM_0603 _instance; // 最后选择行 private int _selecedRow; #endregion #region 构造函数 public F_PAM_0603() { InitializeComponent(); this.Text = FormTitles.F_PAM_0603; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PAM_0603 Instance { get { if (_instance == null) { _instance = new F_PAM_0603(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// private void F_PAM_0201_Load(object sender, EventArgs e) { this.dgvPayroll.AutoGenerateColumns = false; DateTime dt = DateTime.Now.Date; dtpStartTime.Value = new DateTime(dt.Year, dt.Month, 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 btnSearch_Click_1(object sender, EventArgs e) { try { DataTable dt = dgvPayroll.DataSource as DataTable; if (dt == null || dt.Rows.Count == 0) { return; } int returnValue = (int)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.SavePayrollChange(dt); })); if (returnValue > 0) //等于O,表示未修改数据,影响行为0 { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } btnSearch_Click(sender, e); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// /// /// /// private void dgvPayroll_SelectionChanged(object sender, EventArgs e) { try { if (this.dgvPayroll.CurrentCell != null) { //if (!this.tsbtnClose.ReadOnly) //{ 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) { //this.dgvInCheckededDetail.DataSource = ds.Tables[0]; //this.dgvInCheckedWinDetail.DataSource = ds.Tables[1]; //this.c_DataGridView1.DataSource = ds.Tables[2]; //this.c_DataGridView2.DataSource = ds.Tables[3]; } //} } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 结算按钮事件 /// /// /// private void tsbtnPay_Click(object sender, EventArgs e) { } /// /// 搜索按钮事件 /// /// /// private void btnSearch_Click(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(); DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() => { return PAMModuleProxy.Service.GetPayroll(year + month); })); this.btnSearch.Enabled = true; if (dsProductionData != null) { //DataView dv = dsProductionData.Tables[0].DefaultView; //dv.RowFilter = "ADAmount=0"; //DataSet ds = new DataSet(); //ds.Tables.Add(dv.ToTable()); foreach (DataRow r in dsProductionData.Tables[0].Rows) { r["TotalAmount"] = Convert.ToDecimal(r["Piecework"]) + Convert.ToDecimal(r["DamageSubsidy"]) + Convert.ToDecimal(r["RepairSubsidy"]) + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["AdminEXA"]) + Convert.ToDecimal(r["ADAmount"]); } 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"]; } } } } } foreach (DataGridViewRow row in this.dgvPayroll.Rows) { // 未注浆的,不能编辑 object groutingFlag = row.Cells["AuditStatus"].Value; if (groutingFlag.ToString() == "1") { row.Cells["ADAmount"].ReadOnly = true; row.Cells["Remarks"].ReadOnly = true; } } this.dgvPayroll.IsSetInputColumnsColor = true; } catch (Exception ex) { this.btnSearch.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion private void tsbtnClose_Click_1(object sender, EventArgs e) { this.Close(); } /// /// 自动列宽 /// /// /// private void tsbtnAdaptive_Click_1(object sender, EventArgs e) { this.dgvPayroll.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } private void F_PAM_0603_Shown(object sender, EventArgs e) { this.dgvPayroll.IsSetInputColumnsColor = true; } private void dgvPayroll_CellValidated(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } DataGridViewRow rowItem = this.dgvPayroll.Rows[e.RowIndex]; DataGridViewColumn columnItem = dgvPayroll.Columns[e.ColumnIndex]; if ("ADAmount" == columnItem.Name) { object ADAmount = rowItem.Cells[e.ColumnIndex].FormattedValue; if (ADAmount == null || ADAmount.ToString() == string.Empty) { rowItem.Cells["ADAmount"].Value = 0; } //r["TotalAmount"] = Convert.ToDecimal(r["Piecework"]) + Convert.ToDecimal(r["DamageSubsidy"]) + Convert.ToDecimal(r["RepairSubsidy"]) // + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["AdminEXA"]) + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["ADAmount"]); rowItem.Cells["TotalAmount"].Value = Convert.ToDecimal(rowItem.Cells["Piecework"].Value) + Convert.ToDecimal(rowItem.Cells["DamageSubsidy"].Value) + Convert.ToDecimal(rowItem.Cells["RepairSubsidy"].Value) + Convert.ToDecimal(rowItem.Cells["QualityEXA"].Value) + Convert.ToDecimal(rowItem.Cells["AdminEXA"].Value) + Convert.ToDecimal(rowItem.Cells["ADAmount"].Value) ; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void dgvPayroll_Sorted(object sender, EventArgs e) { foreach (DataGridViewRow row in this.dgvPayroll.Rows) { // 未注浆的,不能编辑 object groutingFlag = row.Cells["AuditStatus"].Value; if (groutingFlag.ToString() == "1") { row.Cells["ADAmount"].ReadOnly = true; row.Cells["Remarks"].ReadOnly = true; } } this.dgvPayroll.IsSetInputColumnsColor = true; } } }