Вы находитесь на странице: 1из 62

ATM PROJECT

SOFTWARE REQUIREMENT SPECIFICATION


For running the code please use Net Beans IDE 8.0.2 and save the project as java application and create
files as java files.

For Database:

Use MySQL 1.5.4

Create table accountdetails with primary key as acct_no and pin with other fields like First name
(fname), Last name(lname), Account type (acct_type), balance, phone and pin using the query:
CREATE TABLE accountdetails( acct_no number (13,0) NOT NULL, fname varchar2(50) NOT
NULL, lname varchar2(50) NOT NULL, acct_type varchar2(100) NOT NULL, balance
number(20,0) NOT NULL, phone number(10,0) NOT NULL, pin number(4,0) NOT NULL,
Primary key (acct_no));

Create a second table transaction with primary key as trans_id and acct_no acting as the foreign
key by using the query:
CREATE TABLE transaction(trans_id number(9,0), acct_no number (13,0), status varchar
(10),cheque_no number(6,0),chequebank_name varchar(20),amount number(5,0),type
varchar(10),transdate date, primary key (acct_no), constraint fk_accountdetails Foreign key
(acct_no));

1 or 2 records should exist in the table accountdetails

Please first run the program welcome and then enter an account number and pin to login.

SOURCE CODE:

WELCOME SCREEN
This is the welcome screen where user needs to enter their login details i.e. account number and pin
and then on correct details they will be directed to the profile page
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package atm;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public class Welcome extends javax.swing.JFrame {


Connection con;
Statement st;
ResultSet rs;
String acctno,pinn;
String name,lnam;
/**
* Creates new form Welcome
*/
public Welcome() {
initComponents();

try{

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","123");
}
catch(ClassNotFoundException ex){
System.out.print("Unable to load Driver");
}
catch(SQLException e){
System.out.print("Error in connection");
}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


l1 = new javax.swing.JLabel();
l2 = new javax.swing.JLabel();
p1 = new javax.swing.JPasswordField();
p2 = new javax.swing.JPasswordField();
b1 = new javax.swing.JButton();
b2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setBackground(new java.awt.Color(0, 204, 204));

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Welcome to National Bank ATM Service");

l1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N


l1.setText("Enter your ACCOUNT NUMBER :-");

l2.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N


l2.setText("Enter PIN :-"); /* this is creation of the layout for the screen*/

b1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


b1.setText("Continue");
b1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b1ActionPerformed(evt);
}
});

b2.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


