private void b_searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_searchActionPerformed
        try {
            if(j_date_first.getDate() == null || j_date_last.getDate() == null){
                JOptionPane.showMessageDialog(rootPane, "Preencha as duas Datas para continuar.", "Relatórios | Cadore Sistemas", JOptionPane.WARNING_MESSAGE);
            }else{
                Date first = sdfBR.parse(sdfBR.format(j_date_first.getDate()));
                Date last = sdfBR.parse(sdfBR.format(j_date_last.getDate()));
                long d = first.getTime() - last.getTime();
                String days = String.valueOf(d/1000/60/60/24).replace("-", "");
                if(first.getTime() > last.getTime()){
                    JOptionPane.showMessageDialog(rootPane, "A data inicial é maior que a data final.", "Relatórios | Cadore Sistemas", JOptionPane.WARNING_MESSAGE);
                }else{
                    Long truck = null;
                    if(!" -".equals(cb_truck.getSelectedItem())){
                       truck = Long.valueOf(trucksDAO.getIDTruck(String.valueOf(cb_truck.getSelectedItem())));
                    }else{
                        truck = Long.valueOf(0);
                    }
                    try {
                        freights = freightsReportsDAO.getReportsFreights((ut.dateFormatInsert(sdfBR.format(j_date_first.getDate()))),
                                (ut.dateFormatInsert(sdfBR.format(j_date_last.getDate()))),truck, Long.valueOf(this.IdBusiness));
                        fueled = freightsReportsDAO.getLitersFueledFreights((ut.dateFormatInsert(sdfBR.format(j_date_first.getDate()))),
                                (ut.dateFormatInsert(sdfBR.format(j_date_last.getDate()))),truck, Long.valueOf(this.IdBusiness));
                    } catch (ParseException ex) {
                        Logger.getLogger(FreightsReportsForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    int qnt = freights.getQnt();
                    f_qnt.setText(String.valueOf(freights.getQnt()));
                    f_weight.setText(String.valueOf(freights.getWeight()).replace(".", ","));
                    f_medium_weight.setText(decimal.format(freights.getWeight() / qnt).replace(".", ","));
                    f_value_t.setText(String.valueOf(freights.getValue_t()).replace(".", ","));
                    f_medium_value_t.setText(decimal.format(freights.getValue_t() / qnt).replace(".", ","));
                    f_discount2.setText(String.valueOf(freights.getDiscount2()).replace(".", ","));
                    f_medium_discount2.setText(decimal.format(freights.getDiscount2() / qnt).replace(".", ","));
                    f_fueled.setText(String.valueOf(freights.getFueled()).replace(".", ","));
                    f_medium_fueled.setText(decimal.format(freights.getFueled() / qnt).replace(".", ","));
                    f_total2.setText(String.valueOf(freights.getTotal2()).replace(".", ","));
                    f_medium_total2.setText(decimal.format(freights.getTotal2() / qnt).replace(".", ","));
                    f_gross.setText(String.valueOf(freights.getGross()).replace(".", ","));
                    f_medium_gross.setText(decimal.format(freights.getGross() / qnt).replace(".", ","));
                    f_total3.setText(String.valueOf(freights.getTotal3()).replace(".", ","));
                    f_medium_total3.setText(decimal.format(freights.getTotal3() / qnt).replace(".", ","));
                    l_obs.setText("OBS: Os valor abaixo são dados referentes aos períodos acima.");
                    l_period.setText("Período de: "+sdfBR.format(j_date_first.getDate())+" Até: "+sdfBR.format(j_date_last.getDate())+" Totalizando: "+days+" dias,"+"  Veiculo: "+cb_truck.getSelectedItem());
                }
            }
        } catch (ParseException ex) {
            Logger.getLogger(FreightsReportsForm.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(!"0".equals(f_qnt.getText())){
            b_print.setEnabled(true);
            b_send_mail.setEnabled(true);
        }           
    }//GEN-LAST:event_b_searchActionPerformed