| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 工资调整
- /// </summary>
- 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 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PAM_0603 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PAM_0603();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- 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);
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应事件
- /// </summary>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- //this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 搜索按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 结算按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnPay_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 搜索按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 自动列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- }
|