public String getAllPeriods() { String txt = ""; if (esborra) { return txt; } for (int i = 0; i < listmodel1.size(); i++) { String item = (String) listmodel1.get(i); String date1 = StringUtils.BeforeFirst(item, "a").trim(); String date2 = StringUtils.AfterFirst(item, "a").trim(); if (date1.equals(date2)) { txt += date1 + ", "; } else { txt += item + ", "; } } return StringUtils.BeforeLast(txt, ","); }
public String2Date(String input) { String iniString = ""; String finString = ""; if (input.contains("a")) { iniString = StringUtils.BeforeFirst(input, "a").trim(); finString = StringUtils.AfterFirst(input, "a").trim(); } else { iniString = input.trim(); finString = iniString; } SimpleDateFormat df = null; if (input.contains("-")) { df = new SimpleDateFormat("dd-MM-yyyy"); } else { df = new SimpleDateFormat("dd/MM/yyyy"); } try { date1 = df.parse(iniString); date2 = df.parse(finString); } catch (ParseException ex) { Logger.getLogger(PeriodSelect.class.getName()).log(Level.SEVERE, null, ex); } }
// 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