protected bool OnEdit(PayrollEmployee item)
        {
            var selectedItem = item;

            using (var frm = new frmPayrollEmployee_Add())
            {
                if (selectedItem.Id != 0)
                {
                    selectedItem.RowStatus = RecordStatus.ModifiedRecord;
                }
                frm.ItemData = selectedItem;
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }
            }

            App.LogAction("Payroll", "Updated Employee : " + selectedItem.EmployeeClass.EmpNum);

            return(true);
        }
        protected PayrollEmployee OnAdd()
        {
            // Find Employee Id
            var employeeId = 0;

            using (var frm = new frmEmployee_Open())
            {
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }
                employeeId = frm.EmployeeId;
            }


            // Check for Duplicate
            var duplicate = new PayrollEmployeeDataReader().HasExistingId(employeeId);

            if (duplicate)
            {
                MessageDialog.Show("Duplicate Record", "An existing Record with same employee already exists");
                return(null);
            }


            // Get Employee Profile
            var employee = new EmployeeDataReader().GetBasicProfileOf(employeeId);

            if (employee == null)
            {
                throw new Exception("Record NOT found");
            }


            // Create New Payroll Employee
            var newItem = new PayrollEmployee
            {
                EmployeeId    = employee.Id,
                EmployeeClass = employee,
                Active        = true
            };


            // Mandatory Deductions
            newItem.Deductions.AddMandatoryDeductions();
            DeductionGenerator.UpdateMandatoryDeductions(newItem);


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


            App.LogAction("Payroll", "Added Employee : " + newItem.EmployeeClass.EmpNum);

            return(newItem);
        }