Samar Sharma 0 Newbie Poster

hay this is samar here
actually i have to get values from tha my sql foe a perticular string which i pass through a xt box

i think i'm not able to pass the vehicle no. to the querry
this is my cade
pls help

package p2c;

import java.awt.Container;
import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import p2c.com.DBOperation;
import p2c.com.InBean;
import p2c.com.OutBean;



/**
 *
 * @author Ravan
 */
public class Pout extends javax.swing.JFrame 
{
    public static String VehicleNo = "" ;
    Container root;
    DBOperation db =  new DBOperation();
    InBean objInBean;
    int charges;
    OutBean outbean;
  
  
    
    public Pout()
    {
       
        initComponents();
        setVisible(true);
        setSize(610,450);
        ArrayList al;
        setLocationRelativeTo(null);
        setResizable(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE); 
        
        al = db.getInfo(VehicleNo);
       
    }
   
    public void Pout()
    {
        VehicleNo = txtVehicleNo.getText();    
        String result = "";        
        objInBean = new InBean();
        
        
         
        int SrNo = objInBean.getSr_No();
        Date date = objInBean.getDate();
        Time Intime = objInBean.getIntime();
        String VehicleType = String.valueOf(objInBean.getVehicleType());
        
        java.util.Date utilDate = new java.util.Date();
        Time outtimeNow =  new java.sql.Time(utilDate.getTime());
        
        int Charges = 0; 
         
        try
        {
            
            Time date1 = Intime;
            Time date2 = outtimeNow;
            long remainder = date2.getTime() - date1.getTime();
       
            if (remainder<3)
            {
                if(VehicleType.equals("Two Wheeler"))
                {
                     charges = 5;
                }
                if(VehicleType.equals("Four Wheeler"))
                {
                    charges = 15;
                }
                if(VehicleType.equals("Other"))
                {
                    charges = 100;
                }
            }
        
            if(remainder>3)
            {
                if(remainder<6)
                {
                    if(VehicleType.equals("Two Wheeler"))
                    {
                    charges = 5;
                    }
                    if(VehicleType.equals("Four Wheeler"))
                    {
                        charges = 30;
                    }
                    if(VehicleType.equals("Other"))
                    {
                        charges = 100;
                    }
                }
            }
            if(remainder>=6)
            {
                if(remainder<9)
                {
                    if(VehicleType.equals("Two Wheeler"))
                    {
                        charges = 10;
                    }
                    if(VehicleType.equals("Four Wheeler"))
                    {
                        charges = 45;
                    }
                    if(VehicleType.equals("Other"))
                    {
                        charges = 100;
                    }
                }            
            }
            if(remainder>=9)
            {
                if(remainder<12)
                {
                    if(VehicleType.equals("Two Wheeler"))
                    {
                        charges = 10;
                    }
                    if(VehicleType.equals("Four Wheeler"))
                    {
                        charges = 60;
                    }
                    if(VehicleType.equals("Other"))
                    {
                        charges = 100;
                    }
                }
            }
        
            if (remainder>=12)
            {
                
                if(VehicleType.equals("Two Wheeler"))
                {
                    charges = 10;
                }
                if(VehicleType.equals("Four Wheeler"))
                {
                    charges = 75;
                }
                if(VehicleType.equals("Other"))
                {
                    charges = 200;
                }
            }
        }
        catch(Exception e)
        {
           System.out.println("Time" +e); 
        }
        
        System.out.println("SRNO"+SrNo);
        System.out.println("Date"+date);
        System.out.println("in"+Intime);
        System.out.println("VHL"+VehicleNo);
        System.out.println("OUT"+outtimeNow);
        System.out.println("CHR"+charges);
       
        
        if (txtVehicleNo.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this, "VehicleNo is Missing", "Error", JOptionPane.ERROR_MESSAGE );
            
        }
        else
            
        {
            try
            {
                
             
                outbean = new OutBean();
                outbean.setSr_No(SrNo);
                outbean.setVehicle_No(VehicleNo);
                outbean.setDate(date);
                outbean.setIntime(Intime);
                outbean.setOuttimeNow(outtimeNow);
                outbean.setCharges(charges);
                
                result = db.updateEntry2(outbean);
                
                
                setVisible(false);
                new PoutR();
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(this, "Record Cannot be Added", "ERROR", JOptionPane.ERROR_MESSAGE);
            }
            
        }
        
        
    }
            
        
        
        
    


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtVehicleNo = new javax.swing.JTextField();
        btnSubmitt = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Vehicle No.");

        txtVehicleNo.setFont(new java.awt.Font("Tahoma", 0, 14));

        btnSubmitt.setText("Submitt");
        btnSubmitt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSubmittActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 16));
        jLabel4.setText("MODREN INTER STATE BUS TERMINAL, TUTIKANDI, SHIMLA");

        jLabel2.setFont(new java.awt.Font("Trebuchet MS", 0, 18));
        jLabel2.setText("PARKING FEE COLLECTION BY:");

        jLabel3.setFont(new java.awt.Font("Trajan Pro", 1, 18));
        jLabel3.setText("C.K INFRASTRUCTURES LTD. (SHIMLA)");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(61, 61, 61)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(33, 33, 33)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addGap(58, 58, 58))))
                            .addComponent(jLabel4)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(171, 171, 171)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(84, 84, 84)
                                .addComponent(btnSubmitt))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(45, 45, 45)
                                .addComponent(txtVehicleNo, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(73, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addGap(71, 71, 71)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtVehicleNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(54, 54, 54)
                .addComponent(btnSubmitt)
                .addContainerGap(109, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void btnSubmittActionPerformed(java.awt.event.ActionEvent evt) {                                           
            Pout();
    }                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see [url]http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html[/url] 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Pout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Pout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Pout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Pout.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Pout().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton btnSubmitt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField txtVehicleNo;
    // End of variables declaration                   


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.