Академический Документы
Профессиональный Документы
Культура Документы
For Database:
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));
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;
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
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
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
/**
* @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>
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);
); /* 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
/**
* @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);
ex);
}
ex);
}
ex);
}
//</editor-fold>
}
});
}
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;
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() {
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);
.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
/**
* @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);
ex);
}
ex);
}
ex);
}
//</editor-fold>
}
});
}
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 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
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
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() {
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);
}
});
.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)
pack();
}// </editor-fold>//GEN-END:initComponents
}//GEN-LAST:event_rb1ActionPerformed
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");
}
java.awt.EventQueue.invokeLater(new Runnable(){
public void run() {
}
});
}
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;
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
});
.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
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
/**
* @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>
}
});
}
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
*/
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() {
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);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
.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)
pack();
}// </editor-fold>//GEN-END:initComponents
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+"'");
}//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
/* 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>
}
});
}