コード例 #1
0
  public int miseAJourStatutCommande() {

    ConnexionBD bd = new ConnexionBD();
    Statement st = bd.createStatement();
    int rs = 0;
    try {

      // on regarde combie de colis à la commande correspondant au colis controle
      ResultSet i =
          st.executeQuery(
              "SELECT id_commande, count(id_colis) FROM "
                  + Constantes.base_colis
                  + " WHERE id_colis = "
                  + id
                  + " GROUP BY id_commande;");

      if (i.next()) {

        int numCommande = i.getInt(1);
        int nbColis = i.getInt(2);

        // i.close();

        // on récupère les colis donc le statut à été controle, cad passer par la douane et approuvé
        ResultSet g =
            st.executeQuery(
                " SELECT id_colis FROM "
                    + Constantes.base_colis
                    + " WHERE id_commande = "
                    + numCommande
                    + " AND statut IN ('controle', 'emballe') GROUP BY id_colis;");
        if (g.next()) {
          g.last();
          int nombreColis = g.getRow();
          g.beforeFirst();
          // si le nombre de colis de la commande est égal au nombre de colis controle de la
          // commande, on peut changer le statut de la commande a expedie
          if (nbColis == nombreColis) {
            rs =
                st.executeUpdate(
                    "UPDATE "
                        + Constantes.base_commande
                        + " SET statut = 'expediee' WHERE id_commande = "
                        + numCommande
                        + ";");
          }

        } else {
          System.out.println("NOOOON");
        }

      } else {
        System.out.println("RIEEEEN");
      }

    } catch (SQLException e) {
      e.printStackTrace();
    }
    return rs;
  }
コード例 #2
0
  public void updateInfos() {

    ConnexionBD bd = new ConnexionBD();
    Statement st = bd.createStatement();

    try {
      ResultSet rs =
          st.executeQuery(
              "SELECT id_colis, id_commande, cast(date_emballage as varchar) FROM "
                  + Constantes.base_colis
                  + " natural join "
                  + Constantes.base_emballage
                  + " WHERE id_colis ="
                  + id
                  + ";");

      int col, com;
      String embal;

      if (rs.next()) {
        // rs.previous();

        col = rs.getInt(1);
        com = rs.getInt(2);
        embal = rs.getString(3);
        // q = rs.getInt(4);

        colis.setText(String.valueOf(col));
        commande.setText(String.valueOf(com));
        date.setText(embal);
        // qual.setText(String.valueOf(q));

      }
      rs.close();
      st.close();
      bd.close();

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
コード例 #3
0
  public int miseAJour(String statutC) {

    ConnexionBD bd = new ConnexionBD();
    Statement st = bd.createStatement();
    int rs = 0;
    try {
      rs =
          st.executeUpdate(
              "UPDATE "
                  + Constantes.base_colis
                  + " SET statut = '"
                  + statutC
                  + "' WHERE id_colis = "
                  + id
                  + ";");
      miseAJourStatutCommande();

    } catch (SQLException e) {
      e.printStackTrace();
    }
    return rs;
  }
コード例 #4
0
  public InfosColis(int idColis, String statut) {

    ConnexionBD conn = new ConnexionBD();
    Statement st = conn.createStatement();
    ResultSet rs;

    try {

      rs =
          st.executeQuery(
              "SELECT id_produit, quantite FROM "
                  + Constantes.base_contenuColis
                  + " WHERE id_colis="
                  + idColis
                  + ";");

      LinkedList<Object[]> save = new LinkedList<Object[]>();

      while (rs.next()) {

        Object[] data = new Object[2];

        data[0] = rs.getString(1);
        data[1] = rs.getInt(2);
        save.add(data);
      }

      donnees = new Object[save.size()][];

      for (int i = 0; i < donnees.length; i++) {
        donnees[i] = save.get(i);
      }

      // --Table

      DefaultTableModel tableModel =
          new DefaultTableModel(donnees, columnNames) {
            private static final long serialVersionUID = 1L;

            public boolean isCellEditable(int iRowIndex, int iColumnIndex) {
              return false;
            }
          };

      jt = new JTable(tableModel);

    } catch (SQLException e) {
      e.printStackTrace();
    }

    panelTable = new JPanel();
    // panelTable.setVisible(true);

    panelTable.setLayout(new BorderLayout());

    panelTable.add(jt.getTableHeader(), BorderLayout.PAGE_START);
    // panelTable.add(new JScrollPane(jt), BorderLayout.CENTER);
    panelTable.add(jt, BorderLayout.CENTER);
    panelTable.setVisible(false);

    // panelTable.repaint();
    // scrollJT.revalidate();
    // panelTable.revalidate();

    ImageIcon iconeDerouler = new ImageIcon();
    try {
      BufferedImage img = ImageIO.read(new File("src/ic_menu_add.png"));
      Image resize = img.getScaledInstance(20, 20, Image.SCALE_SMOOTH);
      iconeDerouler.setImage(resize);
    } catch (IOException e) {
      e.printStackTrace();
    }
    derouler = new JButton(iconeDerouler);
    derouler.addActionListener(this);
    derouler.setContentAreaFilled(false);
    derouler.setBorderPainted(false);

    JLabel infos = new JLabel("ID: " + idColis + " [" + statut + "]");

    entete = new JPanel();
    entete.add(derouler);
    entete.add(infos);

    this.setLayout(new BorderLayout());
    this.add(entete, BorderLayout.NORTH);
    this.add(panelTable, BorderLayout.CENTER);
    // this.revalidate();
  }