Exemplo n.º 1
0
 private void doPdfStarten(int art) {
   int row = tabbericht.getSelectedRow();
   if (row < 0) {
     JOptionPane.showMessageDialog(null, "Kein Bericht für Datenübernahme ausgewählt");
     return;
   }
   new LadeProg(
       Reha.proghome
           + "PDFLoader.jar "
           + Integer.toString(art)
           + " "
           + tabbericht.getValueAt(row, 0).toString()
           + " "
           + SystemConfig.PDFformularPfad
           + " "
           + Reha.proghome
           + "ini/"
           + Reha.aktIK
           + "/fremdprog.ini"
           + " "
           + Reha.thisClass.patpanel.patDaten.get(29)
           + " "
           + Reha.proghome
           + "ini/"
           + Reha.aktIK
           + "/rehajava.ini");
 }
Exemplo n.º 2
0
 public void aktualisiereGutachten(
     String editdat, String bertype, String empf, String verfasser, int berid, String patintern) {
   String cmd =
       "update berhist set berichttyp='"
           + bertype
           + "', empfaenger='"
           + empf
           + "', editdat='"
           + DatFunk.sDatInSQL(editdat)
           + "', verfasser='"
           + verfasser
           + "' where berichtid='"
           + berid
           + "'";
   SqlInfo.sqlAusfuehren(cmd);
   int row = tabbericht.getSelectedRow();
   if (!Reha.thisClass.patpanel.aktPatID.equals(patintern)) {
     JOptionPane.showMessageDialog(
         null, "Der aktuelle Patient und das zu speichernde Gutachten passen nicht zusammen...");
     return;
   }
   if (dtblm.getValueAt(row, 0).equals(Integer.toString(berid))) {
     dtblm.setValueAt(bertype, row, 1);
     dtblm.setValueAt(verfasser, row, 2);
     dtblm.setValueAt(empf, row, 4);
     dtblm.setValueAt(editdat, row, 5);
   }
 }
 private void selectDownloadToShowOnDownloadGrid() {
   DownloadWrapper d = null;
   if (table.getSelectedRow() == -1) {
     d = selectDownloadToShowOnDownloadGridIgnoringSelection();
   } else {
     DownloadWrapper dw = rows.get(table.getSelectedRow());
     if (dw != null
         && dw.download != null
         && !dw.download.isComplete()
         && dw.download.isActive()) {
       d = dw;
     } else {
       d = selectDownloadToShowOnDownloadGridIgnoringSelection();
     }
   }
   if (d != null && downloadGrid != null) {
     downloadGrid.setDownload(d.download);
   }
   interestingDownloadWrapper = d;
 }
  private void editSelectedGroup() {

    WSISecurityGroup group = groupTableModel.getSecurityGroupAtRow(tblGroupPerms.getSelectedRow());

    if (group == null) return;

    for (WSISecurityGroup grp :
        (ArrayList<WSISecurityGroup>)
            Dictionary.getDictionaryAsArrayList("securityGroupDictionary")) {
      if (grp.getId().equals(group.getId())) {
        group = grp;
        break;
      }
    }

    GroupUIView groupDialog =
        new GroupUIView(
            null, true, group, groupTableModel.getWSIPermissionAt(tblGroupPerms.getSelectedRow()));
    groupDialog.setVisible(true);
  }
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 private void cbxAbgearbeitetActionPerformed(final java.awt.event.ActionEvent evt) {
   try {
     final int displayedIndex = jXTable1.getSelectedRow();
     final int modelIndex = jXTable1.getFilters().convertRowIndexToModel(displayedIndex);
     final CidsBean selectedFortfuehrungBean =
         ((FortfuehrungenTableModel) jXTable1.getModel()).getCidsBeanByIndex(modelIndex);
     selectedFortfuehrungBean.setProperty(
         FortfuehrungPropertyConstants.PROP__IST_ABGEARBEITET, cbxAbgearbeitet.isSelected());
     selectedFortfuehrungBean.persist();
     jXTable1.repaint();
   } catch (Exception ex) {
     LOG.error("fehler beim setzen von ist_abgearbeitet", ex);
   }
 }
  private void delete_branch_locations() {
    int row = tbl_branch_locations.getSelectedRow();
    if (row < 0) {
      return;
    }
    final to_branch_locations to =
        (to_branch_locations)
            tbl_branch_locations_ALM.get(tbl_branch_locations.convertRowIndexToModel(row));
    if (to.status == 1) {
      Alert.set(0, "Cannot Delete Default Location");
      return;
    }
    Window p = (Window) this;
    Dlg_auth nd = Dlg_auth.create(p, true);
    nd.setTitle("");
    nd.setCallback(
        new Dlg_auth.Callback() {

          @Override
          public void ok(CloseDialog closeDialog, Dlg_auth.OutputData data) {
            closeDialog.ok();
            jProgressBar1.setString("Loading...Please wait...");
            jProgressBar1.setIndeterminate(true);
            btn_new.setEnabled(false);
            btn_add.setEnabled(false);
            btn_edit.setEnabled(false);
            btn_delete.setEnabled(false);
            Thread t =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        S1_branch_locations.delete_branch_locations(to);
                        data_cols();
                        clear_branch_locations();
                        Alert.set(3, "");
                        jProgressBar1.setString("Finished...");
                        jProgressBar1.setIndeterminate(false);
                        btn_new.setEnabled(true);
                        btn_add.setEnabled(true);
                        btn_edit.setEnabled(true);
                        btn_delete.setEnabled(true);
                      }
                    });
            t.start();
          }
        });
    nd.setLocationRelativeTo(jScrollPane2);
    nd.setVisible(true);
  }
  private void editSelectedUser() {
    WSISecurityUser user = userTableModel.getSecurityUserAtRow(tblUserPerms.getSelectedRow());

    for (WSISecurityUser usr :
        (ArrayList<WSISecurityUser>)
            Dictionary.getDictionaryAsArrayList("securityUserDictionary")) {
      if (usr.getId().equals(user.getId())) {
        user = usr;
        break;
      }
    }

    UserUIView userDialog = new UserUIView(null, true, user);
    userDialog.setVisible(true);
  }
  @Override
  public void valueChanged(ListSelectionEvent arg) {

    if (!arg.getValueIsAdjusting() && this.acceptListEvents) {
      int col = combinedRulesTable.getSelectedColumn();
      int row = combinedRulesTable.getSelectedRow();
      consoleLogger.debug("Selected ROW: " + row + " - COL: " + col);
      String rule =
          String.valueOf(
              combinedRulesTable.getValueAt(row, CombinedRulesTableColumns.RULE_NUMBER.ordinal()));
      //   System.out.println("rule:::::"+rule);
      this.firePropertyChange(FIRING_PROPERTY, this.selectedCombinedRule, rule);
      this.selectedCombinedRule = rule;
    }
  }