b2.setText("Exit");
b2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b2ActionPerformed(evt);
}
});

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, false)
.addGroup(layout.createSequentialGroup()
.addGap(145, 145, 145)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 364,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(92, 92, 92)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(l2, javax.swing.GroupLayout.PREFERRED_SIZE, 82,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(l1, javax.swing.GroupLayout.PREFERRED_SIZE, 210,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(p1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(p2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(177, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(152, 152, 152)
.addComponent(b1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(b2)
.addGap(192, 192, 192))

);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(80, 80, 80)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(l1, javax.swing.GroupLayout.PREFERRED_SIZE, 44,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(p1, javax.swing.GroupLayout.PREFERRED_SIZE, 44,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(l2, javax.swing.GroupLayout.PREFERRED_SIZE, 26,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(p2, javax.swing.GroupLayout.PREFERRED_SIZE, 26,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(83, 83, 83)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(b1)
.addComponent(b2))
.addContainerGap(151, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void b1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b1ActionPerformed

acctno=p1.getText();
pinn=p2.getText();
try
{

st=con.createStatement();
rs=st.executeQuery("select * from accountdetails where acct_no='"+acctno+"' and pin='"+pinn+"'");/* it fetches
data from the table */
if(rs.next()){
name=rs.getString(2);
lnam=rs.getString(3);
new Profile(name,lnam).setVisible(true);
}

else
{
JOptionPane.showMessageDialog(this,"Login Failed. Wrong username or password");
}
} /* if else statement is used to validate whether the account number and pin entered match with the database */
catch(SQLException e)
{
System.out.println("error,error in connection");
}
/* the statement is used to catch any sql exceptions */
}//GEN-LAST:event_b1ActionPerformed

private void b2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b2ActionPerformed


System.exit(0); // TODO add your handling code here:
}//GEN-LAST:event_b2ActionPerformed

/**
* @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(Welcome.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Welcome.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 Welcome().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton b1;
private javax.swing.JButton b2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel l1;
private javax.swing.JLabel l2;
private javax.swing.JPasswordField p1;
private javax.swing.JPasswordField p2;
// End of variables declaration//GEN-END:variables
}

PROFILE SCREEN
This screen consists of options after logging into the profile that display what all actions the end user
can take.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.

Current

*/
package atm;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
*
* @author Niharika Jain
*/
public class Profile extends javax.swing.JFrame {
String k;
String l;
DateFormat d; /* declaring the variables to be used for displaying the name first name and last
name and carrying the variables forward along with the current date*/
public Profile(String n,String o) {
initComponents();
k=n;
l=o;
l3.setText("Welcome "+k+" "+o);
d =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal=Calendar.getInstance();
l4.setText(d.format(cal.getTime()));/* to fetch the current date
*/

/**

* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

l3 = new javax.swing.JLabel();
l4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
b3 = new javax.swing.JButton();
b4 = new javax.swing.JButton();
b5 = new javax.swing.JButton();
b6 = new javax.swing.JButton();
b8 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

l3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
l3.setText("jLabel1");

l4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
l4.setText("jLabel1");

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

jLabel1.setText("NATIONAL BANK ATM SERVICE");

b3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


b3.setText("Deposit");
b3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b3ActionPerformed(evt);
}
}); /* to create a button for Withdraw and determine the set the event of clicking on the button on
which action will be performed */
*/
b4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
b4.setText("Withdraw");
b4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b4ActionPerformed(evt);
}
});/* to create a button for Withdraw and determine the set the event of clicking on the button on
which action will be performed */
b5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
b5.setText("Fast Cash");
b5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b5ActionPerformed(evt);
}
});/* to create a button for Fast Cash and determine the set the event of clicking on the button on which action
will be performed */
b6.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
b6.setText("Mini Statement");
b6.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {


b6ActionPerformed(evt);
}
});/* to create a button for Mini Statement and determine the set the event of clicking on the button on which
action will be performed */

b8.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


b8.setText("Exit");

); /* to create a button for Exit and determine the set the event of clicking on the button on which action will be
performed */
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(b3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(b5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(b7, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(b6, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(b4, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(87, 87, 87))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(127, 127, 127)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 480,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(92, 92, 92)
.addComponent(l3, javax.swing.GroupLayout.PREFERRED_SIZE, 264,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(l4, javax.swing.GroupLayout.PREFERRED_SIZE, 264,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(44, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(b8, javax.swing.GroupLayout.PREFERRED_SIZE, 129,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(235, 235, 235))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(287, 287, 287)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(b5)
.addComponent(b6)))
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 62,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(l3, javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(l4, javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(74, 74, 74)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(b3)
.addComponent(b4))))
.addGap(48, 48, 48)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(b7)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74,
Short.MAX_VALUE)
.addComponent(b8)
.addGap(108, 108, 108))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void b3ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b3ActionPerformed


new Deposit(k,l).setVisible(true); /* to call the deposit class i.e. display the deposit
screen and carrying the variable for first and last name for the deposit screen */ //
TODO add your handling code here:
}//GEN-LAST:event_b3ActionPerformed
private void b4ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b4ActionPerformed
new Withdraw(k,l).setVisible(true); /* to call the withdraw class i.e. display the withdraw screen and carrying the
variable for first and last name for the withdraw screen */
}//GEN-LAST:event_b4ActionPerformed

private void b6ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b6ActionPerformed


new mini(k,l).setVisible(true); /* to call the mini class i.e. display the mini screen and carrying the variable for first
and last name for the mini screen */
}//GEN-LAST:event_b6ActionPerformed

private void b5ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_b5ActionPerformed


new fastcash(k,l).setVisible(true); /* to call the deposit class i.e. display the deposit screen and carrying the
variable for first and last name for the deposit screen */
}//GEN-LAST:event_b5ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed


