コード例 #1
0
 private void addBanca() {
   try {
     BancaView view;
     view = new BancaView(getShell(), null, AbstractView.MODE_ADD, null, false);
     view.open();
     if (view.getUserAction() == SWT.CANCEL) {
       return;
     }
     Banca result = view.getResult();
     CursValutarView.this.mapBanci.clear();
     CursValutarView.this.mapBanci.addAll(BorgCache.getBanci().values());
     CursValutarView.this.comboBanca.getViewer().setInput(CursValutarView.this.mapBanci);
     CursValutarView.this.comboBanca.select(result.getId());
   } catch (Exception exc) {
     SQLLibrary.processErr(exc);
   }
 }
コード例 #2
0
  @Override
  protected boolean validate() {
    CursValuta test;
    Banca banca;
    Valuta valuta;
    try {
      if (this.comboBanca.getSelectedElement() == null) {
        SWTeXtension.displayMessageW("Nu ati selectat banca de referinta!");
        this.comboBanca.getCombo().setFocus();
        return false;
      }
      banca = (Banca) this.comboBanca.getSelectedElement();

      if (this.comboValuta.getSelectedElement() == null) {
        SWTeXtension.displayMessageW("Nu ati selectat valuta!");
        this.comboValuta.getCombo().setFocus();
        return false;
      }
      valuta = (Valuta) this.comboValuta.getSelectedElement();
      if (Double.parseDouble(this.textCurs.getValue().toString()) == 0) {
        SWTeXtension.displayMessageW("Cursul nu poate fi zero!");
        return false;
      }

      test =
          (CursValuta)
              Database.getDbSingleObjectForUi(
                  CursValuta.class,
                  " AND a."
                      + CursValuta.COL_ID_BANCA
                      + "="
                      + banca.getId()
                      + " AND a."
                      + CursValuta.COL_ID_VALUTA
                      + "="
                      + valuta.getId()
                      + " AND a."
                      + CursValuta.COL_DATA
                      + "='"
                      + this.textData.getText()
                      + "'");
      if ((test != null) && (test.getId() != this.cursValutar.getId())) {
        if (SWTeXtension.displayMessageQ(
                "Atentie! In data de "
                    + this.textData.getText()
                    + ", pentru valuta \""
                    + valuta.getAcronim()
                    + "\" si banca \""
                    + banca.getNume()
                    + "\" exista "
                    + "deja un curs valutar setat! Aceasta valoare va fi actualizata daca veti continua. Continuam?")
            == SWT.NO) {
          return false;
        }
        this.cursValutar = test.cloneObject();
      }
    } catch (Exception exc) {
      AbstractView.processValidateErr(exc);
      return false;
    }
    return true;
  }