Exemplo n.º 9
0
 private void doBerichtEdit() {
   int row = tabbericht.getSelectedRow();
   // System.out.println("in doBerichtEdit");
   if (row < 0) {
     // System.out.println("keine Zeile vorhanden also return");
     return;
   }
   String bertyp = (String) tabbericht.getValueAt(row, 1);
   int berid = Integer.parseInt(tabbericht.getValueAt(row, 0).toString());
   String berempfaenger = (String) tabbericht.getValueAt(row, 4);
   Reha.thisClass.progLoader.GutachenFenster(
       1, Reha.thisClass.patpanel.aktPatID, berid, bertyp, false, berempfaenger, -1);
   // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
   // ,berid,bertyp,false,berempfaenger );
   // ProgLoader.InternalGut2();
 }
Exemplo n.º 10
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    String cmd = arg0.getActionCommand();
    if (cmd.equals("gutneu")) {
      if (!Rechte.hatRecht(Rechte.Gutachten_anlegen, true)) {
        return;
      }
      final JComponent comp = ((JComponent) arg0.getSource());
      new SwingWorker<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
          try {
            JRtaTextField tf = new JRtaTextField("nix", false);
            // System.out.println("in GutachtenWahl");
            GutachtenWahl gwahl =
                new GutachtenWahl(
                    (Point) comp.getLocationOnScreen(), tf, "Neues Gutachten erstellen");
            // System.out.println("Aufruf des Focus***********");
            gwahl.setzeFocus();
            gwahl.setVisible(true);
            // gwahl.setModal(true);

            // System.out.println("Der Rückgabewert der Auswahl = "+tf.getText() );
            if (tf.getText().equalsIgnoreCase("ebericht")) {
              Reha.thisClass.progLoader.GutachenFenster(
                  1, Reha.thisClass.patpanel.aktPatID, -1, "E-Bericht", true, "", -1);
              // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
              // ,-1,"E-Bericht",true,"" );
              return null;
            }
            if (tf.getText().equalsIgnoreCase("nachsorge")) {
              Reha.thisClass.progLoader.GutachenFenster(
                  1, Reha.thisClass.patpanel.aktPatID, -1, "Nachsorge", true, "", -1);
              // ProgLoader.GutachenFenster(1,Reha.thisClass.patpanel.aktPatID
              // ,-1,"Nachsorge",true,"" );
              return null;
            }
            gwahl = null;
          } catch (Exception ex) {
            ex.printStackTrace();
          }

          return null;
        }
      }.execute();
      return;
    }
    if (cmd.equals("gutedit")) {
      if (!Rechte.hatRecht(Rechte.Gutachten_editvoll, true)) {
        return;
      }
      doBerichtEdit();
      return;
    }
    if (cmd.equals("gutdelete")) {
      if (aktPanel.equals("leerPanel")) {
        JOptionPane.showMessageDialog(
            null,
            "Oh Herr laß halten...\n\n"
                + "....und welches der nicht vorhandenen Gutachten möchten Sie bitteschön löschen....");
        return;
      }
      if (!Rechte.hatRecht(Rechte.Gutachten_delete, true)) {
        return;
      }
      int currow = tabbericht.getSelectedRow();
      // int anzrow = tabbericht.getRowCount();
      if (currow == -1) {
        JOptionPane.showMessageDialog(null, "Kein Gutachten zum -> löschen <- ausgewählt");
        return;
      }
      String berichtid = (String) tabbericht.getValueAt(currow, 0);
      int frage =
          JOptionPane.showConfirmDialog(
              null,
              "Wollen Sie das Gutachten mit der ID:" + berichtid + " wirklich löschen?",
              "Wichtige Benutzeranfrage",
              JOptionPane.YES_NO_OPTION);
      if (frage == JOptionPane.NO_OPTION) {
        return;
      }
      String sqlcmd = "delete from berhist where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);
      sqlcmd = "delete from bericht2 where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);
      sqlcmd = "delete from bericht2ktl where berichtid='" + berichtid + "'";
      new ExUndHop().setzeStatement(sqlcmd);

      currow = TableTool.loescheRow(tabbericht, Integer.valueOf(currow));
      int uebrig = tabbericht.getRowCount();

      anzahlGutachten.setText("Anzahl Gutachten: " + Integer.toString(uebrig));
      Reha.thisClass.patpanel.getTab().setTitleAt(4, macheHtmlTitel(uebrig, "Gutachten"));
      if (uebrig <= 0) {
        holeGutachten(Reha.thisClass.patpanel.patDaten.get(29), "");
      } else {
      }

      return;
    }
    if (cmd.equals("guttools")) {
      new ToolsDlgGutachten("", gutbut[3].getLocationOnScreen());
      return;
    }
  }
