예제 #1
0
  @SuppressWarnings("unchecked")
  public static final Map<String, Map<Integer, String>> getMapAllStyle() {
    Map<String, Map<Integer, String>> m = new HashMap<String, Map<Integer, String>>();
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLSelect sel = new SQLSelect(base);
    sel.addSelect(base.getField("STYLE.NOM"));
    String req = sel.asString();
    List<Map<String, Object>> l = base.getDataSource().execute(req);

    for (Map<String, Object> map : l) {

      Object o = map.get("NOM");
      String s = (o == null) ? null : o.toString();
      m.put(s, null);
    }
    m.put("BlankStyle", null);
    return m;
  }
예제 #2
0
파일: ActionDB.java 프로젝트: stephan1/my
  /**
   * Check si la table posséde au moins une ligne avec un ordre different null le cas cas échéant le
   * crée
   *
   * @param base
   */
  public static void correct(SQLBase base) {
    Set<String> tableNames = base.getTableNames();
    for (String tableName : tableNames) {

      if (base.getTable(tableName).contains("ORDRE")) {
        SQLSelect select = new SQLSelect(base);
        select.addSelect("ORDRE");
        List l = base.getDataSource().execute(select.asString());
        if (l == null || l.size() == 0) {
          SQLRowValues rowVals = new SQLRowValues(base.getTable(tableName));
          rowVals.put("ORDRE", 0);
          try {
            rowVals.commit();
          } catch (SQLException e) {

            e.printStackTrace();
          }
        }
      }
    }
    // TODO Checker que toutes les tables sont dans FWK_UNDEFINED_ID
  }
  private int[] getMouvement(int idPiece) {

    int[] idS = null;

    SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable tableMvt = b.getTable("MOUVEMENT");

    SQLSelect sel = new SQLSelect(b);
    sel.addSelect(tableMvt.getField("NUMERO"));
    sel.setWhere(tableMvt.getField("ID_PIECE"), "=", idPiece);

    List l = (List) b.getDataSource().execute(sel.asString(), new ArrayListHandler());

    if (l.size() > 0) {
      idS = new int[l.size()];
    }

    for (int i = 0; i < l.size(); i++) {
      Object[] tmp = (Object[]) l.get(i);
      idS[i] = Integer.parseInt(tmp[0].toString());
    }

    return idS;
  }
예제 #4
0
  /*
   * Crée un panel destiné à l'onglet de jrnl
   */
  private JPanel initJournalPanel(final Journal jrnl) {

    final JPanel panelTmp = new JPanel();
    long totalDebitJournal = 0;
    long totalCreditJournal = 0;

    panelTmp.setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    // Récupération des ecritures du journal avec le total par mois
    // SQLTable ecritureTable = base.getTable("ECRITURE");
    // SQLSelect sel = new SQLSelect(base);
    //
    // sel.addSelect(ecritureTable.getField("DATE"), "YEAR");
    // sel.addSelect(ecritureTable.getField("DATE"), "MONTH");
    // sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
    // sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
    //
    // Where w = new Where(ecritureTable.getField("ID_JOURNAL"), "=", jrnl.getId());
    //
    // sel.setWhere(w);
    //
    // sel.setDistinct(true);
    //
    // String req = sel.asString() + " GROUP BY YEAR(ECRITURE.DATE), MONTH(ECRITURE.DATE) ORDER
    // BY ECRITURE.DATE";

    String req =
        "SELECT DISTINCT EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"),"
            + " SUM(\""
            + baseName
            + "\".\"ECRITURE\".\"DEBIT\"), "
            + "SUM(\""
            + baseName
            + "\".\"ECRITURE\".\"CREDIT\")"
            + " FROM \""
            + baseName
            + "\".\"ECRITURE\" "
            + "WHERE (\""
            + baseName
            + "\".\"ECRITURE\".\"ID\" != 1) "
            + "AND ((\""
            + baseName
            + "\".\"ECRITURE\".\"ARCHIVE\" = 0) "
            + "AND (\""
            + baseName
            + "\".\"ECRITURE\".\"ID_JOURNAL\" = "
            + jrnl.getId()
            + ")) "
            + "GROUP BY EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\") "
            + "ORDER BY EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\")";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    // System.err.println("TEST DATE " + t);

    if (myList.size() != 0) {

      for (int i = 0; i < myList.size(); i++) {

        Object[] objTmp = (Object[]) myList.get(i);

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DATE, 1);
        int month = (new Double(objTmp[1].toString()).intValue() - 1);
        System.err.println(jrnl.getNom() + " SET MONTH " + month);
        cal.set(Calendar.MONTH, month);
        System.err.println(month + " = " + cal.getTime());

        cal.set(Calendar.YEAR, new Double(objTmp[0].toString()).intValue());

        long debitMois = ((Number) objTmp[2]).longValue();
        long creditMois = ((Number) objTmp[3]).longValue();

        c.gridwidth = GridBagConstraints.REMAINDER;
        final JPanel creerJournalMoisPanel =
            creerJournalMoisPanel(cal.getTime(), debitMois, creditMois, jrnl);
        creerJournalMoisPanel.setOpaque(false);
        panelTmp.add(creerJournalMoisPanel, c);

        c.gridy++;

        totalDebitJournal += debitMois;
        totalCreditJournal += creditMois;
      }
    }
    c.gridx = 0;
    c.weighty = 1;
    c.gridwidth = 1;
    final JLabel label = new JLabel("Journal " + jrnl.getNom());
    label.setOpaque(false);
    panelTmp.add(label, c);
    c.gridx = GridBagConstraints.RELATIVE;
    panelTmp.add(
        new JLabel(" Total débit : " + GestionDevise.currencyToString(totalDebitJournal)), c);
    panelTmp.add(
        new JLabel(" Total crédit : " + GestionDevise.currencyToString(totalCreditJournal)), c);

    return panelTmp;
  }