new balance(k,l); /* to call the deposit class i.e. display the deposit screen and carrying the variable for first and
last name for the deposit screen */
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(Profile.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

catch (InstantiationException ex) {


java.util.logging.Logger.getLogger(Profile.class.getName()).log(java.util.logging.Level.SEVERE, null,

ex);
}

catch (IllegalAccessException ex) {


java.util.logging.Logger.getLogger(Profile.class.getName()).log(java.util.logging.Level.SEVERE, null,

ex);
}

catch (javax.swing.UnsupportedLookAndFeelException ex) {


java.util.logging.Logger.getLogger(Profile.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() {

}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton b3;
private javax.swing.JButton b4;
private javax.swing.JButton b5;
private javax.swing.JButton b6;
private javax.swing.JButton b8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel l3;
private javax.swing.JLabel l4;
// End of variables declaration//GEN-END:variables
}

MINI SCREEN
This screen is for viewing the mini statement
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package atm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

/**
*
* @author Niharika jain
*/
public class mini extends javax.swing.JFrame {
DateFormat d;
String f1;
String l1;

public mini(String p,String q) {


initComponents();
f1=p;
l1=q;
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","123");
String sql="Select * from transaction order by trans_date desc limit 0,10"; /* to create connection with the
database and obtain the data from transaction table for the last 10 transactions */
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(sql); /*
for storing the records being fetched
from the database */

ResultSetMetaData md=rs.getMetaData();
int columns=md.getColumnCount();
DefaultTableModel dmt=new DefaultTableModel();
Vector columnNames=new Vector();
for(int i=1;i<=columns;i++)
{
columnNames.addElement(md.getColumnName(i));
}
dmt.setColumnIdentifiers(columnNames);
while(rs.next())
{
Vector row=new Vector();
for(int i=1;i<=columns;i++)
{
row.addElement(rs.getString(i));
}
dmt.addRow(row);
}
table1.setModel(dmt);
rs.close();
st.close();
}
catch(Exception e)
{
System.out.print(e);
}
d =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal=Calendar.getInstance();
l7.setText(d.format(cal.getTime()));

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();


table1 = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
l7 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

table1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
}, /* display data in tabular format */
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"

}
));
jScrollPane1.setViewportView(table1);

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("NATIONAL BANK ATM SERIVICE");

jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("MINI-STATEMENT");

l7.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l7.setText("jLabel3");

jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton1.setText("Back");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

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(204, 204, 204)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 323,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(236, 236, 236)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 211,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(65, 65, 65)
.addComponent(l7, javax.swing.GroupLayout.PREFERRED_SIZE, 226,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 746,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(26, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(293, 293, 293))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(l7, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30,
Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 381,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed


new Profile(f1,l1).setVisible(true);
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(mini.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

catch (InstantiationException ex) {


java.util.logging.Logger.getLogger(mini.class.getName()).log(java.util.logging.Level.SEVERE, null,

ex);
}

catch (IllegalAccessException ex) {


java.util.logging.Logger.getLogger(mini.class.getName()).log(java.util.logging.Level.SEVERE, null,

ex);
}

catch (javax.swing.UnsupportedLookAndFeelException ex) {


java.util.logging.Logger.getLogger(mini.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() {

}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton jButton1;

private javax.swing.JLabel jLabel1;


private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel l7;
private javax.swing.JTable table1;
// End of variables declaration//GEN-END:variables
}

FAST CASH SCREEN


This is for the fast cash screen where one can get instant cash with two options of Rs. 500, Rs. 1000,
Rs.5000 and Rs.10000 and is displayed on selecting the button fast cash.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package atm;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

/**
*
* @author Niharika Jain
*/
public class fastcash extends javax.swing.JFrame {
int button1;
Connection con;
DateFormat d;
Statement st;
ResultSet rs;
String first2;
String last2;
String type2="fastcash";
String status2=null;
String acctno2;
String transid2;
String transdate2;
int chequeno2=0;
String chebankname2=null;
float balance2;
float total2;
float amount2;

public final class SessionIdentifierGenerator{


private SecureRandom random=new SecureRandom();
public String nextSessionId()
{
return new BigInteger(30,random).toString();
}

}
public fastcash(String y,String z) {
initComponents();
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","123");
} /* to create connection with the database */
catch(ClassNotFoundException ex){
System.out.print("Unable to load Driver");
}
catch(SQLException e){
System.out.print("Error in connection");
}
first2=y;
last2=z;
l8.setText("Welcome "+first2+" "+last2);
d =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal=Calendar.getInstance();
l9.setText(d.format(cal.getTime()));
transdate2=d.format(cal.getTime());
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents

private void initComponents() {

bg1 = new javax.swing.ButtonGroup();


jLabel1 = new javax.swing.JLabel();
l8 = new javax.swing.JLabel();
l9 = new javax.swing.JLabel();
rb1 = new javax.swing.JRadioButton();
rb2 = new javax.swing.JRadioButton();
rb3 = new javax.swing.JRadioButton();
rb4 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("NATIONAL BANK ATM SERVICE");

l8.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l8.setText("jLabel2");

l9.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l9.setText("jLabel2");

bg1.add(rb1);
rb1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
rb1.setText("500");
rb1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {


rb1ActionPerformed(evt);
}
});

bg1.add(rb2);
rb2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
rb2.setText("1000");
rb2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb2ActionPerformed(evt);
}
});

bg1.add(rb3);
rb3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
rb3.setText("5000");
rb3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb3ActionPerformed(evt);
}
});

bg1.add(rb4);
rb4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
rb4.setText("10000");
rb4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb4ActionPerformed(evt);

}
});

jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton1.setText("Get Cash");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton2.setText("Back");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

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()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(rb1)
.addComponent(l8, javax.swing.GroupLayout.PREFERRED_SIZE, 351,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(83, 83, 83)
.addComponent(l9, javax.swing.GroupLayout.PREFERRED_SIZE, 284,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(304, 304, 304)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(rb3)
.addComponent(rb2)
.addComponent(rb4)))))
.addGroup(layout.createSequentialGroup()
.addGap(160, 160, 160)
.addComponent(jButton1)
.addGap(219, 219, 219)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 102,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(189, 189, 189)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 332,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(84, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(l8, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(l9, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addComponent(rb1)
.addGap(30, 30, 30)
.addComponent(rb2)
.addGap(27, 27, 27)
.addComponent(rb3)
.addGap(29, 29, 29)
.addComponent(rb4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(65, 65, 65))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void rb1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_rb1ActionPerformed


button1=Integer.parseInt(rb1.getText()); /*
converting text to integer format */

}//GEN-LAST:event_rb1ActionPerformed

private void rb2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_rb2ActionPerformed


button1=Integer.parseInt(rb2.getText());
}//GEN-LAST:event_rb2ActionPerformed

private void rb3ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_rb3ActionPerformed


button1=Integer.parseInt(rb3.getText());
}//GEN-LAST:event_rb3ActionPerformed

private void rb4ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_rb4ActionPerformed


button1=Integer.parseInt(rb4.getText());
}//GEN-LAST:event_rb4ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed

fastcash.SessionIdentifierGenerator ob=new fastcash.SessionIdentifierGenerator();


transid2=ob.nextSessionId();
try
{

st=con.createStatement();
rs=st.executeQuery("select * from accountdetails where fname='"+first2+"' and
lname='"+last2+"'");
if(rs.next()){
acctno2=rs.getString(1);

balance2=Float.parseFloat(rs.getString(5));

else
{
JOptionPane.showMessageDialog(this,"No Account exists");
}
if(button1==Integer.parseInt(rb1.getText()))
{
amount2=button1; /* to store the value selected in the variable */
if(amount2<=balance2)
{
total2=balance2-amount2;
int val2=st.executeUpdate("INSERT into transaction
values('"+transid2+"','"+acctno2+"','"+status2+"','"+chequeno2+"','"+chebankname2+"','"+amount2+"','"
+type2+"','"+transdate2+"')"); /* to update the balance after obtaining fast cash */
int cou2=st.executeUpdate("UPDATE accountdetails set balance='"+total2+"' where
fname='"+first2+"' and lname='"+last2+"'");
JOptionPane.showMessageDialog(this, "Please collect your cash");
}//GEN-LAST:event_jButton1ActionPerformed
else
{
JOptionPane.showMessageDialog(this, "You do not have sufficient balance in your account.
Please check your balance");
}
}
else if(button1==Integer.parseInt(rb2.getText()))
{

amount2=button1;
if(amount2<=balance2)
{
total2=balance2-amount2;
int val2=st.executeUpdate("INSERT into transaction
values('"+transid2+"','"+acctno2+"','"+status2+"','"+chequeno2+"','"+chebankname2+"','"+amount2+"','"
+type2+"','"+transdate2+"')");
int cou2=st.executeUpdate("UPDATE accountdetails set balance='"+total2+"' where
fname='"+first2+"' and lname='"+last2+"'");
JOptionPane.showMessageDialog(this, "Please collect your cash");
}
else
{
JOptionPane.showMessageDialog(this, "You do not have sufficient balance in your account.
Please check your balance");
}

}
else if(button1==Integer.parseInt(rb3.getText()))
{
amount2=button1;
if(amount2<=balance2)
{
total2=balance2-amount2;
int val2=st.executeUpdate("INSERT into transaction
values('"+transid2+"','"+acctno2+"','"+status2+"','"+chequeno2+"','"+chebankname2+"','"+amount2+"','"
+type2+"','"+transdate2+"')");
int cou2=st.executeUpdate("UPDATE accountdetails set balance='"+total2+"' where
fname='"+first2+"' and lname='"+last2+"'");
JOptionPane.showMessageDialog(this, "Please collect your cash");

}
else
{
JOptionPane.showMessageDialog(this, "You do not have sufficient balance in your account.
Please check your balance");
}

}
else if(button1==Integer.parseInt(rb4.getText()))
{
amount2=button1;
if(amount2<=balance2)
{
total2=balance2-amount2;
int val2=st.executeUpdate("INSERT into transaction
values('"+transid2+"','"+acctno2+"','"+status2+"','"+chequeno2+"','"+chebankname2+"','"+amount2+"','"
+type2+"','"+transdate2+"')");
int cou2=st.executeUpdate("UPDATE accountdetails set balance='"+total2+"' where
fname='"+first2+"' and lname='"+last2+"'");
JOptionPane.showMessageDialog(this, "Please collect your cash");
}
else
{
JOptionPane.showMessageDialog(this, "You do not have sufficient balance in your account.
Please check your balance");
}

}
else

{
JOptionPane.showMessageDialog(this, "Please select one of the options");
}
}
catch(SQLException e)
{
System.out.println("error,error withdraw in connection");
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton2ActionPerformed


new Profile(first2,last2).setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable(){
public void run() {

}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.ButtonGroup bg1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;


private javax.swing.JLabel l8;
private javax.swing.JLabel l9;
private javax.swing.JRadioButton rb1;
private javax.swing.JRadioButton rb2;
private javax.swing.JRadioButton rb3;
private javax.swing.JRadioButton rb4;
// End of variables declaration//GEN-END:variables
}

DEPOSIT SCREEN
This screen enables end user to deposit money in their account which is refected in their balance on
selecting deposit button.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package atm;

import java.math.BigInteger;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.JOptionPane;
import java.security.SecureRandom;

public class Deposit extends javax.swing.JFrame {


Random r;
Connection con;
Statement st;
ResultSet rs;
DateFormat d;
String first;
String last;
String option;
float amount;
int chequeno;
String chebankname;
String type="credit";
String status;
String acctno;
String transid;
String transdate;
float balance;
float total;

public final class SessionIdentifierGenerator{


private SecureRandom random=new SecureRandom();
public String nextSessionId()
{
return new BigInteger(30,random).toString();
}
}

public Deposit(String h,String k) {

initComponents();
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","123");
status="cash";
}
catch(ClassNotFoundException ex){
System.out.print("Unable to load Driver");
}
catch(SQLException e){
System.out.print("Error in connection");
}
first=h;
last=k;
d =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal=Calendar.getInstance();
l5.setText(d.format(cal.getTime()));
transdate=d.format(cal.getTime());
t2.setEditable(false);
t3.setEditable(false);

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/

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

jLabel1 = new javax.swing.JLabel();


l5 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
t1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
c1 = new javax.swing.JComboBox();
jLabel4 = new javax.swing.JLabel();
t2 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
t3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("NATIONAL BANK ATM SERVICE");

l5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
l5.setText("jLabel2");

jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel2.setText("Enter Amount:-");

t1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N

jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel3.setText("Select (Cash/Check):-");

c1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


c1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Cash", "Cheque" }));
c1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
c1ActionPerformed(evt);
}
});

jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel4.setText("Cheque Number:-");

t2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N

jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel5.setText("Cheque Bank Name:-");

t3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N

jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton1.setText("Deposit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);

}
});

jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton2.setText("Back");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

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(140, 140, 140)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 426,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(182, 182, 182)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(131, 131, 131)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(t1)
.addComponent(c1, 0, 126, Short.MAX_VALUE)
.addComponent(t2)
.addComponent(t3)))
.addGroup(layout.createSequentialGroup()
.addGap(274, 274, 274)
.addComponent(jButton1)
.addGap(85, 85, 85)
.addComponent(jButton2)))
.addContainerGap(153, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(l5, javax.swing.GroupLayout.PREFERRED_SIZE, 197,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 72,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(l5, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(c1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(t2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(t3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(59, 59, 59))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void c1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_c1ActionPerformed


option=c1.getSelectedItem().toString();
if(option.equals("Cheque"))
{
status="Cheque";
t2.setEditable(true);
t3.setEditable(true);
JOptionPane.showMessageDialog(this, "You selected Cheque. Please Enter Cheque number and
Cheque Bank Name"); /* if statement is used to perform this function when cheque is selected and value is stored
in status variable */
}
else
{
status="cash";
JOptionPane.showMessageDialog(this, "You selected Cash"); /* it
performs the function when cash is selected */
}
}//GEN-LAST:event_c1ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed


status="cash";
SessionIdentifierGenerator ob=new SessionIdentifierGenerator();
transid=ob.nextSessionId();
JOptionPane.showMessageDialog(null,transid);

if(status.equals("Cheque"))
{
amount=Float.parseFloat(t1.getText());

chequeno=Integer.parseInt(t2.getText());
chebankname=t3.getText();
status="cheque";
try
{

st=con.createStatement();
rs=st.executeQuery("select * from accountdetails where fname='"+first+"' and lname='"+last+"'");
if(rs.next()){
acctno=rs.getString(1);
balance=Float.parseFloat(rs.getString(5));

else
{
JOptionPane.showMessageDialog(this,"No Account exists");
}
total=amount+balance;
int val=st.executeUpdate("INSERT into transaction
values('"+transid+"','"+acctno+"','"+status+"','"+chequeno+"','"+chebankname+"','"+amount+"','"+type+
"','"+transdate+"')");
int cou=st.executeUpdate("UPDATE accountdetails set balance='"+total+"' where fname='"+first+"'
and lname='"+last+"'");
JOptionPane.showMessageDialog(this, "Amount deposited successfully");
}
catch(SQLException e)
{
System.out.println("error,error in connection");
}

}
else
{
amount=Float.parseFloat(t1.getText());
status="cash";
chequeno=0;
chebankname="";
try
{

st=con.createStatement();
rs=st.executeQuery("select * from accountdetails where fname='"+first+"' and lname='"+last+"'");
if(rs.next()){
acctno=rs.getString(1);
balance=Float.parseFloat(rs.getString(5));
}

else
{
JOptionPane.showMessageDialog(this,"No Account exists");
}
total=amount+balance;
int val=st.executeUpdate("INSERT into transaction
values('"+transid+"','"+acctno+"','"+status+"','"+chequeno+"','"+chebankname+"','"+amount+"','"+type+
"','"+transdate+"')");
int cou=st.executeUpdate("UPDATE accountdetails set balance='"+total+"' where fname='"+first+"'
and lname='"+last+"'");
JOptionPane.showMessageDialog(this, "Amount deposited successfully");
}
catch(SQLException e)

{
System.out.println("error,error in connection");
}
}
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton2ActionPerformed


new Profile(first,last).setVisible(true); // TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed

/**
* @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(Deposit.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Deposit.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Deposit.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Deposit.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() {

}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JComboBox c1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;


private javax.swing.JLabel l5;
private javax.swing.JTextField t1;
private javax.swing.JTextField t2;
private javax.swing.JTextField t3;
// End of variables declaration//GEN-END:variables
}

WITHDRAW SCREEN
This is the withdraw screen used to withdraw certain amount after selecting Withdraw button
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package atm;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.JOptionPane;

/**
*
* @author Niharika Jain
*/

public class Withdraw extends javax.swing.JFrame {


Connection con;
Statement st;
ResultSet rs;
DateFormat d;
String first1;
String last1;
String type1="debit";
String status1=null;
String acctno1;
String transid1;
String transdate1;
int chequeno1=0;
String chebankname1=null;
float balance1;
float total1;
float amount1;
public final class SessionIdentifierGenerator{
private SecureRandom random=new SecureRandom();
public String nextSessionId()
{
return new BigInteger(30,random).toString();
}
}

public Withdraw(String u,String v) {


initComponents();
try{
Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","123");
}
catch(ClassNotFoundException ex){
System.out.print("Unable to load Driver");
}
catch(SQLException e){
System.out.print("Error in connection");
}
first1=u;
last1=v;
d =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal=Calendar.getInstance();
l6.setText(d.format(cal.getTime()));
transdate1=d.format(cal.getTime());
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


l7 = new javax.swing.JLabel();
l8 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();

t4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
l6 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N


jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("NATIONAL BANK ATM SERVICE");

l7.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l8.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N

jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel2.setText("Enter amount :-");

jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton1.setText("Get Cash");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jButton2.setText("Back");

jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

l6.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


l6.setText("jLabel4");

jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N


jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("Please enter amount LESS THAN 10000 INR");

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(77, 77, 77)
.addComponent(l7, javax.swing.GroupLayout.PREFERRED_SIZE, 257,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(l6, javax.swing.GroupLayout.PREFERRED_SIZE, 360,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(l8, javax.swing.GroupLayout.PREFERRED_SIZE, 220,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(142, 142, 142)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 384,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(112, 112, 112)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 157,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(111, 111, 111)
.addComponent(t4, javax.swing.GroupLayout.PREFERRED_SIZE, 141,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(245, 245, 245)
.addComponent(jButton1)
.addGap(99, 99, 99)
.addComponent(jButton2)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(151, 151, 151)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 390,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 46,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(l7, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(l8, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(l6, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(75, 75, 75)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t4, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(106, 106, 106)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(117, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed

Withdraw.SessionIdentifierGenerator ob=new Withdraw.SessionIdentifierGenerator();


transid1=ob.nextSessionId();
amount1=Float.parseFloat(t4.getText());
try
{

st=con.createStatement();
rs=st.executeQuery("select * from accountdetails where fname='"+first1+"' and
lname='"+last1+"'");
if(rs.next()){
acctno1=rs.getString(1);
balance1=Float.parseFloat(rs.getString(5));

else
{
JOptionPane.showMessageDialog(this,"No Account exists");
}
if(amount1<=balance1)
{
if(amount1<=10000)
{
total1=balance1-amount1;
int val1=st.executeUpdate("INSERT into transaction
values('"+transid1+"','"+acctno1+"','"+status1+"','"+chequeno1+"','"+chebankname1+"','"+amount1+"','"
+type1+"','"+transdate1+"')");
int cou1=st.executeUpdate("UPDATE accountdetails set balance='"+total1+"' where
fname='"+first1+"' and lname='"+last1+"'");

JOptionPane.showMessageDialog(this, "Please collect your cash");


}
else
{
JOptionPane.showMessageDialog(this,"Please enter amount less than or equal to 10000 INR");
}
}
else
{
JOptionPane.showMessageDialog(this,"You dont have sufficient balance in your account. Please
check your balance and enter valid amount");
}

}//GEN-LAST:event_jButton1ActionPerformed
catch(SQLException e)
{
System.out.println("error,error withdraw in connection");
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton2ActionPerformed
new Profile(first1,last1).setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed

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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(Withdraw.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Withdraw.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Withdraw.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Withdraw.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() {

}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel l6;
private javax.swing.JLabel l7;
private javax.swing.JLabel l8;
private javax.swing.JTextField t4;
// End of variables declaration//GEN-END:variables
}

Вам также может понравиться