예제 #1
0
 private void readXtaMembers(final DGuiSession session) {
   msXtaItemTypeCode =
       (String)
           session.readField(
               DModConsts.CS_ITM_TP, new int[] {mnFkItemTypeId}, DDbRegistry.FIELD_CODE);
   msXtaItemTypeName =
       (String)
           session.readField(
               DModConsts.CS_ITM_TP, new int[] {mnFkItemTypeId}, DDbRegistry.FIELD_NAME);
 }
예제 #2
0
  private void readRegMembers(final DGuiSession session, final boolean update) {
    moRegItem = (DDbItem) session.readRegistry(DModConsts.CU_ITM, new int[] {mnFkItemId});

    if (update) {
      mnFkItemTypeId = moRegItem.getRegFamily().getFkItemTypeId();
      mnFkUnitId = moRegItem.getFkUnitId();
    }

    moRegUnit = (DDbUnit) session.readRegistry(DModConsts.CU_UOM, new int[] {mnFkUnitId});

    if (update) {
      mdMassUnit = moRegItem.getMassUnit();
    }
  }
예제 #3
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;
  }
예제 #4
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;
  }
예제 #5
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);
    }
  }