public JobProtheus retornaJob(Connection conn, JobLote lote) throws SQLException { ResultSet rs = null; PreparedStatement stmt = null; JobProtheus job = null; String sql = "select job , B1_DESC, operacao , produto, "; sql += " dt_release, job_start_date , qtd_release, setor, qtd_transf "; sql += " from job left join " + DB_PROTHEUS.trim() + ".dbo.SB1000 SB1 "; sql += " on(produto collate SQL_Latin1_General_CP1_CI_AS = B1_COD) "; sql += " where job = ? and operacao = ? and SB1.D_E_L_E_T_ = '' "; sql += " order by dt_release, produto "; stmt = conn.prepareStatement(sql); stmt.setString(1, lote.getJob().trim()); stmt.setInt(2, lote.getOperNum()); rs = stmt.executeQuery(); while (rs.next()) { String nJob = rs.getString("job"); int operacao = rs.getInt("operacao"); String produto = rs.getString("produto"); Date dataEmissao = rs.getDate("dt_release"); Date dataPrevisaoInicio = rs.getDate("job_start_date"); String descricaoProduto = rs.getString("B1_DESC"); double quantidade = rs.getDouble("qtd_release"); String wc = rs.getString("setor"); String emissao = dataEmissao != null ? getDateToString(dataEmissao) : ""; String previsaoInicio = dataPrevisaoInicio != null ? getDateToString(dataPrevisaoInicio) : ""; job = new JobProtheus(); job.setStatus(""); job.setJob(nJob); job.setOperacao(operacao); job.setProduto(produto.trim()); job.setDataEmissao(emissao); job.setQuantidadeLiberada(quantidade); job.setDescricaoProduto(descricaoProduto); job.setCentroTrabalho(wc); double qtdTotal = retornaQtdTotal(conn, job); // calcula o total transferido para o job job.setQuantidadeCompleta(qtdTotal); job.setDataPrivisaoInicio(previsaoInicio); job.setQuantidadeFaltando(quantidade - qtdTotal); // seta o valor qtd faltando } return job; // retorna lista de jobs }
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; }
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; }
public void setContent(String cat) { cat = cat.trim(); selectAllCB.setVisible(false); selectAllCB.setSelected(false); deleteBut.setVisible(false); restoreBut.setVisible(false); refreshBut.setVisible(true); Object columns[] = null; int count = 0; switch (cat) { case "Inbox": columns = new Object[] {"", "From", "Date", "Subject", "Content"}; count = Database.getCount("Inbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc"); ; break; case "SentMail": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Sentmail"); workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc"); break; case "Draft": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Draft"); workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc"); break; case "Outbox": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Outbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc"); break; case "Trash": // restoreBut.setVisible(true); columns = new Object[] {"", "To/From", "Date", "Subject", "Content"}; count = Database.getCount("Trash"); workingSet = db.getData( "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); break; default: System.out.println("in default case"); } if (count > 0) { selectAllCB.setVisible(true); rows = new Object[count][]; msgID = new int[count]; try { workingSet.beforeFirst(); for (int i = 0; i < count && workingSet.next(); i++) { msgID[i] = workingSet.getInt(1); rows[i] = new Object[] { false, workingSet.getString(2), workingSet.getDate(3), workingSet.getString(4), workingSet.getString(5) }; } } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); sqlExc.printStackTrace(); } tableModel = new MyDefaultTableModel(rows, columns); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(this); table.addMouseListener(this); table.getTableHeader().setOpaque(true); table.getTableHeader().setReorderingAllowed(false); // table.getTableHeader().setBackground(Color.blue); table.getTableHeader().setForeground(Color.blue); // table.setRowSelectionAllowed(false); // table.setColumnSelectionAllowed(false); table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14)); table.setRowHeight(20); table.setFillsViewportHeight(true); TableColumn column = null; for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(6); } else if (i == 3) { column.setPreferredWidth(250); } else if (i == 4) { column.setPreferredWidth(450); } else { column.setPreferredWidth(40); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); remove(contentPan); contentPan = new JScrollPane(table); contentPan.setBackground(Color.orange); contentPan.setOpaque(true); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); Home.home.homeFrame.setVisible(true); } else { JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("No Messages In This Category"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22)); label.setForeground(Color.orange); centPan.add(label); remove(contentPan); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); } }