Пример #1
0
  public void doDBUpdate(boolean write) {

    String SQL1 = "DELETE FROM tuta_dies_sancions WHERE idActuacio=" + idTask;
    int nup = coreCfg.getMysql().executeUpdate(SQL1);

    if (write && mexp2 > 0 && idTask > 0) {
      for (int i = 0; i < listmodel1.size(); i++) {
        String cmd = (String) listmodel1.get(i);
        String2Date s2d = new String2Date(cmd);

        String SQL2 =
            "INSERT INTO tuta_dies_sancions (exp2, idActuacio, desde, fins, tipus) VALUES (?,?,?,?,?)";
        Object[] obj = new Object[] {mexp2, idTask, s2d.getInici(), s2d.getFinal(), mtipus};
        nup = coreCfg.getMysql().preparedUpdate(SQL2, obj);
      }
    }
  }
Пример #2
0
  private void checkSignatures() {
    if (!isListening) {
      return;
    }

    jTextArea1.append("Dia " + jDateChooser1.getDate() + "\n");
    // Comprova si el dia triat té o no signatures
    String SQL1 =
        "Select count(id) as total from sig_signatures where data='"
            + new DataCtrl(jDateChooser1.getDate()).getDataSQL()
            + "'";
    try {
      Statement st = coreCfg.getMysql().createStatement();
      ResultSet rs1 = coreCfg.getMysql().getResultSet(SQL1, st);
      if (rs1 != null && rs1.next()) {
        jTextArea1.append("> Núm. signatures matí=" + rs1.getInt("total") + "\n");
      }
      if (rs1 != null) {
        rs1.close();
        st.close();
      }
    } catch (SQLException ex) {
      Logger.getLogger(EsborraSig.class.getName()).log(Level.SEVERE, null, ex);
    }
    // Comprova si el dia triat té o no signatures
    SQL1 =
        "Select count(id) as total from sig_signatures_tarda where data='"
            + new DataCtrl(jDateChooser1.getDate()).getDataSQL()
            + "'";
    try {
      Statement st = coreCfg.getMysql().createStatement();
      ResultSet rs1 = coreCfg.getMysql().getResultSet(SQL1, st);
      if (rs1 != null && rs1.next()) {
        jTextArea1.append("> Núm. signatures tarda=" + rs1.getInt("total") + "\n");
      }
      if (rs1 != null) {
        rs1.close();
        st.close();
      }
    } catch (SQLException ex) {
      Logger.getLogger(EsborraSig.class.getName()).log(Level.SEVERE, null, ex);
    }
    jTextArea1.append("\n");
  }
Пример #3
0
  // ESBORRA
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    if (jCheckBox2.isSelected() && jTextField1.getText().length() == 0) {
      jTextField1.setFocusable(true);
      return;
    }

    DataCtrl cd = new DataCtrl(jDateChooser1.getDate());

    if (jCheckBox1.isSelected()) {

      // Confirmació
      int conf =
          JOptionPane.showConfirmDialog(
              this,
              "Estau a punt d'esborrar les "
                  + "signatures del dia "
                  + cd.getDiaMesComplet()
                  + "\nVoleu continuar?",
              "Confirmacio",
              JOptionPane.YES_NO_OPTION);

      if (conf != 0) {
        return;
      }

      // Tot el dia
      String SQL1 = "DELETE FROM sig_data where data='" + cd.getDataSQL() + "'";
      int nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_data: esborrades " + nup + "entrades\n");
      SQL1 = "DELETE FROM sig_signatures where data='" + cd.getDataSQL() + "'";
      nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_signatures: esborrades " + nup + "entrades\n");
      SQL1 = "DELETE FROM sig_signatures_tarda where data='" + cd.getDataSQL() + "'";
      nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_signatures_tarda: esborrades " + nup + "entrades\n");
      jTextArea1.append("Fet!\n");

      checkSignatures();
    } else {
      // Una franja
      // Determina inici i fi de la franja
      int ini = -1;
      int fin = -1;

      String sini = StringUtils.BeforeFirst(jTextField1.getText(), "-");
      String sfin = StringUtils.AfterFirst(jTextField1.getText(), "-");

      try {
        ini = Integer.parseInt(sini);
        fin = Integer.parseInt(sfin);
      } catch (java.lang.NumberFormatException e) {
        //
      }

      if (ini <= 0 || fin <= 0) {
        return;
      }

      if (fin < ini) {
        int ini0 = ini;
        ini = fin;
        fin = ini0;
      }

      // Confirmació
      int conf =
          JOptionPane.showConfirmDialog(
              this,
              "Estau a punt de convertir "
                  + "signatures ``?´´ del dia "
                  + cd.getDiaMesComplet()
                  + "\nen la franja "
                  + ini
                  + "a - "
                  + fin
                  + "a hores.\nVoleu continuar?",
              "Confirmacio",
              JOptionPane.YES_NO_OPTION);

      int newStatus = 1;
      if (jCheckBox4.isSelected()) {
        newStatus = -1;
      }

      if (conf != 0) {
        return;
      }

      for (int i = ini; i <= fin; i++) {
        if (i < 8) {
          String SQL1 =
              "UPDATE sig_signatures SET h"
                  + i
                  + "="
                  + newStatus
                  + " where data='"
                  + cd.getDataSQL()
                  + "' AND h"
                  + i
                  + "=0";
          int nup = coreCfg.getMysql().executeUpdate(SQL1);
          jTextArea1.append(" > sig_signatures: hora=" + i + ": convertits=" + nup + "\n");
        } else if (i >= 8 && i < 15) {
          String SQL1 =
              "UPDATE sig_signatures_tarda SET h"
                  + (i - 7)
                  + "="
                  + newStatus
                  + " where data='"
                  + cd.getDataSQL()
                  + "' AND h"
                  + (i - 7)
                  + "=0";
          int nup = coreCfg.getMysql().executeUpdate(SQL1);
          jTextArea1.append(" > sig_signatures_tarda: hora=" + i + ": convertits=" + nup + "\n");
        }
      }
      jTextArea1.append("Fet!\n");
    }
  } // GEN-LAST:event_jButton1ActionPerformed