Beispiel #1
0
        public IActionResult DeleteEmployeeStatus(long id)
        {
            EmployeeStatus a = EmpStatus_repo.Find(id);

            if (a == null)
            {
                return(NotFound());
            }
            EmpStatus_repo.Delete(a);
            return(Ok());
        }
Beispiel #2
0
        public void Update(Employee employee)
        {
            Transaction tx = null;

            try
            {
                using (var em = EntityManagerFactory.CreateInstance(ds))
                {
                    tx = em.BeginTransaction();


                    string[] columns = { "EmployeeCode", "OldEmployeeCode", "EmployeeName",  "BirthPlace",     "BirthDate",   "Gender", "Religion", "IsTransfer",
                                         "BankName",     "AccountNumber",   "MaritalStatus", "NumberOfChilds", "IsInsurance", "IsTax",  "NPWP",     "PTKPId",
                                         "IsPrincipal",  "IsFuelAllowance", "StartDate",     "EndDate",        "IsActive",
                                         "ModifiedDate", "ModifiedBy" };

                    object[] values = { employee.EmployeeCode,                employee.OldEmployeeCode,         employee.EmployeeName,                employee.BirthPlace,                    employee.BirthDate.ToShortDateString(),
                                        employee.Gender == true?1:0,          employee.Religion,                employee.IsTransfer == true?1:0,      employee.BankName,                      employee.AccountNumber,
                                        employee.MaritalStatus == true?1:0,   employee.NumberOfChilds,          employee.IsInsurance == true?1:0,     employee.IsTax == true?1:0,             employee.NPWP,
                                        employee.PTKPId,                      employee.IsPrincipal == true?1:0, employee.IsFuelAllowance == true?1:0, employee.StartDate.ToShortDateString(),
                                        employee.EndDate.ToShortDateString(), employee.IsActive == true?1:0,
                                        DateTime.Now.ToShortDateString(),     Store.ActiveUser };


                    var q = new Query().Select(columns).From(tableName).Update(values)
                            .Where("ID").Equal("{" + employee.ID + "}");

                    em.ExecuteNonQuery(q.ToSql(), tx);

                    employeeFamilyRepository.Delete(em, tx, employee.ID);
                    foreach (var family in employee.Families)
                    {
                        family.EmployeeId = employee.ID;
                        employeeFamilyRepository.Save(em, tx, family);
                    }


                    employeeDepatmentRepository.Delete(em, tx, employee.ID);
                    foreach (var dept in employee.Departments)
                    {
                        dept.EmployeeId = employee.ID;
                        employeeDepatmentRepository.Save(em, tx, dept);
                    }


                    employeeGradeRepository.Delete(em, tx, employee.ID);
                    foreach (var grade in employee.Grades)
                    {
                        grade.EmployeeId = employee.ID;
                        employeeGradeRepository.Save(em, tx, grade);
                    }


                    employeeOccupationRepository.Delete(em, tx, employee.ID);
                    foreach (var occupation in employee.Occupations)
                    {
                        occupation.EmployeeId = employee.ID;
                        employeeOccupationRepository.Save(em, tx, occupation);
                    }


                    employeePrincipalRepository.Delete(em, tx, employee.ID);
                    foreach (var principal in employee.Principals)
                    {
                        principal.EmployeeId = employee.ID;
                        employeePrincipalRepository.Save(em, tx, principal);
                    }

                    employeeStatusRepository.Delete(em, tx, employee.ID);
                    foreach (var status in employee.Status)
                    {
                        status.EmployeeId = employee.ID;
                        employeeStatusRepository.Save(em, tx, status);
                    }


                    employeeInsuranceRepository.Delete(em, tx, employee.ID);
                    foreach (var insurance in employee.Insurances)
                    {
                        insurance.EmployeeId = employee.ID;
                        employeeInsuranceRepository.Save(em, tx, insurance);
                    }

                    employeeSalaryRepository.Delete(em, tx, employee.ID);
                    foreach (var salary in employee.Salaries)
                    {
                        salary.EmployeeId = employee.ID;
                        employeeSalaryRepository.Save(em, tx, salary);
                    }


                    tx.Commit();
                }
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
        }
Beispiel #3
0
 public bool Delete(int id)
 {
     return(iEmployeeStatusRepository.Delete(id));
 }