예제 #1
0
 public void excluir(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlExcluir = "DELETE FROM oriundo WHERE codigo=?";
   try {
     ps = con.prepareStatement(sqlExcluir);
     ps.setInt(1, oriundo.getCodigo());
     ps.executeUpdate();
     JOptionPane.showMessageDialog(
         null, "Ecluido Com Sucesso: ", "Mensagem do Sistema - Excluir", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Excluir", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
예제 #2
0
  protected TBMainAbstract(
      String strHelpID,
      ActionListener actListenerParent,
      // javax.help.HelpBroker hbrHelpStandard,
      int intOrientation,
      javax.swing.ImageIcon
          iinFrameFloatable, // should be used once bug fixed "setFloatable(true), see below
      boolean blnDoHelpOnItem,
      boolean blnFloatable) {
    super(intOrientation, iinFrameFloatable, strHelpID, blnFloatable);

    String strMethod = "TBMainAbstract(...)";

    try {
      this._btnHelpSource_ = new BESHelpJHSource();

      if (blnDoHelpOnItem) {
        this._btnHelpTrack_ = new BESHelpJHTrack();
      }
    } catch (NullPointerException excNullPointer) {
      excNullPointer.printStackTrace();
      MySystem.s_printOutExit(this, strMethod, "excNullPointerCaught");
    }

    this._btnExit_ = new BESExit24(actListenerParent);

    if (actListenerParent != null) super._btnPrint_ = new BESPrint24(actListenerParent);
  }
예제 #3
0
    public void actionPerformed(ActionEvent e) {
      JTextField fieldEdited = (JTextField) e.getSource();
      try {
        editingClassName = fieldEdited.getText();
      } catch (NullPointerException npex) {
        System.out.println("Null pointer exception in getting java class name");
        npex.printStackTrace();
      }

      String updatedStatusText = prepareStatusText();
      statusAreaTop.setText(updatedStatusText);
    }
예제 #4
0
 public List<Oriundo> listar() throws SQLException {
   List<Oriundo> resultado = new ArrayList<Oriundo>();
   conexao propCon = new conexao();
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           propCon.config.getString("usuario"),
           propCon.config.getString("senha"));
   PreparedStatement ps = null;
   ResultSet rs = null;
   String sqlListar = "SELECT * FROM oriundo Order by codigo DESC";
   Oriundo oriundo;
   try {
     ps = con.prepareStatement(sqlListar);
     rs = ps.executeQuery();
     // if(rs==null){
     // return null;
     // }
     while (rs.next()) {
       oriundo = new Oriundo();
       oriundo.setCodigo(rs.getInt("codigo"));
       oriundo.setDescricao(rs.getString("descricao"));
       oriundo.setData_cadastro(rs.getDate("data_cadastro"));
       oriundo.setDia_fechamento(rs.getInt("dia_fechamento"));
       oriundo.setDia_pag(rs.getInt("dia_pag"));
       resultado.add(oriundo);
     }
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
   return resultado;
 }
예제 #5
0
 public Oriundo localizar(Integer codigo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   ResultSet rs = null;
   String sqlLocalizar = "SELECT * FROM oriundo WHERE codigo=?";
   Oriundo oriundo = new Oriundo();
   try {
     ps = con.prepareStatement(sqlLocalizar);
     ps.setInt(1, codigo);
     rs = ps.executeQuery();
     // if(!rs.next()){
     // return null;
     // }
     oriundo.setCodigo(rs.getInt("codigo"));
     oriundo.setDescricao(rs.getString("descricao"));
     oriundo.setData_cadastro(rs.getDate("data_cadastro"));
     oriundo.setDia_fechamento(rs.getInt("dia_fechamento"));
     oriundo.setDia_pag(rs.getInt("dia_pag"));
     return oriundo;
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
   return oriundo;
 }
예제 #6
0
 public void atualizar(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlAtualizar =
       "UPDATE oriundo SET descricao=?, data_cadastro=?, dia_fechamento=?, dia_pag=? WHERE codigo=?";
   try {
     ps = con.prepareStatement(sqlAtualizar);
     ps.setString(1, oriundo.getDescricao());
     ps.setDate(2, oriundo.getData_cadastro());
     ps.setInt(3, oriundo.getDia_fechamento());
     ps.setInt(4, oriundo.getDia_pag());
     ps.setInt(5, oriundo.getCodigo());
     ps.executeUpdate();
     JOptionPane.showMessageDialog(
         null, "Atualizado Com Sucesso: ", "Mensagem do Sistema - Atualizar", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Atualizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
예제 #7
0
 public void salvar(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlSalvar =
       "INSERT INTO oriundo (descricao, data_cadastro, dia_fechamento, dia_pag ) VALUES (?, ?, ?, ?)";
   try {
     ps = con.prepareStatement(sqlSalvar);
     ps.setString(1, oriundo.getDescricao());
     ps.setDate(2, oriundo.getData_cadastro());
     ps.setInt(3, oriundo.getDia_fechamento());
     ps.setInt(4, oriundo.getDia_pag());
     ps.executeUpdate();
     // JOptionPane.showMessageDialog(null, "Inserido Com Sucesso: ", "Mensagem do Sistema -
     // Salvar", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Salvar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
예제 #8
0
  @Override
  public void actionPerformed(ActionEvent action) {
    // Get the file the user wants to use and store it.
    if (action.getSource() == chooseFile) {
      // *sigh* I spent like 10 minutes trying to figure out why my if statement was not working
      // and then I found a semicolon on the end...noob mistake...
      // I had written a paragraph about it to send you too.
      if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
          System.out.println(
              "File: "
                  + fileChooser.getSelectedFile()
                  + "\nInt: "
                  + fileChooser.showOpenDialog(this));
          file = fileChooser.getSelectedFile();
          inputFile = new Scanner(file);
          if (JOptionPane.showConfirmDialog(
                  this,
                  "Overwrite orginal file?",
                  "Overwrite Confimration",
                  JOptionPane.YES_NO_OPTION)
              == JOptionPane.YES_OPTION) {
            outputFile = new PrintWriter(file);
          } else {
            fileChooser.showOpenDialog(this);
            outputFile = new PrintWriter(fileChooser.getSelectedFile());
          }
          // Enable the buttons now that a file has been chosen.
          sort.setEnabled(true);
          next.setEnabled(true);
        } catch (FileNotFoundException exception) {
          JOptionPane.showMessageDialog(this, "Error: Could not find or open file.");
          exception.printStackTrace();
        }
        // Just in case something weird happens and all those files don't get linked correctly,
        // this will get called and prevent the buttons from being enabled.  Essentially, the user
        // won't see anything.
        catch (NullPointerException exception) {
          sort.setEnabled(false);
          next.setEnabled(false);
          exception.printStackTrace();
        }
      }
    } else if (action.getSource() == sort) {
      // Call the quicksort method to sort, and handle the file writing.
      while (inputFile.hasNextLine()) {
        arrayList.add(inputFile.nextLine());
      }
      inputFile.close();
      temp = new String[arrayList.size()];
      array = arrayList.toArray(temp);
      sorter.quicksort(array, 0, array.length - 1);

      for (int i = 0; i < array.length; i++) {
        outputFile.println(array[i]);
      }
      outputFile.close();
      JOptionPane.showMessageDialog(this, "List successfully sorted.");
    } else if (action.getSource() == next) {
      // Go to the search options.
      buttonPanel.remove(chooseFile);
      buttonPanel.remove(sort);
      buttonPanel.add(search);
      repaint();
      setVisible(true);
    } else if (action.getSource() == exit) {
      // Exit, obviously.
      dispose();
    } else if (action.getSource() == search) {
      // Call the binarySearch method and display the result.
      String searchValue = JOptionPane.showInputDialog("Enter the value to search for:");
      boolean ignoreCase;
      int result;
      if (JOptionPane.showConfirmDialog(
              this,
              "Case-sensitive search?",
              "Case-sensitive",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE)
          == JOptionPane.YES_OPTION) {
        ignoreCase = false;
      } else {
        ignoreCase = true;
      }
      result = searcher.binarySearch(array, searchValue, ignoreCase) + 1;
      if (result == 0) {
        text.setText("The value, " + searchValue + ", was not found.");
      } else {
        text.setText("The value, " + searchValue + ", was found on line: " + result + ".");
      }
    }
  }