public void UpdateCurrentInfo(int month, int year, EmployeeCurrentInfo currentInfo) { try { using (var em = EntityManagerFactory.CreateInstance(ds)) { string[] columns = { "Branch", "Department", "BankName", "AccountNumber" }; object[] values = { currentInfo.BranchName, currentInfo.DepartmentName, currentInfo.BankName, currentInfo.AccountNumber }; var q = new Query().Select(columns).From(tableName).Update(values) .Where("EmployeeId").Equal("{" + currentInfo.EmployeeId + "}") .And("MonthPeriod").GreaterEqualThan(month) .And("YearPeriod").GreaterEqualThan(year) .And("IsPaid = false");; em.ExecuteNonQuery(q.ToSql()); } } catch (Exception ex) { throw ex; } }
private void UpdateEmployeeCurrentInfo(Guid employeeId, string branchName, string departmentName, string gradeName, string occupationName, string employeeStatus, string paymentType) { Guid branchId = Guid.Empty; Guid departmentId = Guid.Empty; Guid gradeId = Guid.Empty; int gradeLevel = 0; Guid occupationId = Guid.Empty; var branch = branchRepository.GetByName(branchName); if (branchName != null) { branchId = branch.ID; } var department = departmentRepository.GetByName(departmentName); if (department != null) { departmentId = department.ID; } var grade = gradeRepository.GetByName(gradeName); if (grade != null) { gradeId = grade.ID; gradeLevel = grade.GradeLevel; } var occupation = occupationRepository.GetByName(occupationName); if (occupation != null) { occupationId = occupation.ID; } var employeeCurrentInfo = new EmployeeCurrentInfo(); employeeCurrentInfo.EmployeeId = employeeId; employeeCurrentInfo.BranchId = branchId; employeeCurrentInfo.BranchName = branchName; employeeCurrentInfo.DepartmentId = departmentId; employeeCurrentInfo.DepartmentName = departmentName; employeeCurrentInfo.GradeId = gradeId; employeeCurrentInfo.GradeName = gradeName; employeeCurrentInfo.GradeLevel = gradeLevel; employeeCurrentInfo.OccupationId = occupationId; employeeCurrentInfo.OccupationName = occupationName; employeeCurrentInfo.EmployeeStatus = employeeStatus; employeeCurrentInfo.PaymentType = paymentType; employeeRepository.UpdateCurrentInfo(employeeCurrentInfo); }
public void UpdateCurrentInfo(EmployeeCurrentInfo currentInfo) { try { using (var em = EntityManagerFactory.CreateInstance(ds)) { string[] columns = { "CurrentBranchId", "CurrentBranch", "CurrentDepartmentId", "CurrentDepartment", "CurrentGradeId", "CurrentGrade", "CurrentGradeLevel", "CurrentOccupationId", "CurrentOccupation", "CurrentStatus", "CurrentPaymentType" }; object[] values = { currentInfo.BranchId, currentInfo.BranchName, currentInfo.DepartmentId, currentInfo.DepartmentName, currentInfo.GradeId, currentInfo.GradeName, currentInfo.GradeLevel, currentInfo.OccupationId, currentInfo.OccupationName, currentInfo.EmployeeStatus, currentInfo.PaymentType }; var q = new Query().Select(columns).From(tableName).Update(values) .Where("ID").Equal("{" + currentInfo.EmployeeId + "}"); em.ExecuteNonQuery(q.ToSql()); } } catch (Exception ex) { throw ex; } }