Exemple #1
0
        /// <summary>
        /// Saves the payroll employee deduction.
        /// </summary>
        /// <param name="payrollEmployeeDeduction">The payroll employee deduction.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">payrollEmployeeDeduction</exception>
        public string SavePayrollEmployeeDeduction(IPayrollEmployeeDeduction payrollEmployeeDeduction)
        {
            if (payrollEmployeeDeduction == null)
            {
                throw new ArgumentNullException(nameof(payrollEmployeeDeduction));
            }

            string result = string.Empty;

            var newRecord = new PayrollEmployeeDeduction
            {
                PayrollId           = payrollEmployeeDeduction.PayrollId,
                CompanyId           = payrollEmployeeDeduction.CompanyId,
                EmployeeDeductionId = payrollEmployeeDeduction.EmployeeDeductionId,
                IsActive            = true,
                DateCreated         = DateTime.UtcNow,
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.PayrollEmployeeDeductions.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Save payroll info - {0}, {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
        private void Show_Deduction_OnRow(int row, PayrollEmployeeDeduction item)
        {
            FlexGridDeductions[row, "code"]        = item.DeductionClass.Code;
            FlexGridDeductions[row, "description"] = item.DeductionClass.Description;
            FlexGridDeductions[row, "amount"]      = item.Amount;


            FlexGridDeductions[row, "startdate"] = item.DateFrom;
            FlexGridDeductions[row, "enddate"]   = item.DateTo;

            FlexGridDeductions.Rows[row].UserData = item;
        }
        private void btnAddDeduction_Click(object sender, EventArgs e)
        {
            var newItem = new PayrollEmployeeDeduction();

            using (var frm = new frmEmployeeDeduction_Add())
            {
                frm.ItemData = newItem;
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                //newItem = frm.ItemData;
            }

            ItemData.Deductions.Add(newItem);
            Show_Deductions();
        }