private void saveCategoryEmployee(long masterId, PayrollCategory[] categories) throws Exception {

    String sql =
        "INSERT INTO "
            + IDBConstants.TABLE_PAYROLL_CATEGORY_EMPLOYEE_HISTORY
            + "("
            + IDBConstants.ATTR_HISTORY_MASTER
            + ","
            + IDBConstants.ATTR_CATEGORY
            + ","
            + IDBConstants.ATTR_EMPLOYEE
            + ")"
            + " values (?, ?, ?)";

    for (int i = 0; i < categories.length; i++) {
      PayrollCategory payrollCategory = categories[i];

      IHRMSQL iSql = new HRMSQLSAP();
      Employee[] employees =
          iSql.getPayrollCategoryEmployee(payrollCategory.getIndex(), connection);

      for (int j = 0; j < employees.length; j++) {
        Employee emp = employees[j];

        PreparedStatement stm = connection.prepareStatement(sql);

        stm.setLong(1, masterId);
        stm.setLong(2, payrollCategory.getNewIndex());
        stm.setLong(3, emp.getIndex());

        stm.executeUpdate();
      }
    }
  }
  private void saveEmployeeComponent(long masterId, PayrollCategory[] categories) throws Exception {
    String sql =
        "INSERT INTO "
            + IDBConstants.TABLE_EMPLOYEE_PAYROLL_COMPONENT_HISTORY
            + "("
            + IDBConstants.ATTR_HISTORY_MASTER
            + ","
            + IDBConstants.ATTR_EMPLOYEE
            + ","
            + IDBConstants.ATTR_COMPONENT
            + ","
            + IDBConstants.ATTR_FORMULA
            + ","
            + IDBConstants.ATTR_FORMULA_MONTH
            + ","
            + IDBConstants.ATTR_ROUND_VALUE
            + ","
            + IDBConstants.ATTR_PRECISION
            + ")"
            + " values (?, ?, ?, ?, ?, ?, ?)";

    for (int i = 0; i < categories.length; i++) {
      PayrollCategory payrollCategory = categories[i];

      IHRMSQL iSql = new HRMSQLSAP();
      Employee[] employees =
          iSql.getPayrollCategoryEmployee(payrollCategory.getIndex(), connection);

      for (int j = 0; j < employees.length; j++) {
        Employee emp = employees[j];

        HRMBusinessLogic logic = new HRMBusinessLogic(connection);

        PayrollCategoryComponent[] components =
            logic.getAllPayrollCategoryComponent(
                sessionId,
                IDBConstants.MODUL_MASTER_DATA,
                emp.getIndex(),
                IDBConstants.TABLE_EMPLOYEE_PAYROLL_COMPONENT);

        for (int k = 0; k < components.length; k++) {
          PayrollCategoryComponent comp = components[k];

          PreparedStatement stm = connection.prepareStatement(sql);

          stm.setLong(1, masterId);
          stm.setLong(2, emp.getIndex());
          stm.setLong(3, comp.getPayrollComponent().getIndex());
          stm.setString(4, comp.getFormulaEntity().getFormulaCode());
          stm.setInt(5, (int) comp.getEveryWhichMonth());
          stm.setInt(6, (int) comp.getFormulaEntity().getNumberRounding().getRoundingMode());
          stm.setInt(7, comp.getFormulaEntity().getNumberRounding().getPrecision());

          stm.executeUpdate();
        }
      }
    }
  }