Exemplo n.º 11
0
  @Override
  public void setListeners() {
    iSearchField.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            isAddingRows = true;
            iSearchField.setText(Formatter.makeUpperCase(iSearchField.getText()));
            String input = iSearchField.getText();
            List<Products> productWithID =
                products
                    .stream()
                    .filter(
                        (p) ->
                            (p.getAddmotoCode().toUpperCase().contains(input.toUpperCase())
                                    || (p.getDescription()
                                            + " "
                                            + p.getCharacteristics()
                                            + p.getMotors())
                                        .replaceAll("\\s+", " ")
                                        .trim()
                                        .toUpperCase()
                                        .contains(input.toUpperCase()))
                                || getProductLineName(p.getProductLineID())
                                    .toUpperCase()
                                    .contains(input.toUpperCase()))
                    .collect(Collectors.toList());

            while (tableModel.getRowCount() > 0) {
              tableModel.removeRow(0);
            }
            for (Products product : productWithID) {
              tableModel.addRow(
                  new Object[] {
                    String.valueOf(product.getProductID()),
                    product.getAddmotoCode(),
                    productLineMap.get(product.getProductLineID()),
                    (product.getDescription()
                            + " "
                            + product.getCharacteristics()
                            + " "
                            + product.getMotors())
                        .replaceAll("\\s+", " ")
                        .trim(),
                    "PhP " + Formatter.format(product.getUnitPrice()),
                    "PhP " + Formatter.format(product.getSellingPrice())
                  });
            }
            isAddingRows = false;
          }
        });

    iAddNewPLine.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String newProductLine =
                JOptionPane.showInputDialog(
                    null, "Product Line Name:", "New Product Line", JOptionPane.QUESTION_MESSAGE);

            try {
              if (newProductLine.equals("")) {
                JOptionPane.showMessageDialog(
                    null,
                    "You cannot create an empty product line name.",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);
              } else {
                int rows = model.insertNewProductLine(newProductLine);
                if (rows != 0) {
                  JOptionPane.showMessageDialog(
                      null,
                      "Product Line list updated.",
                      "Success",
                      JOptionPane.INFORMATION_MESSAGE);
                  populate();
                } else {
                  JOptionPane.showMessageDialog(
                      null,
                      "Product Line may be existing already!",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                }
              }
            } catch (Exception ex) {

            }
          }
        });

    iShowHistory.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JOptionPane.showMessageDialog(view, "Clicked");
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iShowHistory);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setWhiteForeground(iShowHistory);
          }
        });

    iSellingPrice.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iSellingPrice.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iSellingPrice.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iUnitCost.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iUnitCost.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iUnitCost.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyThreshold.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            iQtyThreshold.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    iSellingPrice.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iSellingPrice.getText().contains("."))
                || (ch == '.' && iSellingPrice.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyThreshold.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateRSP.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateRSP.getText().equals("Edit")) {
                sellingPriceValue = iSellingPrice.getText();
                setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, false);
              } else if (iEditUpdateRSP.getText().equals("Update")) {
                if (iSellingPrice.getText().equals("")
                    || iUnitCost.getText().equals("")
                    || iSellingPrice.getText().split("\\.")[1].length() > 2
                    || iUnitCost.getText().split("\\.")[1].length() > 2) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iSellingPrice.setText(String.valueOf(sellingPriceValue));
                } else {
                  double sellingPrice = Double.parseDouble(iSellingPrice.getText());
                  double unitPrice = Double.parseDouble(iUnitCost.getText());

                  if (sellingPrice >= unitPrice * 1.30) {
                    int option =
                        JOptionPane.showConfirmDialog(
                            null,
                            "Are you sure you want to proceed with the update?",
                            "Confirm",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (option == JOptionPane.YES_OPTION) {
                      int itemID = Integer.parseInt(iItemNumber.getText());
                      int updatedRow = model.updateSellingPrice(itemID, sellingPrice);
                      if (updatedRow != 0) {
                        JOptionPane.showMessageDialog(
                            null,
                            "Product selling price updated!",
                            "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                        setIndexZero();
                        setDefaultViews();
                        isAddingRows = true;
                        populate();
                        isAddingRows = false;
                      } else {
                        JOptionPane.showMessageDialog(
                            null,
                            "There is an error while updating item selling price.",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                      }
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null,
                        "You must have atleast 30% profit for this item.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                  }
                }
                setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateRSP);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateRSP);
          }
        });

    iUnitCost.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iUnitCost.getText().contains("."))
                || (ch == '.' && iUnitCost.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateUC.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateUC.getText().equals("Edit")) {
                unitCostValue = iUnitCost.getText();
                setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, false);
              } else if (iEditUpdateUC.getText().equals("Update")) {
                if (iSellingPrice.getText().equals("")
                    || iUnitCost.getText().equals("")
                    || iSellingPrice.getText().split("\\.")[1].length() > 2
                    || iUnitCost.getText().split("\\.")[1].length() > 2) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iUnitCost.setText(String.valueOf(unitCostValue));
                } else {
                  double sellingPrice = Double.parseDouble(iSellingPrice.getText());
                  double unitPrice = Double.parseDouble(iUnitCost.getText());

                  if (sellingPrice >= unitPrice * 1.30) {
                    int option =
                        JOptionPane.showConfirmDialog(
                            null,
                            "Are you sure you want to proceed with the update?",
                            "Confirm",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (option == JOptionPane.YES_OPTION) {
                      int itemID = Integer.parseInt(iItemNumber.getText());
                      int updatedRow = model.updateUnitPrice(itemID, unitPrice);
                      if (updatedRow != 0) {
                        JOptionPane.showMessageDialog(
                            null,
                            "Product unit price updated!",
                            "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                        setIndexZero();
                        setDefaultViews();
                        isAddingRows = true;
                        populate();
                        isAddingRows = false;
                      } else {
                        JOptionPane.showMessageDialog(
                            null,
                            "There is an error while updating item unit price.",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                      }
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null,
                        "You must have atleast 30% profit for this item.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                  }
                }
                setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateUC);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateUC);
          }
        });

    iQtyThreshold.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iEditUpdateQT.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (!iAddMotoCode.getText().equals("")) {
              if (iEditUpdateQT.getText().equals("Edit")) {
                qtyThresholdValue = iQtyThreshold.getText();
                setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, false);
              } else if (iEditUpdateQT.getText().equals("Update")) {
                if (iQtyThreshold.getText().equals("")) {
                  JOptionPane.showMessageDialog(
                      null,
                      "There are empty fields or number format is invalid",
                      "Error",
                      JOptionPane.ERROR_MESSAGE);
                  iQtyThreshold.setText(String.valueOf(qtyThresholdValue));
                } else {
                  int threshold = Integer.parseInt(iQtyThreshold.getText());
                  int option =
                      JOptionPane.showConfirmDialog(
                          null,
                          "Are you sure you want to proceed with the update?",
                          "Confirm",
                          JOptionPane.YES_NO_OPTION,
                          JOptionPane.QUESTION_MESSAGE);
                  if (option == JOptionPane.YES_OPTION) {
                    int itemID = Integer.parseInt(iItemNumber.getText());
                    int updatedRow = model.updateThreshold(itemID, threshold);
                    if (updatedRow != 0) {
                      JOptionPane.showMessageDialog(
                          null,
                          "Product threshold count updated!",
                          "Success",
                          JOptionPane.INFORMATION_MESSAGE);
                      setIndexZero();
                      setDefaultViews();
                      isAddingRows = true;
                      populate();
                      isAddingRows = false;
                    } else {
                      JOptionPane.showMessageDialog(
                          null,
                          "There is an error while updating item threshold count.",
                          "Error",
                          JOptionPane.ERROR_MESSAGE);
                    }
                  }
                }
                setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, true);
              }
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iEditUpdateQT);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iEditUpdateQT);
          }
        });

    iCancelRSP.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iSellingPrice.setText(sellingPriceValue);
            setToDefault(iSellingPrice, iEditUpdateRSP, iCancelRSP, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelRSP);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelRSP);
          }
        });

    iCancelUC.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iUnitCost.setText(unitCostValue);
            setToDefault(iUnitCost, iEditUpdateUC, iCancelUC, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelUC);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelUC);
          }
        });

    iCancelQT.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            iQtyThreshold.setText(qtyThresholdValue);
            setToDefault(iQtyThreshold, iEditUpdateQT, iCancelQT, true);
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            setRedForeground(iCancelQT);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            setBlackForeground(iCancelQT);
          }
        });

    selectionModel.addListSelectionListener(
        (ListSelectionEvent e) -> {
          if (e.getValueIsAdjusting()) {
            return;
          }
          if (!isAddingRows) {
            int row = iProductsTable.getSelectedRow();
            int ID = Integer.parseInt((String) iProductsTable.getValueAt(row, 0));
            System.out.println("ID -> " + ID);
            iProductsTable.scrollRowToVisible(row);
            showProductDetails(ID);
          }
        });

    iSellingPriceText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iSellingPriceText.getText().contains("."))
                || (ch == '.' && iSellingPriceText.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iUnitPriceText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE)
                || (ch == '.'))) {
              tk.beep();
              e.consume();
            } else if ((ch == '.' && iUnitPriceText.getText().contains("."))
                || (ch == '.' && iUnitPriceText.getText().equals(""))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iQtyText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iThresholdText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {
            char ch = e.getKeyChar();
            if (!((ch >= '0') && (ch <= '9')
                || (ch == KeyEvent.VK_BACK_SPACE)
                || (ch == KeyEvent.VK_DELETE))) {
              tk.beep();
              e.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    iAddNew.addActionListener(
        (ActionEvent e) -> {
          int choice =
              JOptionPane.showOptionDialog(
                  view,
                  addItem,
                  "ADD Moto - Motorcycle Parts and Accessories",
                  JOptionPane.OK_CANCEL_OPTION,
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  null);
          if (choice == JOptionPane.OK_OPTION) {
            String supplierName = getFormattedString((String) iSupplierList.getSelectedItem());
            String productLine = getFormattedString((String) iProductLineList.getSelectedItem());
            String supplierCode = getFormattedString(iSupplierCodeText.getText());
            String unitPrice = getFormattedString(iUnitPriceText.getText());
            String sellingPrice = getFormattedString(iSellingPriceText.getText());
            String qtyOnHand = getFormattedString(iQtyText.getText());
            String threshold = getFormattedString(iThresholdText.getText());
            String characteristics = getFormattedString(iCharacteristics.getText());
            String _model = getFormattedString(iModelText.getText());
            String description = getFormattedString(iDescriptionText.getText());

            if (supplierName.isEmpty()
                || productLine.isEmpty()
                || supplierCode.isEmpty()
                || unitPrice.isEmpty()
                || sellingPrice.isEmpty()
                || qtyOnHand.isEmpty()
                || threshold.isEmpty()
                || characteristics.isEmpty()
                || _model.isEmpty()
                || description.isEmpty()) {
              JOptionPane.showMessageDialog(
                  view, "All fields must not be empty!", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
              Products product =
                  new Products(
                      productLine.toUpperCase().substring(0, 2) + "AD" + supplierCode,
                      supplierCode,
                      parseInt(qtyOnHand),
                      parseDouble(unitPrice),
                      parseDouble(sellingPrice),
                      parseDouble(sellingPrice) - parseDouble(unitPrice),
                      parseInt(threshold),
                      null,
                      description,
                      characteristics,
                      _model,
                      getKeybyValue_p(productLine),
                      getKeybyValue_s(supplierName));
              System.out.println(product.toString());
              int returnValue = model.addNewProduct(product);
              if (returnValue == 0) {
                JOptionPane.showMessageDialog(
                    view, "There must be some kind of error.", "Error", JOptionPane.ERROR_MESSAGE);
              } else {
                JOptionPane.showMessageDialog(
                    view,
                    "Successfully added new product!",
                    "Success",
                    JOptionPane.INFORMATION_MESSAGE);
                setIndexZero();
                setDefaultViews();
                isAddingRows = true;
                repopulateTable();
                isAddingRows = false;
              }
            }
          }
        });
  }
Exemplo n.º 12
0
  /**
   * DOCUMENT ME!
   *
   * @param e DOCUMENT ME!
   */
  private void fortfuehrungsTableListSelectionChanged(final ListSelectionEvent e) {
    final int selectedIndex = jXTable1.getSelectedRow();
    final CidsBean selectedFortfuehrungBean;
    if (selectedIndex >= 0) {
      final int rowIndex = jXTable1.convertRowIndexToModel(selectedIndex);
      selectedFortfuehrungBean =
          ((FortfuehrungenTableModel) jXTable1.getModel()).getCidsBeanByIndex(rowIndex);
    } else {
      selectedFortfuehrungBean = null;
    }
    if (selectedFortfuehrungBean != null) {
      new SwingWorker<Set<Integer>, Void>() {

        @Override
        protected Set<Integer> doInBackground() throws Exception {
          lstKassenzeichen.setEnabled(false);
          cbxAbgearbeitet.setEnabled(false);
          jProgressBar1.setVisible(true);
          final List<CidsBean> geomBeans =
              (List<CidsBean>)
                  selectedFortfuehrungBean.getBeanCollectionProperty(
                      FortfuehrungPropertyConstants.PROP__GEOMETRIEN);
          final KassenzeichenGeomSearch geomSearch = new KassenzeichenGeomSearch();
          final Set<Integer> kassenzeichennummern = new HashSet<Integer>();
          for (final CidsBean geomBean : geomBeans) {
            if (geomBean != null) {
              try {
                final Geometry geom =
                    (Geometry) geomBean.getProperty(GeomPropertyConstants.PROP__GEO_FIELD);
                geomSearch.setGeometry(geom.buffer(FLURSTUECKBUFFER_FOR_KASSENZEICHEN_GEOMSEARCH));
                kassenzeichennummern.addAll(
                    (Collection<Integer>)
                        SessionManager.getProxy()
                            .customServerSearch(SessionManager.getSession().getUser(), geomSearch));
              } catch (final Exception ex) {
                LOG.error("fehler beim suchen von kassenzeichen über eine geometrie", ex);
              }
            }
          }
          return kassenzeichennummern;
        }

        @Override
        protected void done() {
          try {
            final Set<Integer> kassenzeichennummern = get();
            setDetailEnabled(true);
            setKassenzeichenNummern(kassenzeichennummern);
            cbxAbgearbeitet.setSelected(
                (Boolean)
                    selectedFortfuehrungBean.getProperty(
                        FortfuehrungPropertyConstants.PROP__IST_ABGEARBEITET));

            final CidsBean urlBean =
                (CidsBean)
                    selectedFortfuehrungBean.getProperty(
                        FortfuehrungPropertyConstants.PROP__DOKUMENTURL);
            final String protPrefix = (String) urlBean.getProperty("url_base_id.prot_prefix");
            final String server = (String) urlBean.getProperty("url_base_id.server");
            final String path = (String) urlBean.getProperty("url_base_id.path");
            final String objectName = (String) urlBean.getProperty("object_name");
            final String urlString = protPrefix + server + path + objectName;
            setDokumentLink(urlString);
          } catch (final Exception ex) {
            setKassenzeichenNummern(null);
            cbxAbgearbeitet.setSelected(false);
            LOG.fatal("", ex);
          }
          lstKassenzeichen.setEnabled(true);
          cbxAbgearbeitet.setEnabled(true);
          jProgressBar1.setVisible(false);
        }
      }.execute();
    } else {
      setDetailEnabled(false);
      setKassenzeichenNummern(null);
      cbxAbgearbeitet.setSelected(false);
      setDokumentLink(null);
    }
  }