Exemplo n.º 1
0
        private void createPayrollButton_Click(object sender, EventArgs e)
        {
            TimeSpan validDate = endDatePeriod.Value - startDatePeriod.Value;

            if (validDate <= fetchValidDateDuration())
            {
                showErrorMessage("Invalid period.");
                return;
            }

            hideErrorMessage();
            if (!selectAllCheckBox.Checked)
            {
                EmployeeControllerInterface employeeController = new EmployeeController();
                Employee employee = employeeController.fetchEmployeeByUsername(usernameOrEmployeeId.Text);

                if (employee == null || employee.Equals(""))
                {
                    showErrorMessage("Please input a valid username.");
                    return;
                }

                PayrollControllerInterface payslipController = new PayrollController();
                Payslip payslip = payslipController.createPayslip(startDatePeriod.Value, endDatePeriod.Value, employee);
                if (thirteenMonthPayCheckBox.Checked)
                {
                    payslipController.addThirteenMonthPayToPayslip(employee, payslip);
                }

                loadPayrollList();
                adminTab.SelectedTab = payrollTab;
                showErrorMessage("Successfully created payroll to user: "******"admin" && user.status == AccountStatus.Enable)
                    {
                        EmployeeControllerInterface employeeController = new EmployeeController();
                        Employee employee = employeeController.fetchEmployeeByUsername(user.username);

                        if (employee == null || employee.Equals(""))
                        {
                            showErrorMessage("Please input a valid username.");
                            return;
                        }

                        PayrollControllerInterface payslipController = new PayrollController();
                        payslipController.createPayslip(startDatePeriod.Value, endDatePeriod.Value, employee);
                    }
                }
                selectAllCheckBox.Checked = false;
                loadPayrollList();
                adminTab.SelectedTab = payrollTab;
                showErrorMessage("Successfully create payroll to all users");
            }
        }