public Project_aggregateVo find(long id) throws Exception {
    Project_aggregateVo akey = null;
    try {
      for (Project_aggregateVo v : _table) {
        if (id == v.getId()) {
          akey = v;
          break;
        }
      }
    } catch (Exception e) {
      logger.error(e);
      throw e;
    }

    return akey;
  }
  public Project_aggregateVo find(String uuid) throws Exception {
    Project_aggregateVo akey = null;
    try {
      for (Project_aggregateVo v : _table) {
        if (StringTK.equals(uuid, v.getRuuid())) {
          akey = v;
          break;
        }
      }
    } catch (Exception e) {
      logger.error(e);
      throw e;
    }

    return akey;
  }
Exemple #3
0
  /**
   * 根據id刪除主專案
   *
   * @return boolean 成功或失敗
   */
  public boolean deletePrjInfo(long id) {
    SqlSession session = null;
    boolean status = false;
    int cnt = 0;
    try {
      session = getSession(false);

      Project_subsetVo psVo = new Project_subsetVo();
      ProjectSubsetDao psDao = new ProjectSubsetDao(getDataSourceEnvironment());
      List<Project_subsetVo> psList = null;
      // 根據主專案id先取得所屬子專案資料
      psList = psDao.findByPrjId(id);

      Project_aggregateVo paVo = new Project_aggregateVo();
      ProjectAggregateDao paDao = new ProjectAggregateDao(getDataSourceEnvironment());

      if (!NullTK.isNull(psList)) {
        for (Project_subsetVo d : psList) {
          List<Project_aggregateVo> paList = null;
          View_project_aggregateVo rvo = new View_project_aggregateVo();
          // 根據子專案id取得所屬銷售組合之資料
          paList = paDao.findBySubsetId(d.getId());
          for (Project_aggregateVo dd : paList) {
            // 根據銷售組合資料刪除所屬的費率與佣金資料
            cnt = session.delete("rates.deleteById", dd.getRateid());
            cnt = session.delete("commission.deleteById", dd.getComissionid());
          }
          // 根據子專案id刪除所屬隻銷售組合資料
          cnt = session.delete("projectAggregate.deleteBySubsetId", d.getId());
        }
        cnt = session.delete("projectSubset.deleteByPrjId", id);
      }
      cnt = session.delete("project.deleteById", id);

      session.commit();
      if (cnt > 0) {
        status = true;
      }
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      session.rollback();
    } finally {
      closeCoonnection(session);
    }
    return status;
  }