Esempio n. 1
0
        private void dtgAdd_RowValidated(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dtgAdd.Rows[e.RowIndex].IsNewRow)
            {
                return;
            }
            decimal mBase = 0m;/*mAnnuities=0, mMedicare=0, mUnemployment=0, mBigMedicare=0, mHousingFund=0, mPTax=0;*/

            //遍历数据行与工资项配对,如果是增项,加到基本工资中,如果是前减项则从基本工资中减掉.
            this.CalculateIncrement(ref mBase, this.dtgAdd.Rows[e.RowIndex], this.strHeader);

            //算保险列的值(如果选了某保险列,就算)
            decimal mRealy = mBase;

            foreach (DataGridViewColumn column in this.dtgAdd.Columns)
            {
                if (this.strInsuranceItems.Contains(column.Name))
                {
                    this.dtgAdd.Rows[e.RowIndex].Cells[column.Name].Value = GetInsuranceValue(column.Name, ref mRealy, mBase);
                }
            }

            //实际所得,税前工资(己扣掉保险,没扣税),减掉税钱.
            mRealy = mRealy - HumanResourceLogic.GetPersonnelIncomeTax(mRealy);;
            //遍历数据行与工资项配对,如果存在后减项则从税后工资中减掉.
            this.CalculateDecrease(ref mRealy, this.dtgAdd.Rows[e.RowIndex], this.strHeader);
            this.dtgAdd.Rows[e.RowIndex].Cells["实领工资"].Value = mRealy;
        }
Esempio n. 2
0
 /// <summary>
 /// 单元格编辑之后时发生,在这里判断如果选择人了并且有基本工资列,就读数据库取基本工资值.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dtgAdd_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     if (this.dtgAdd.Columns[e.ColumnIndex].Name == "员工姓名" &&
         this.dtgAdd.Columns.OfType <DataGridViewColumn>().Where(p => p.Name == "基本工资").Count() > 0)
     {
         //if (this.dtgAdd.Rows[e.RowIndex].Cells["基本工资"].Value == null)
         //{
         decimal?mValue = HumanResourceLogic.GetBaseByHumanID(Int32.Parse(this.dtgAdd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()));
         this.dtgAdd.Rows[e.RowIndex].Cells["基本工资"].Value = mValue.HasValue ? mValue.Value : 0;
         //}
     }
 }
Esempio n. 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            var chkBoxs = (this.MdiParent.ActiveMdiChild as FrmReadyPayOff).panPayRoll_flp.Controls.OfType <CheckBox>().Where(p => p.Checked == true);

            this.dtgAdd.ColumnCount = chkBoxs.Count();
            for (int i = 0; i < this.dtgAdd.Columns.Count; i++)
            {
                this.dtgAdd.Columns[i].Name       = chkBoxs.ElementAt(i).Text;
                this.dtgAdd.Columns[i].HeaderText = chkBoxs.ElementAt(i).Text;
                if (this.strInsuranceItems.Contains(chkBoxs.ElementAt(i).Text))
                {
                    this.dtgAdd.Columns[i].ReadOnly = true;
                }
                DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
                dataGridViewCellStyle.Format            = "N2";
                dataGridViewCellStyle.NullValue         = null;
                this.dtgAdd.Columns[i].DefaultCellStyle = dataGridViewCellStyle;
            }
            DataGridViewComboBoxColumn colCboHuman = new DataGridViewComboBoxColumn();

            colCboHuman.HeaderText    = "员工姓名";
            colCboHuman.Name          = colCboHuman.HeaderText;
            colCboHuman.DataSource    = HumanResourceLogic.GetAllPersonnel();
            colCboHuman.DisplayMember = "name";
            colCboHuman.ValueMember   = "id";
            this.dtgAdd.Columns.Insert(0, colCboHuman);

            DataGridViewTextBoxColumn colWage = new DataGridViewTextBoxColumn();

            colWage.Name = "实领工资";
            colWage.DefaultCellStyle.Format    = "N2";
            colWage.DefaultCellStyle.NullValue = null;
            colWage.ReadOnly = true;
            this.dtgAdd.Columns.Insert(this.dtgAdd.Columns.Count, colWage);

            this.dtsWillBeStore = new DataSet();
            this.dtsWillBeStore.Tables.Add(new DataTable());
            this.dtgList.AutoGenerateColumns = false;
            this.dtgList.ColumnCount         = this.dtgAdd.ColumnCount;
            //this.dtgList.ReadOnly = true;
            for (int i = 0; i < this.dtgAdd.ColumnCount; i++)
            {
                this.dtgList.Columns[i].Name             = this.dtgAdd.Columns[i].Name;
                this.dtgList.Columns[i].HeaderText       = this.dtgAdd.Columns[i].HeaderText;
                this.dtgList.Columns[i].DataPropertyName = this.dtgAdd.Columns[i].Name;
                this.dtsWillBeStore.Tables[0].Columns.Add(this.dtgAdd.Columns[i].Name);
            }
            this.dtsWillBeStore.Tables[0].Columns.Add("员工标识");
        }
Esempio n. 4
0
        /// <summary>
        /// 获取各保险金额
        /// </summary>
        /// <param name="strName">保险名称</param>
        /// <param name="mBase">基本工资引用</param>
        /// <param name="mV">基本工资</param>
        /// <returns></returns>
        private decimal GetInsuranceValue(string strName, ref decimal mRealy, decimal mBase)
        {
            decimal dValue = 0;

            switch (strName)
            {
            case "养老保险":
                dValue  = HumanResourceLogic.GetAnnuities(mBase);
                mRealy -= dValue;
                break;

            case "医疗保险":
                dValue  = HumanResourceLogic.GetMedicare(mBase);
                mRealy -= dValue;
                break;

            case "失业保险":
                dValue  = HumanResourceLogic.GetUnemployment(mBase);
                mRealy -= dValue;
                break;

            case "住房公积金":
                dValue  = HumanResourceLogic.GetHousingFund(mBase);
                mRealy -= dValue;
                break;

            case "医疗大额保险":
                dValue  = HumanResourceLogic.GetBigMedicare();
                mRealy -= dValue;
                break;

            case "扣税":
                dValue = HumanResourceLogic.GetPersonnelIncomeTax(mBase);
                //先不减掉税钱
                break;
            }
            return(dValue);
        }