コード例 #1
0
  @Override
  public void read(DGuiSession session, int[] pk) throws SQLException, Exception {
    ResultSet resultSet = null;

    initRegistry();
    initQueryMembers();
    mnQueryResultId = DDbConsts.READ_ERROR;

    msSql = "SELECT * " + getSqlFromWhere(pk);
    resultSet = session.getStatement().executeQuery(msSql);
    if (!resultSet.next()) {
      throw new Exception(DDbConsts.ERR_MSG_REG_NOT_FOUND);
    } else {
      mnPkFormulaId = resultSet.getInt("id_frm");
      mnPkByProdId = resultSet.getInt("id_byp");
      mdQuantity = resultSet.getDouble("qty");
      mdMassUnit = resultSet.getDouble("mass_unt");
      mdMass_r = resultSet.getDouble("mass_r");
      mdBrix = resultSet.getDouble("brix");
      mdMassSolid_r = resultSet.getDouble("mass_sld_r");
      mbStandard = resultSet.getBoolean("b_std");
      mnFkItemId = resultSet.getInt("fk_itm");
      mnFkItemTypeId = resultSet.getInt("fk_itm_tp");
      mnFkUnitId = resultSet.getInt("fk_uom");

      readRegMembers(session, false);
      readXtaMembers(session);

      mbRegistryNew = false;
    }

    mnQueryResultId = DDbConsts.READ_OK;
  }
コード例 #2
0
  @Override
  public void save(DGuiSession session) throws SQLException, Exception {
    initQueryMembers();
    mnQueryResultId = DDbConsts.SAVE_ERROR;

    compute(session);

    if (mbRegistryNew) {
      computePrimaryKey(session);

      msSql =
          "INSERT INTO "
              + getSqlTable()
              + " VALUES ("
              + mnPkFormulaId
              + ", "
              + mnPkByProdId
              + ", "
              + mdQuantity
              + ", "
              + mdMassUnit
              + ", "
              + mdMass_r
              + ", "
              + mdBrix
              + ", "
              + mdMassSolid_r
              + ", "
              + (mbStandard ? 1 : 0)
              + ", "
              + mnFkItemTypeId
              + ", "
              + mnFkItemId
              + ", "
              + mnFkItemTypeId
              + ", "
              + mnFkUnitId
              + " "
              + ")";
    } else {
      throw new Exception(DDbConsts.ERR_MSG_REG_NON_UPDATABLE);
    }

    session.getStatement().execute(msSql);
    mbRegistryNew = false;
    mnQueryResultId = DDbConsts.SAVE_OK;
  }
コード例 #3
0
  @Override
  public void computePrimaryKey(DGuiSession session) throws SQLException, Exception {
    ResultSet resultSet = null;

    mnPkByProdId = 0;

    msSql =
        "SELECT COALESCE(MAX(id_byp), 0) + 1 FROM "
            + getSqlTable()
            + " "
            + "WHERE id_frm = "
            + mnPkFormulaId
            + " ";
    resultSet = session.getStatement().executeQuery(msSql);
    if (resultSet.next()) {
      mnPkByProdId = resultSet.getInt(1);
    }
  }