Example #1
0
        private void btnAddDeduction_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeePayslipItemModel newItem = new EmployeePayslipItemModel();
                newItem.IsStandard = false;
                frmAddEditPayrollItem frm = new frmAddEditPayrollItem(newItem);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    if (newItem.IsApplied)
                    {
                        if (newItem.ChargesType == libERP.MODELS.COMMON.ITEM_CHARGE_TYPE.LUMPSUM)
                        {
                            newItem.SalaryHeadAmount = newItem.SalaryHeadValue;
                        }
                        if (newItem.ChargesType == libERP.MODELS.COMMON.ITEM_CHARGE_TYPE.PERCENTAGE)
                        {
                            if (newItem.HeadForCalculation == libERP.MODELS.COMMON.SalaryHeadCalculatedOn.PERCENT_OF_BASIC)
                            {
                                newItem.SalaryHeadAmount = (_Payslip.BasicSalaryApplied * newItem.SalaryHeadValue) / 100;
                            }
                            if (newItem.HeadForCalculation == libERP.MODELS.COMMON.SalaryHeadCalculatedOn.PERCENT_OF_GROSS)
                            {
                                newItem.SalaryHeadAmount = (_Payslip.GrossSalaryAmount * newItem.SalaryHeadValue) / 100;
                            }
                            if (newItem.HeadForCalculation == libERP.MODELS.COMMON.SalaryHeadCalculatedOn.PERCENT_OF_BASIC_AND_DA)
                            {
                                int     basicSalaryHeadID = Program.LIST_DEFAULTS.Where(X => X.ID == (int)APP_DEFAULT_VALUES.BasicSalaryHeadID).FirstOrDefault().DEFAULT_VALUE;
                                decimal basicAmount       = _Payslip.MonthlyAllounces.Where(x => x.SalaryHeadID == basicSalaryHeadID).FirstOrDefault().SalaryHeadAmount;

                                int     daSalaryHeadID = Program.LIST_DEFAULTS.Where(X => X.ID == (int)APP_DEFAULT_VALUES.daSalaryHeadID).FirstOrDefault().DEFAULT_VALUE;
                                decimal daAmount       = _Payslip.MonthlyAllounces.Where(x => x.SalaryHeadID == daSalaryHeadID).FirstOrDefault().SalaryHeadAmount;


                                newItem.SalaryHeadAmount = ((basicAmount + daAmount) * newItem.SalaryHeadValue) / 100;
                            }
                        }
                    }
                    _Payslip.MonthlyDeducations.Add(newItem);
                    gridDeductions.DataSource = null;
                    gridDeductions.DataSource = _Payslip.MonthlyDeducations;
                    gridDeductions.Refresh();
                    (new ServicePayRoll()).RecalculateEmployeeSalaryHeads(_Payslip);
                    UpdateTotals();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlEmployeeSalaryView::btnAddDeduction_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnAddAllounces_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeePayslipItemModel newItem = new EmployeePayslipItemModel();
                newItem.IsStandard = false;
                frmAddEditPayrollItem frm = new frmAddEditPayrollItem(newItem);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    if (newItem.IsApplied)
                    {
                        if (newItem.ChargesType == libERP.MODELS.COMMON.ITEM_CHARGE_TYPE.LUMPSUM)
                        {
                            newItem.SalaryHeadAmount = newItem.SalaryHeadValue;
                        }
                        if (newItem.ChargesType == libERP.MODELS.COMMON.ITEM_CHARGE_TYPE.PERCENTAGE)
                        {
                            if (newItem.HeadForCalculation == libERP.MODELS.COMMON.SalaryHeadCalculatedOn.PERCENT_OF_BASIC)
                            {
                                newItem.SalaryHeadAmount = (_Payslip.BasicSalaryApplied * newItem.SalaryHeadValue) / 100;
                            }
                            if (newItem.HeadForCalculation == libERP.MODELS.COMMON.SalaryHeadCalculatedOn.PERCENT_OF_GROSS)
                            {
                                newItem.SalaryHeadAmount = (_Payslip.GrossSalaryAmount * newItem.SalaryHeadValue) / 100;
                            }
                        }
                    }
                    _Payslip.MonthlyAllounces.Add(newItem);
                    gridAllounces.DataSource = null;
                    gridAllounces.DataSource = _Payslip.MonthlyAllounces;
                    gridAllounces.Refresh();

                    (new ServicePayRoll()).RecalculateEmployeeSalaryHeads(_Payslip);
                    UpdateTotals();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlEmployeeSalaryView::btnAddAllounces_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }