예제 #1
0
  @Override
  public int call(java.sql.Connection connection) {
    int nParam = 1;
    java.sql.CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement = connection.prepareCall("{ CALL mfg_ltime_cob_val(?, ?, ?) }");
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.registerOutParameter(nParam, java.sql.Types.INTEGER);
      callableStatement.execute();

      mvParamsOut.clear();
      mvParamsOut.add(callableStatement.getInt(nParam));
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_OK;
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
예제 #2
0
  @Override
  public int read(Object pk, java.sql.Statement statement) {
    int[] key = (int[]) pk;
    String sql = "";
    java.sql.ResultSet resultSet = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;
    reset();

    try {
      sql =
          "SELECT d.*, un.usr, ue.usr, ud.usr "
              + "FROM trn_dsm_nts AS d "
              + "INNER JOIN erp.usru_usr AS un ON "
              + "d.fid_usr_new = un.id_usr "
              + "INNER JOIN erp.usru_usr AS ue ON "
              + "d.fid_usr_edit = ue.id_usr "
              + "INNER JOIN erp.usru_usr AS ud ON "
              + "d.fid_usr_del = ud.id_usr "
              + "WHERE id_year = "
              + key[0]
              + " AND id_doc = "
              + key[1]
              + " AND id_nts = "
              + key[2]
              + " ";
      resultSet = statement.executeQuery(sql);
      if (!resultSet.next()) {
        throw new Exception(SLibConstants.MSG_ERR_REG_FOUND_NOT);
      } else {
        mnPkYearId = resultSet.getInt("d.id_year");
        mnPkDocId = resultSet.getInt("d.id_doc");
        mnPkNotesId = resultSet.getInt("d.id_nts");
        msNotes = resultSet.getString("d.nts");
        mbIsPrintable = resultSet.getBoolean("d.b_prt");
        mbIsDeleted = resultSet.getBoolean("d.b_del");
        mnFkUserNewId = resultSet.getInt("d.fid_usr_new");
        mnFkUserEditId = resultSet.getInt("d.fid_usr_edit");
        mnFkUserDeleteId = resultSet.getInt("d.fid_usr_del");
        mtUserNewTs = resultSet.getTimestamp("d.ts_new");
        mtUserEditTs = resultSet.getTimestamp("d.ts_edit");
        mtUserDeleteTs = resultSet.getTimestamp("d.ts_del");

        msDbmsUserNew = resultSet.getString("un.usr");
        msDbmsUserEdit = resultSet.getString("ue.usr");
        msDbmsUserDelete = resultSet.getString("ud.usr");

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_READ_OK;
      }
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_READ_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_READ_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
예제 #3
0
  @Override
  public int save(java.sql.Connection connection) {
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL erp.finu_tax_bas_save(" + "?, ?, ?, ?, ?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkTaxBasicId);
      callableStatement.setString(nParam++, msTaxBasic);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.CHAR);
      callableStatement.execute();

      mnPkTaxBasicId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      if (mnDbmsErrorId != 0) {
        throw new Exception(msDbmsError);
      } else {
        // Save aswell the taxes

        nParam = 1;

        for (int i = 0; i < mvDbmsTaxes.size(); i++) {
          mvDbmsTaxes.get(i).setPkTaxBasicId(mnPkTaxBasicId);
          if (mvDbmsTaxes.get(i).save(connection) != SLibConstants.DB_ACTION_SAVE_OK) {
            throw new Exception(SLibConstants.MSG_ERR_DB_REG_SAVE_DEP);
          }
        }

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
      }
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
예제 #4
0
  @Override
  public int save(java.sql.Connection connection) {
    int i = 0;
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL mfgu_line_save(" + "?, ?, ?, ?, ?, " + "?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkMfgLineId);
      callableStatement.setString(nParam++, msMfgLine);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mnFkCostCenterId);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.INTEGER);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.VARCHAR);
      callableStatement.execute();

      mnPkMfgLineId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      mbIsRegistryNew = false;
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
예제 #5
0
  @Override
  public int read(java.lang.Object pk, java.sql.Statement statement) {
    int[] key = (int[]) pk;
    String sql = "";

    ResultSet resultSet = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;
    reset();

    try {
      sql =
          "SELECT l.*, cc.id_cc, cc.cc "
              + "FROM mfgu_line AS l "
              + "INNER JOIN fin_cc AS cc ON "
              + "l.fid_cc = cc.pk_cc "
              + "WHERE l.id_line = "
              + key[0]
              + " ";

      resultSet = statement.executeQuery(sql);
      if (!resultSet.next()) {
        throw new Exception(SLibConstants.MSG_ERR_REG_FOUND_NOT);
      } else {
        mnPkMfgLineId = resultSet.getInt("l.id_line");
        msMfgLine = resultSet.getString("l.line");
        mbIsDeleted = resultSet.getBoolean("l.b_del");
        mnFkCostCenterId = resultSet.getInt("l.fid_cc");
        mnFkUserNewId = resultSet.getInt("l.fid_usr_new");
        mnFkUserEditId = resultSet.getInt("l.fid_usr_edit");
        mnFkUserDeleteId = resultSet.getInt("l.fid_usr_del");
        mtUserNewTs = resultSet.getTimestamp("l.ts_new");
        mtUserEditTs = resultSet.getTimestamp("l.ts_edit");
        mtUserDeleteTs = resultSet.getTimestamp("l.ts_del");

        msDbmsPkCostCenterId = resultSet.getString("cc.id_cc");
        msDbmsCostCenter = resultSet.getString("cc.cc");

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_READ_OK;
      }
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_READ_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
예제 #6
0
  @Override
  public int save(java.sql.Connection connection) {
    int nParam = 1;
    java.sql.CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall(
              "{ " + "CALL trn_dsm_nts_save(" + "?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkYearId);
      callableStatement.setInt(nParam++, mnPkDocId);
      callableStatement.setInt(nParam++, mnPkNotesId);
      callableStatement.setString(nParam++, msNotes);
      callableStatement.setBoolean(nParam++, mbIsPrintable);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mnFkUserNewId);
      callableStatement.setInt(nParam++, mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.VARCHAR);
      callableStatement.execute();

      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      if (mnDbmsErrorId != 0) {
        mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      } else {
        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
      }
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
  private void print() {
    int year = moFieldYear.getInteger();
    Cursor cursor = getCursor();
    Map<String, Object> map = null;
    JasperPrint jasperPrint = null;
    JasperViewer jasperViewer = null;
    SDataBizPartner bizPartner = null;
    SDataBizPartnerCategory bizPartnerCategory = null;

    try {
      setCursor(new Cursor(Cursor.WAIT_CURSOR));

      bizPartner =
          (SDataBizPartner)
              SDataUtilities.readRegistry(
                  miClient,
                  SDataConstants.BPSU_BP,
                  moFieldBizPartner.getKeyAsIntArray(),
                  SLibConstants.EXEC_MODE_VERBOSE);

      map = miClient.createReportParams();
      map.put("nSysMoveCatId", manSysMoveTypeKey[0]);
      map.put("nSysMoveTypeId", manSysMoveTypeKey[1]);
      map.put("sBizPartnerCat", msBizPartnerCatSng.toUpperCase());
      map.put("sBizPartnerCatPlural", msBizPartnerCatPlr.toUpperCase());
      map.put(
          "nLocalCurrencyId",
          miClient.getSessionXXX().getParamsErp().getDbmsDataCurrency().getPkCurrencyId());
      map.put(
          "sLocalCurrency",
          miClient.getSessionXXX().getParamsErp().getDbmsDataCurrency().getCurrency());
      map.put("nYear", year);
      map.put(
          "tDate",
          jckShowPayDays.isSelected()
              ? moFieldDateRef.getDate()
              : SLibTimeUtilities.createDate(year, 12, 31));
      map.put("nBizPartnerId", bizPartner.getPkBizPartnerId());
      map.put("sBizPartner", bizPartner.getBizPartner());

      switch (mnBizPartnerCategoryId) {
        case SDataConstantsSys.BPSS_CT_BP_SUP:
          bizPartnerCategory = bizPartner.getDbmsCategorySettingsSup();
          break;
        case SDataConstantsSys.BPSS_CT_BP_CUS:
          bizPartnerCategory = bizPartner.getDbmsCategorySettingsCus();
          break;
        default:
      }

      map.put("dCreditLimit", bizPartnerCategory.getEffectiveCreditLimit());
      map.put("nDaysCredit", bizPartnerCategory.getEffectiveDaysOfCredit());
      map.put("nDaysGrace", bizPartnerCategory.getEffectiveDaysOfGrace());
      map.put(
          "sCreditType",
          SDataReadDescriptions.getCatalogueDescription(
              miClient,
              SDataConstants.BPSS_TP_CRED,
              new int[] {bizPartnerCategory.getEffectiveCreditTypeId()}));

      jasperPrint =
          SDataUtilities.fillReport(
              miClient,
              jckShowPayDays.isSelected()
                  ? SDataConstantsSys.REP_FIN_BPS_ACC_MOV_DAY
                  : SDataConstantsSys.REP_FIN_BPS_ACC_MOV,
              map);
      jasperViewer = new JasperViewer(jasperPrint, false);
      jasperViewer.setTitle(getTitle());
      jasperViewer.setVisible(true);
    } catch (Exception e) {
      SLibUtilities.renderException(this, e);
    } finally {
      setCursor(cursor);
    }
  }
예제 #8
0
  @Override
  public int read(java.lang.Object pk, java.sql.Statement statement) {
    int[] key = (int[]) pk;
    String sql = "";
    ResultSet resultSet = null;
    Statement statementAux = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;
    reset();

    try {
      sql = "SELECT * FROM erp.finu_tax_bas WHERE id_tax_bas = " + key[0] + " ";
      resultSet = statement.executeQuery(sql);
      if (!resultSet.next()) {
        throw new Exception(SLibConstants.MSG_ERR_REG_FOUND_NOT);
      } else {
        mnPkTaxBasicId = resultSet.getInt("id_tax_bas");
        msTaxBasic = resultSet.getString("tax_bas");
        mbIsDeleted = resultSet.getBoolean("b_del");
        mnFkUserNewId = resultSet.getInt("fid_usr_new");
        mnFkUserEditId = resultSet.getInt("fid_usr_edit");
        mnFkUserDeleteId = resultSet.getInt("fid_usr_del");
        mtUserNewTs = resultSet.getTimestamp("ts_new");
        mtUserEditTs = resultSet.getTimestamp("ts_edit");
        mtUserDeleteTs = resultSet.getTimestamp("ts_del");

        statementAux = statement.getConnection().createStatement();

        // Read aswell the taxes

        sql =
            "SELECT id_tax_bas, id_tax FROM erp.finu_tax WHERE id_tax_bas = "
                + key[0]
                + " "
                + "ORDER BY tax, id_tax_bas, id_tax ";
        resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
          SDataTax tax = new SDataTax();
          if (tax.read(
                  new int[] {resultSet.getInt("id_tax_bas"), resultSet.getInt("id_tax")},
                  statementAux)
              != SLibConstants.DB_ACTION_READ_OK) {
            throw new Exception(SLibConstants.MSG_ERR_DB_REG_READ_DEP);
          } else {
            mvDbmsTaxes.add(tax);
          }
        }

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_READ_OK;
      }
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_READ_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_READ_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }