コード例 #1
0
        public Request updateRequestStatusById(int requestId, string status)
        {
            Request request = fetchById(requestId);

            sqlCon.Open();
            sqlCmd.CommandText = "UPDATE Request SET status = @status WHERE (id = @id);";
            sqlCmd.Parameters.AddWithValue("@status", status);
            sqlCmd.Parameters.AddWithValue("@id", requestId);
            sqlCmd.ExecuteNonQuery();
            sqlCon.Close();

            if (status == "approved")
            {
                EmployeeServiceInterface employeeService = new EmployeeService();
                Employee employee = employeeService.fetchEmployeeById(request.employee.id);

                LeaveCreditServiceInterface leaveCreditsService = new LeaveCreditService();
                LeaveCredits leaveCredits = leaveCreditsService.fetchLeaveCreditsByEmployee(employee);
                Console.WriteLine("leave" + request.name);
                if (request.name.Equals("Vacation Leave"))
                {
                    leaveCredits.vacationLeaveCredits -= 1;
                }
                else if (request.name.Equals("Sick Leave"))
                {
                    leaveCredits.sickLeaveCredits -= 1;
                }
                else if (request.name.Equals("Bereavement Leave"))
                {
                    leaveCredits.bereavementLeaveCredits -= 1;
                }
                else if (request.name.Equals("Paternity Leave"))
                {
                    leaveCredits.paternityLeaveCredits -= 1;
                }
                else if (request.name.Equals("Emergency Leave"))
                {
                    leaveCredits.emergencyLeaveCredits -= 1;
                }
                else if (request.name.Equals("Birthday Leave"))
                {
                    leaveCredits.birthdayLeaveCredits -= 1;
                }
                EmployeeLeaveCredits employeeLeaveRequest = leaveCreditsService.updateEmployeeLeaveCredits(employee, leaveCredits);
            }
            return(request);
        }
コード例 #2
0
        public Employee saveEmployee(Employee employee)
        {
            UserServiceInterface userService = new UserService();
            User user = userService.createUser(employee.userAccount);

            if (user.id > 0)
            {
                sqlCon.Open();
                sqlCmd.CommandText = "INSERT into [Employee] (employeeId, userAccountId, fullName, "
                                     + "birthDate, gender, civilStatus, dependents, address, contactNumber, tin, "
                                     + "sssId, philHealthId, pagIbigId, dateEmployed, jobPositionId) "
                                     + "values(@employeeId, @userAccountId, @fullName, "
                                     + "@birthDate, @gender, @civilStatus, @dependents, "
                                     + "@address, @contactNumber, @tin, @sssId, @philHealthId, @pagIbigId, "
                                     + "@dateEmployed, @jobPositionId);SELECT CAST(scope_identity() AS int)";
                sqlCmd.Parameters.AddWithValue("@employeeId", employee.employeeId);
                sqlCmd.Parameters.AddWithValue("@userAccountId", user.id);
                sqlCmd.Parameters.AddWithValue("@fullName", employee.fullName);
                sqlCmd.Parameters.AddWithValue("@birthDate", employee.birthDate);
                sqlCmd.Parameters.AddWithValue("@gender", employee.gender);
                sqlCmd.Parameters.AddWithValue("@civilStatus", employee.civilStatus);
                sqlCmd.Parameters.AddWithValue("@dependents", employee.dependents);
                sqlCmd.Parameters.AddWithValue("@address", employee.address);
                sqlCmd.Parameters.AddWithValue("@contactNumber", employee.contactNumber);
                sqlCmd.Parameters.AddWithValue("@tin", employee.tin);
                sqlCmd.Parameters.AddWithValue("@sssId", employee.sssId);
                sqlCmd.Parameters.AddWithValue("@philHealthId", employee.philHealthId);
                sqlCmd.Parameters.AddWithValue("@pagIbigId", employee.pagIbigId);
                sqlCmd.Parameters.AddWithValue("@dateEmployed", employee.dateEmployed);
                sqlCmd.Parameters.AddWithValue("@jobPositionId", employee.jobPosition.id);
                employee.id = (int)sqlCmd.ExecuteScalar();
                sqlCon.Close();

                LeaveCreditServiceInterface leaveCreditsService  = new LeaveCreditService();
                EmployeeLeaveCredits        employeeLeaveCredits = leaveCreditsService.createEmployeeLeaveCredits(employee);

                MiscellaneousServiceInterface miscellaneousService = new MiscellaneousService();
                Miscellaneous thirteenMonthBenefit = miscellaneousService.createThirteenMonthBenefit(employee);

                return(employee);
            }
            return(null);
        }