Exemplo n.º 1
0
  @Override
  public void update() {

    if (!this.numeroUniqueDevis.checkValidation()) {
      ExceptionHandler.handle("Impossible de modifier, numéro de devis existant.");
      final Object root = SwingUtilities.getRoot(this);
      if (root instanceof EditFrame) {
        final EditFrame frame = (EditFrame) root;
        frame.getPanel().setAlwaysVisible(true);
      }
      return;
    }
    super.update();
    this.table.updateField("ID_DEVIS", getSelectedID());
    this.table.createArticle(getSelectedID(), getElement());

    // generation du document

    try {
      final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(getSelectedID()));
      sheet.createDocumentAsynchronous();
      sheet.showPrintAndExportAsynchronous(
          DevisSQLComponent.this.panelOO.isVisualisationSelected(),
          DevisSQLComponent.this.panelOO.isImpressionSelected(),
          true);
    } catch (Exception e) {
      ExceptionHandler.handle("Impossible de créer le devis", e);
    }
  }
Exemplo n.º 2
0
  @Override
  public int insert(final SQLRow order) {

    final int idDevis;
    // on verifie qu'un devis du meme numero n'a pas été inséré entre temps
    if (this.numeroUniqueDevis.checkValidation()) {

      idDevis = super.insert(order);
      this.table.updateField("ID_DEVIS", idDevis);
      // Création des articles
      this.table.createArticle(idDevis, getElement());

      // generation du document
      try {
        final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(idDevis));
        sheet.createDocumentAsynchronous();
        sheet.showPrintAndExportAsynchronous(
            DevisSQLComponent.this.panelOO.isVisualisationSelected(),
            DevisSQLComponent.this.panelOO.isImpressionSelected(),
            true);
      } catch (Exception e) {
        ExceptionHandler.handle("Impossible de créer le devis", e);
      }

      // incrémentation du numéro auto
      if (NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class)
          .equalsIgnoreCase(this.numeroUniqueDevis.getText().trim())) {
        final SQLRowValues rowVals = new SQLRowValues(this.tableNum);
        int val =
            this.tableNum
                .getRow(2)
                .getInt(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class));
        val++;
        rowVals.put(
            NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class), new Integer(val));
        try {
          rowVals.update(2);
        } catch (final SQLException e) {
          e.printStackTrace();
        }
      }
    } else {
      idDevis = getSelectedID();
      ExceptionHandler.handle("Impossible d'ajouter, numéro de devis existant.");
      final Object root = SwingUtilities.getRoot(this);
      if (root instanceof EditFrame) {
        final EditFrame frame = (EditFrame) root;
        frame.getPanel().setAlwaysVisible(true);
      }
    }

    return idDevis;
  }