Пример #1
0
  @Override
  protected SQLRowValues createDefaults() {
    System.err.println("Create defaults");

    setSiteEnabled(false, Type_Diff.DONNEUR_ORDRE);
    setSiteEnabled(false, Type_Diff.SITE);

    // Numero incremental auto
    final SQLRowValues rowVals = new SQLRowValues(getTable());
    rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class));

    // User
    // final SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
    final SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
    final int idUser = UserManager.getInstance().getCurrentUser().getId();
    //
    // sel.addSelect(eltComm.getTable().getKey());
    // sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
    // final List<SQLRow> rowsComm = (List<SQLRow>)
    // Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
    // SQLRowListRSH(eltComm.getTable()));

    SQLRow rowsComm =
        SQLBackgroundTableCache.getInstance()
            .getCacheForTable(eltComm.getTable())
            .getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));

    if (rowsComm != null) {
      rowVals.put("ID_COMMERCIAL", rowsComm.getID());
    }
    if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
      rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE);
    } else {
      SQLRowValues foreign = UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable());
      if (foreign != null && !foreign.isUndefined()) {
        rowVals.put("ID_ETAT_DEVIS", foreign.getObject("ID_ETAT_DEVIS"));
      } else {
        rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE);
      }
    }
    rowVals.put("T_HT", Long.valueOf(0));
    rowVals.put("T_TVA", Long.valueOf(0));
    rowVals.put("T_SERVICE", Long.valueOf(0));
    rowVals.put("T_TTC", Long.valueOf(0));

    if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
      Calendar cal = Calendar.getInstance();
      cal.add(Calendar.MONTH, 1);
      rowVals.put("DATE_VALIDITE", cal.getTime());
    }
    return rowVals;
  }
Пример #2
0
  /*
   * MaJ de la requete pour remplir la IListe en fonction du compte sélectionner et du mode de
   * sélection
   */
  private void changeListRequest() {
    Object idCpt = this.selCompte.getSelectedId();

    SQLRow row = this.tableComptePCE.getRow(Integer.valueOf(idCpt.toString()));

    // filtre de selection
    Where w = new Where(this.tableEcr.getField("ID_COMPTE_PCE"), "=", this.tableComptePCE.getKey());

    if (!UserManager.getInstance()
        .getCurrentUser()
        .getRights()
        .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
      // TODO Show Restricted acces in UI
      w = w.and(new Where(this.tableEcr.getField("COMPTE_NUMERO"), "LIKE", "411%"));
    }

    if (row != null) {
      String num = row.getString("NUMERO");
      Where w2;
      if (this.boxAddSousCompte.isSelected()) {
        w2 = new Where(this.tableComptePCE.getField("NUMERO"), "LIKE", num + "%");
      } else {
        w2 = new Where(this.tableComptePCE.getField("NUMERO"), "=", num);
      }
      w = w.and(w2);
    } else {
      w = w.and(new Where(this.tableComptePCE.getKey(), "=", idCpt));
    }

    // final Calendar cal = Calendar.getInstance();
    // cal.setTimeInMillis(this.rangeSlide.getValue(0));
    //
    // Date dInf = cal.getTime();
    // cal.setTimeInMillis(this.rangeSlide.getValue(1));
    // Date dSup = cal.getTime();

    // w = w.and(new Where(this.tableEcr.getField("DATE"), dInf, dSup));

    Date d1 = this.dateDeb.getValue();
    Date d2 = this.dateFin.getValue();

    if (d1 == null && d2 != null) {
      w = w.and(new Where(this.tableEcr.getField("DATE"), "<=", d2));
    } else {
      if (d1 != null && d2 == null) {
        w = w.and(new Where(this.tableEcr.getField("DATE"), ">=", d1));
      } else {
        if (d1 != null && d2 != null) {
          w = w.and(new Where(this.tableEcr.getField("DATE"), d1, d2));
        }
      }
    }

    if (this.modeSelect == ecritureLettree) {
      w = w.and(new Where(this.tableEcr.getField("LETTRAGE"), "!=", ""));
    } else {
      if (this.modeSelect == ecritureNonLettree) {

        Where wLettre = new Where(this.tableEcr.getField("LETTRAGE"), "=", "");
        String s = null;
        wLettre = wLettre.or(new Where(this.tableEcr.getField("LETTRAGE"), "=", s));
        w = w.and(wLettre);
      }
    }

    this.ecriturePanel.getListe().getRequest().setWhere(w);
    this.ecriturePanel.getListe().setSQLEditable(false);

    this.model.setIdCompte(Integer.parseInt(idCpt.toString()));
  }