/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PAM_0604.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_0604 : DockPanelBase { #region 成员变量 //单例模式 private static F_PAM_0604 _instance; // 最后选择行 private int _selecedRow; #endregion #region 构造函数 public F_PAM_0604() { InitializeComponent(); this.Text = FormTitles.F_PAM_0604; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PAM_0604 Instance { get { if (_instance == null) { _instance = new F_PAM_0604(); } 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.SavePayrollAuditStatus(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 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 dgvPayroll_CurrentCellDirtyStateChanged(object sender, EventArgs e) { try { if (this.dgvPayroll.CurrentRow != null && this.dgvPayroll.IsCurrentCellDirty) { if ("Sel".Equals(this.dgvPayroll.Columns [this.dgvPayroll.CurrentCell.ColumnIndex].Name)) { this.dgvPayroll.CommitEdit(DataGridViewDataErrorContexts.Commit); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// /// /// /// 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) { //base.DataSource = dsProductionData; DataView dv = dsProductionData.Tables[0].DefaultView; dv.RowFilter = "AuditStatus=0"; DataSet ds = new DataSet(); ds.Tables.Add(dv.ToTable()); base.DataSource = ds; 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["Sel"].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); } } }