private void selectView(String str_sql){

        lbl_date.setVisible(true);
        
        if (this.jPanel_graph.getComponentCount() > 1) {
            this.jPanel_graph.remove(1);
        }
        
        jLabel_loding_graph.setIcon(new javax.swing.ImageIcon(getClass().getResource("/energymonitor_sever/loading15.gif")));
        jLabel_loding_graph.setText("");
        jLabel_load_table.setIcon(new javax.swing.ImageIcon(getClass().getResource("/energymonitor_sever/loading15.gif")));
        jLabel_load_table.setText("");

        jPanel_loading_table.setVisible(true);
        jScrollPane1.setVisible(false);
        jPanel_loading_graph.setVisible(true);
        jPanel1.setVisible(false);
        jPanel1.setVisible(true);
        

            
            String[] Columname = {"No", "Name", "Detail", "losttime (min)", "Unit"};
            DefaultTableModel model = new DefaultTableModel(Columname, 0);
            jTable1.setModel(model);      
            
            ResultSet rs = mdb.getSelectdata(str_sql);
            
            double total_unit = 0; 
            int sum_minute = 0;
            int c = 0;
            try {                 
               
                while (rs.next()) {
                    sum_minute += Integer.parseInt(rs.getString("lost_min"));
                    double hr = Double.parseDouble(rs.getString("lost_min")) / 60;
                    double watt = Double.parseDouble(rs.getString("watt"));
                    double unit = watt / 1000 * hr;
                    model.addRow(data);
                    jTable1.setValueAt(c + 1 + "", c, 0);
                    jTable1.setValueAt(rs.getString("name"), c, 1);
                    jTable1.setValueAt(rs.getString("detail"), c, 2);
                    jTable1.setValueAt(rs.getString("lost_min"), c, 3);
                    jTable1.setValueAt(unit + "", c, 4);
                    c++;
                    total_unit += unit;
                    //System.out.println(unit+"  : unit \n"+watt+" : watt  \n"+hr+" : hr");
                }

            } catch (SQLException ex) {
                JOptionPane.showConfirmDialog((Component) null, "Error", "Alert", JOptionPane.DEFAULT_OPTION);
                ex.printStackTrace();
            }
            
            
            
        str_sql = "select cost_per_unit from sever_info where Id = 1";
        rs = mdb.getSelectdata(str_sql);
        double cost_unit = 0;
        try{
            rs.next();           
            cost_unit = Double.parseDouble(rs.getString("cost_per_unit"));
        }catch(Exception ex){
        
        }
            
        double total_cost = total_unit*cost_unit;
        
        txt_Sum_unit.setText(total_unit+"");
        txt_Sum_lostTime.setText(sum_minute+"");
        txt_cost.setText(total_cost+"");
        
            jPanel_loading_table.setVisible(false);
            jScrollPane1.setVisible(true);
            //jPanel_table.setVisible(true);
            
            if(c<=0){
                //jPanel_table.setVisible(false);
                jScrollPane1.setVisible(false);
                jLabel_load_table.setIcon(null);
                jLabel_load_table.setText("                         No Data");
                jPanel_loading_table.setVisible(true);
                
                jLabel_loding_graph.setIcon(null);
                jLabel_loding_graph.setText("                         No Data");
                jLabel_loding_graph.setVisible(true);
                
                jPanel_Dn_1.setVisible(false);
                
            }else{
            
                
                rs = mdb.getSelectdata(this.sqlBargraph);
                int barValue[] = new int[24] ;
                for(int i = 0 ; i<barValue.length ; i++){
                
                    barValue[i] = 0;
                }
                
                try {

                    while (rs.next()) {
                        int lost_min = Integer.parseInt(rs.getString("lost_min"));
                        int hr = Integer.parseInt(rs.getString("hr"));
                        int min = Integer.parseInt(rs.getString("min"));
                        
                        barValue[hr] += lost_min;
                        
//                        if(lost_min > min){
//                            while (lost_min != 0) {
//
//                                barValue[hr] += lost_min;
//
//                                lost_min = lost_min - min;
//                                hr = hr-1;
//                            }
//                        }else{
//                        
//                            barValue[hr] += lost_min;
//                        }
//
//
                    }

                } catch (SQLException ex) {
                    JOptionPane.showConfirmDialog((Component) null, "Error", "Alert", JOptionPane.DEFAULT_OPTION);
                    ex.printStackTrace();
                }
                
                
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                String rowString = "waste time (Minute)";
                String colString = "Time";
                String strAM = "";
                String strPM = "";
        
                for(int i=1 ; i<=23 ; i++){
                    dataset.setValue(barValue[i], rowString, i+" ");
                }
                dataset.setValue(barValue[0], rowString, "24 ");


                JFreeChart chart = ChartFactory.createBarChart3D("waste time Chart", "duration", rowString, dataset, PlotOrientation.VERTICAL, false, true, false);
                CategoryPlot p = chart.getCategoryPlot();

                BarRenderer renderer = (BarRenderer) p.getRenderer();
                DecimalFormat decimalformat = new DecimalFormat("##.##");
                renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat));
                p.setRenderer(renderer);

                renderer.setItemLabelsVisible(true);
                p.setRangeGridlinePaint(Color.BLACK);
                ChartPanel barchartP = new ChartPanel(chart);
                barchartP.setSize(this.jPanel_graph.getSize());
                this.jPanel_graph.add(barchartP, -1);
    
                barchartP.addMouseListener(new MouseListener() {

                    @Override
                    public void mouseClicked(MouseEvent e) {
                        //reportForm.this.p.setVisible(false);
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                        reportForm.this.p.setVisible(false);
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                        //throw new UnsupportedOperationException("Not supported yet.");
                    }

                    @Override
                    public void mouseEntered(MouseEvent e) {
                       // throw new UnsupportedOperationException("Not supported yet.");
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                        //throw new UnsupportedOperationException("Not supported yet.");
                    }
                });
                
                barchartP.setVisible(true);
                
                jPanel_loading_table.setVisible(false);
                jPanel_loading_graph.setVisible(false);
                jScrollPane1.setVisible(true);
                
                jPanel_Dn_1.setVisible(true);
                
            }
    }