0% found this document useful (0 votes)
10 views

Deposit Java

The document describes code for an ATM application. It contains code to handle a back button and deposit button. When the deposit button is clicked, it retrieves the user's current balance from a database table, adds the deposit amount to the balance, updates the database with the new balance, and displays a confirmation message.

Uploaded by

Vinz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Deposit Java

The document describes code for an ATM application. It contains code to handle a back button and deposit button. When the deposit button is clicked, it retrieves the user's current balance from a database table, adds the deposit amount to the balance, updates the database with the new balance, and displays a confirmation message.

Uploaded by

Vinz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Object source=e.

getSource();

if(source==btnBack){

Menu panel = new Menu();


panel.setSize(330,300);
panel.setVisible(true);
panel.setResizable(false);
panel.setLocation(400,250);
dispose();

}else if(source==btnDep){

try{
try{
st= cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM tbl_list
WHERE Username ='"+txtuser.getText()+"'");
while(rs.next()){
txtcash.setText(rs.getString(9));
int a =
Integer.parseInt(txtcash.getText());
int b =
Integer.parseInt(txtwid.getText());

int sum = a+b;


txtcash.setText((sum + ""));
txtwid.setText("");
JOptionPane.showMessageDialog(null,"You Deposit
" + b,"ATM",JOptionPane.INFORMATION_MESSAGE);
ps = cn.prepareStatement("UPDATE tbl_list SET ct = '" + sum
+ "' WHERE Username = '" + txtuser.getText() + "'");
ps.executeUpdate();
txtuser.requestFocus(true);

}
st.close();

}catch(NumberFormatException nfe){

JOptionPane.showMessageDialog(null,"Enter now the amount to


Deposit","ATM",JOptionPane.INFORMATION_MESSAGE);

}catch(SQLException s){
System.out.println("No record found!\n\n\n");
System.out.println("SQL Error" + s.toString() + " " +
s.getErrorCode() + " " + s.getSQLState());
}

catch(Exception x){
System.out.println("Error" + x.toString()+" " +
x.getMessage());
}

You might also like