├── Resources ├── img ├── 1.jpg ├── ok.png ├── IMG.jpg ├── back.jpg ├── bank.jpg ├── cancel.png ├── clear.png ├── current.png ├── print.png └── saving.png ├── README.md └── src └── files ├── Welcome.java ├── LoanInformation.java ├── Help.java ├── BalanceEnquiry.java ├── MiniStatement.java ├── TransactionMenu.java ├── pinChange.java ├── AccountType.java ├── Atmcardno.java └── CashWithdrawal.java /Resources: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/1.jpg -------------------------------------------------------------------------------- /img/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/ok.png -------------------------------------------------------------------------------- /img/IMG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/IMG.jpg -------------------------------------------------------------------------------- /img/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/back.jpg -------------------------------------------------------------------------------- /img/bank.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/bank.jpg -------------------------------------------------------------------------------- /img/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/cancel.png -------------------------------------------------------------------------------- /img/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/clear.png -------------------------------------------------------------------------------- /img/current.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/current.png -------------------------------------------------------------------------------- /img/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/print.png -------------------------------------------------------------------------------- /img/saving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/ATM-Simulator-in-Java/master/img/saving.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ATM-Simulator- 2 | An College Mini Project for the subject OOPs created to minimize load of student accounts management for Adminstrator 3 | -------------------------------------------------------------------------------- /src/files/Welcome.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Image; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | import javax.imageio.ImageIO; 12 | import javax.swing.ImageIcon; 13 | import javax.swing.JButton; 14 | import javax.swing.JFrame; 15 | import javax.swing.JLabel; 16 | import javax.swing.JTextField; 17 | 18 | public class Welcome extends JFrame implements ActionListener 19 | { 20 | JFrame jf; 21 | Font f,f1; 22 | JButton b,b1; 23 | JLabel l2,l3,l4 ; 24 | JTextField t1; 25 | 26 | public Welcome() 27 | { 28 | jf=new JFrame(); 29 | try { 30 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bank.jpg"))))); 31 | 32 | } catch (IOException e) { 33 | System.out.println("image failure"); 34 | } 35 | f = new Font("Times New Roman",Font.BOLD,20); // for button 36 | f1 = new Font("Times New Roman",Font.BOLD,25); //for label 37 | jf.setLayout(null); 38 | 39 | l2=new JLabel("Welcome To Pict Bank"); 40 | l2.setFont(new Font("Times New Roman",Font.BOLD,40)); 41 | l2.setForeground(Color.BLUE); 42 | l2.setBounds(180,230,500,30); 43 | jf.add(l2); 44 | 45 | l3=new JLabel("ATM Services"); 46 | l3.setFont(new Font("Times New Roman",Font.BOLD,30)); 47 | l3.setForeground(Color.BLUE); 48 | l3.setBounds(300,300,300,30); 49 | jf.add(l3); 50 | 51 | l4=new JLabel("Press OK To Use ATM Service or Press Exit to quit "); 52 | l4.setFont(f1); 53 | l4.setForeground(Color.BLUE); 54 | l4.setBounds(120,370,580,30); 55 | jf.add(l4); 56 | 57 | 58 | 59 | b=new JButton("Ok"); 60 | Image img = new ImageIcon(this.getClass().getResource("/ok.png")).getImage(); 61 | b.setIcon(new ImageIcon(img)); 62 | b.setFont(f); 63 | b.setBounds(200,550,130,60); 64 | jf.add(b); 65 | b.addActionListener(this); 66 | 67 | b1=new JButton("Exit"); 68 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 69 | b1.setIcon(new ImageIcon(img2)); 70 | b1.setFont(f); 71 | b1.setBounds(450,550,130,60); 72 | jf.add(b1); 73 | b1.addActionListener(this); 74 | 75 | jf.setTitle("WELCOME TO PICT BANK ATM"); 76 | jf.setSize(800,700); 77 | jf.setLocation(520,150); 78 | jf.setResizable(false); 79 | jf.setVisible(true); 80 | 81 | } 82 | 83 | public void actionPerformed(ActionEvent ae) 84 | { 85 | if(ae.getSource()==b) 86 | { 87 | new Atmcardno(); 88 | jf.setVisible(false); 89 | 90 | } 91 | else if(ae.getSource()==b1) 92 | { 93 | System.exit(0); 94 | } 95 | } 96 | public static void main(String args[]) 97 | { 98 | new Welcome(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/files/LoanInformation.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Image; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | import javax.imageio.ImageIO; 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JFrame; 16 | import javax.swing.JLabel; 17 | import javax.swing.JOptionPane; 18 | 19 | 20 | 21 | public class LoanInformation extends JFrame implements ActionListener{ 22 | 23 | JFrame jf; 24 | Font f,f1; 25 | JLabel l1,l2,l3,l4,l5,l6,l7; 26 | JButton cancel; 27 | 28 | LoanInformation() 29 | { 30 | jf=new JFrame(); 31 | try { 32 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bank.jpg"))))); 33 | } catch (IOException e) { 34 | System.out.println("image failure"); 35 | } 36 | f = new Font("Times New Roman",Font.BOLD,20);//button 37 | f1 = new Font("Times New Roman",Font.BOLD,25);//label 38 | jf.setLayout(null); 39 | 40 | 41 | l1=new JLabel("Loan Information"); 42 | l1.setFont(new Font("Times New ROman",Font.BOLD,30)); 43 | l1.setForeground(Color.BLUE); 44 | l1.setBounds(280,250,250,20); 45 | jf.add(l1); 46 | 47 | l2=new JLabel("Home Loan @ only 9%."); 48 | l2.setFont(f1); 49 | l2.setForeground(Color.WHITE); 50 | l2.setBounds(40,300,680,25); 51 | jf.add(l2); 52 | 53 | l3=new JLabel("Personal Loan @ only 10%."); 54 | l3.setFont(f1); 55 | l3.setForeground(Color.WHITE); 56 | l3.setBounds(40,350,680,25); 57 | jf.add(l3); 58 | 59 | l4=new JLabel("Car Loan @ only 12%."); 60 | l4.setFont(f1); 61 | l4.setForeground(Color.WHITE); 62 | l4.setBounds(40,400,680,25); 63 | jf.add(l4); 64 | 65 | l5=new JLabel("Student Loan @ only 5%."); 66 | l5.setFont(f1); 67 | l5.setForeground(Color.WHITE); 68 | l5.setBounds(40,450,680,25); 69 | jf.add(l5); 70 | 71 | l6=new JLabel("Computer or Laptop Loan @ only 8%."); 72 | l6.setFont(f1); 73 | l6.setForeground(Color.WHITE); 74 | l6.setBounds(40,500,680,25); 75 | jf.add(l6); 76 | 77 | 78 | 79 | 80 | 81 | cancel=new JButton("Cancel",new ImageIcon("cancel.png")); 82 | Image img = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 83 | cancel.setIcon(new ImageIcon(img )); 84 | cancel.setFont(f); 85 | cancel.setBounds(280,580,150,60); 86 | cancel.addActionListener(this); 87 | jf.add(cancel); 88 | 89 | 90 | 91 | jf.setTitle("Loan Information"); 92 | jf.setSize(800,700); 93 | jf.setLocation(520,150); 94 | jf.setResizable(false); 95 | jf.setVisible(true); 96 | } 97 | 98 | @Override 99 | public void actionPerformed(ActionEvent e) { 100 | 101 | if(e.getSource()==cancel) 102 | { 103 | 104 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 105 | new Welcome(); 106 | jf.setVisible(false); 107 | } 108 | } 109 | /* public static void main(String args[]) 110 | { 111 | new LoanInformation(); 112 | } */ 113 | } 114 | 115 | -------------------------------------------------------------------------------- /src/files/Help.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Image; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | import javax.imageio.ImageIO; 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JFrame; 16 | import javax.swing.JLabel; 17 | import javax.swing.JOptionPane; 18 | 19 | public class Help extends JFrame implements ActionListener{ 20 | 21 | JFrame jf; 22 | Font f,f1; 23 | JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14; 24 | JButton cancel; 25 | 26 | 27 | 28 | 29 | Help() 30 | { 31 | jf=new JFrame(); 32 | try { 33 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bank.jpg"))))); 34 | 35 | } catch (IOException e) { 36 | System.out.println("image failure"); 37 | } 38 | 39 | f = new Font("Times New Roman",Font.BOLD,20);//button 40 | f1 = new Font("Times New Roman",Font.BOLD+Font.ITALIC,25);//label 41 | jf.setLayout(null); 42 | 43 | 44 | l1=new JLabel("Help"); 45 | l1.setFont(new Font("Times New Roman",Font.BOLD,30)); 46 | l1.setForeground(Color.BLUE); 47 | l1.setBounds(360,140,200,30); 48 | jf.add(l1); 49 | 50 | l2=new JLabel("Cash Withdrawal: options used to getting money from the ATM."); 51 | l2.setFont(f); 52 | l2.setForeground(Color.WHITE); 53 | l2.setBounds(40,200,670,25); 54 | jf.add(l2); 55 | 56 | l3=new JLabel("Balance Inquiry: A balance inquiry is a review of any type of account "); 57 | l3.setFont(f); 58 | l3.setForeground(Color.WHITE); 59 | l3.setBounds(40,240,670,25); 60 | jf.add(l3); 61 | 62 | l4=new JLabel("Mini statement used to print your balance."); 63 | l4.setFont(f); 64 | l4.setForeground(Color.WHITE); 65 | l4.setBounds(40,280,650,25); 66 | jf.add(l4); 67 | 68 | l5=new JLabel("Electricty bill used pay electricty bill."); 69 | l5.setFont(f); 70 | l5.setForeground(Color.WHITE); 71 | l5.setBounds(40,320,650,25); 72 | jf.add(l5); 73 | 74 | l6=new JLabel("cash deposit used deposit money into your account."); 75 | l6.setFont(f); 76 | l6.setForeground(Color.WHITE); 77 | l6.setBounds(40,360,650,25); 78 | jf.add(l6); 79 | 80 | l7=new JLabel("PIN change option used to change PIN no of ATM card."); 81 | l7.setFont(f); 82 | l7.setForeground(Color.WHITE); 83 | l7.setBounds(40,400,670,25); 84 | jf.add(l7); 85 | 86 | 87 | l8=new JLabel("Loan information option used to give various loan rate."); 88 | l8.setFont(f); 89 | l8.setForeground(Color.WHITE); 90 | l8.setBounds(40,440,650,25); 91 | jf.add(l8); 92 | 93 | 94 | l9=new JLabel("For more information Visit our your nearest branch of PICT-Bank."); 95 | l9.setFont(f); 96 | l9.setForeground(Color.WHITE); 97 | l9.setBounds(40,480,700,25); 98 | jf.add(l9); 99 | 100 | l10=new JLabel("This ATM project developed by,"); 101 | l10.setFont(f); 102 | l10.setForeground(Color.RED); 103 | l10.setBounds(40,520,300,25); 104 | jf.add(l10); 105 | 106 | l11=new JLabel("Ashlesh, Megha and Adil"); 107 | l11.setFont(f1); 108 | l11.setForeground(Color.RED); 109 | l11.setBounds(320,530,500,30); 110 | jf.add(l11); 111 | 112 | l12=new JLabel("Under the guidence of "); 113 | l12.setFont(f); 114 | l12.setForeground(Color.RED); 115 | l12.setBounds(40,570,200,20); 116 | jf.add(l12); 117 | 118 | l13=new JLabel("Mr Zakee Ahmed Sir"); 119 | l13.setFont(f1); 120 | l13.setForeground(Color.RED); 121 | l13.setBounds(250,580,250,30); 122 | jf.add(l13); 123 | 124 | cancel=new JButton("Cancel"); 125 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 126 | cancel.setIcon(new ImageIcon(img2)); 127 | cancel.setFont(f); 128 | cancel.setBounds(600,600,150,60); 129 | cancel.addActionListener(this); 130 | jf.add(cancel); 131 | 132 | 133 | 134 | jf.setTitle("Help"); 135 | jf.setSize(800,700); 136 | jf.setLocation(520,150); 137 | jf.setResizable(false); 138 | jf.setVisible(true); 139 | 140 | 141 | 142 | } 143 | 144 | 145 | public void actionPerformed(ActionEvent ae) 146 | { 147 | if(ae.getSource()==cancel) 148 | { 149 | 150 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 151 | 152 | new Welcome(); 153 | jf.setVisible(false); 154 | } 155 | } 156 | /*public static void main(String[] args) { 157 | new Help(); 158 | }*/ 159 | 160 | } 161 | 162 | -------------------------------------------------------------------------------- /src/files/BalanceEnquiry.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Image; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.ResultSet; 13 | 14 | import java.util.Calendar; 15 | import java.util.Date; 16 | import java.util.GregorianCalendar; 17 | 18 | import javax.imageio.ImageIO; 19 | import javax.swing.ImageIcon; 20 | import javax.swing.JButton; 21 | import javax.swing.JFrame; 22 | import javax.swing.JLabel; 23 | import javax.swing.JOptionPane; 24 | 25 | 26 | import com.mysql.jdbc.Statement; 27 | 28 | public class BalanceEnquiry extends JFrame implements ActionListener { 29 | 30 | int atno,acno,pno; 31 | String actype ; 32 | String strdate,strtime; 33 | 34 | JFrame jf; 35 | JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10; 36 | JButton b1; 37 | 38 | Connection con; 39 | Statement st; 40 | ResultSet rs; 41 | 42 | Date date; 43 | GregorianCalendar calendar; 44 | 45 | 46 | public BalanceEnquiry(int atno1,int acno1,int pno1,String actype1) { 47 | 48 | Font f,f1; 49 | atno=atno1; 50 | acno=acno1; 51 | pno=pno1; 52 | actype=actype1; 53 | 54 | date=new Date(); 55 | calendar=new GregorianCalendar(); 56 | calendar.setTime(date); 57 | strdate =calendar.get(Calendar.YEAR)+"-"+(calendar.get(Calendar.MONTH)+1)+"-"+calendar.get(Calendar.DATE); 58 | strtime=date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); 59 | 60 | System.out.println(strdate + " : "+ strtime); 61 | 62 | jf= new JFrame( ); 63 | try { 64 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\back.jpg"))))); 65 | 66 | } catch (IOException e) { 67 | System.out.println("image failure"); 68 | } 69 | f=new Font("Times New Roman", Font.BOLD, 20); 70 | f1=new Font("Times New Roman", Font.BOLD, 25); 71 | jf.setLayout(null); 72 | 73 | l1=new JLabel("Balance Enquiry"); 74 | l1.setFont(new Font("Times New Roman",Font.BOLD,30)); 75 | l1.setForeground(Color.BLUE); 76 | l1.setBounds(250,250,250,30); 77 | jf.add(l1); 78 | 79 | l2=new JLabel("Date"); 80 | l2.setFont(f1); 81 | l2.setForeground(Color.magenta); 82 | l2.setBounds(100,300,70,30); 83 | jf.add(l2); 84 | 85 | l3=new JLabel(strdate); 86 | l3.setFont(f1); 87 | l3.setForeground(Color.BLACK); 88 | l3.setBounds(100,350,150,30); 89 | jf.add(l3); 90 | 91 | l4=new JLabel("Time"); 92 | l4.setFont(f1); 93 | l4.setForeground(Color.magenta); 94 | l4.setBounds(300,300,70,30); 95 | jf.add(l4); 96 | 97 | l5=new JLabel(strtime); 98 | l5.setFont(f1); 99 | l5.setForeground(Color.BLACK); 100 | l5.setBounds(300,350,150,30); 101 | jf.add(l5); 102 | 103 | l6=new JLabel("Atm no"); 104 | l6.setFont(f1); 105 | l6.setForeground(Color.magenta); 106 | l6.setBounds(500,300,110,30); 107 | jf.add(l6); 108 | 109 | l7=new JLabel(); 110 | l7.setFont(f1); 111 | l7.setForeground(Color.BLACK); 112 | l7.setBounds(500,350,300,30); 113 | jf.add(l7); 114 | 115 | l8=new JLabel("Available Balance in Rs:"); 116 | l8.setFont(f1); 117 | l8.setForeground(Color.magenta); 118 | l8.setBounds(100,400,270,30); 119 | jf.add(l8); 120 | 121 | l9=new JLabel(); 122 | l9.setFont(f1); 123 | l9.setForeground(Color.BLACK); 124 | l9.setBounds(380,400,270,30); 125 | jf.add(l9); 126 | 127 | l10=new JLabel("Thank You For Banking With PICT BANK "); 128 | l10.setFont(f); 129 | l10.setForeground(Color.RED); 130 | l10.setBounds(200,450,650,20); 131 | jf.add(l10); 132 | 133 | b1=new JButton("Cancel"); 134 | Image img = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 135 | b1.setIcon(new ImageIcon(img)); 136 | b1.setFont(f); 137 | b1.setBounds(280,500,150,60); 138 | jf.add(b1); 139 | b1.addActionListener(this); 140 | 141 | try { 142 | Class.forName("com.mysql.jdbc.Driver"); 143 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 144 | System.out.println("Connected to database."); 145 | 146 | st=(Statement) con.createStatement(); 147 | rs=st.executeQuery("select balance from accountdetail where atmno='"+atno+"' and pinno='"+pno+"'"); 148 | rs.next(); 149 | int avbal=rs.getInt(1); 150 | System.out.println("available balance is :"+avbal); 151 | 152 | l7.setText(String.valueOf(atno)); 153 | l9.setText(String.valueOf(avbal)+" /-"); 154 | st.close(); 155 | con.close(); 156 | 157 | } catch ( Exception e1) { 158 | 159 | e1.printStackTrace(); 160 | } 161 | 162 | 163 | jf.setTitle("BALANCE ENQUIRY"); 164 | jf.setSize(800,700); 165 | jf.setLocation(520, 150); 166 | jf.setResizable(false); 167 | jf.setVisible(true); 168 | 169 | } 170 | public void actionPerformed(ActionEvent e) { 171 | // TODO Auto-generated method stub 172 | if(e.getSource()==b1) 173 | { 174 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 175 | 176 | new Welcome(); 177 | jf.setVisible(false); 178 | } 179 | } 180 | /*public static void main(String[] args) { 181 | new BalanceEnquiry(1000, 10001, 1111, "Saving"); 182 | }*/ 183 | 184 | } 185 | -------------------------------------------------------------------------------- /src/files/MiniStatement.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Image; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.PreparedStatement; 13 | import java.sql.ResultSet; 14 | import java.sql.SQLException; 15 | import java.sql.Statement; 16 | 17 | 18 | import javax.imageio.ImageIO; 19 | import javax.swing.ImageIcon; 20 | import javax.swing.JButton; 21 | import javax.swing.JFrame; 22 | import javax.swing.JLabel; 23 | import javax.swing.JOptionPane; 24 | import javax.swing.JScrollPane; 25 | import javax.swing.JTable; 26 | 27 | import javax.swing.table.DefaultTableModel; 28 | 29 | 30 | public class MiniStatement extends JFrame implements ActionListener{ 31 | JFrame jf; 32 | Font f,f1; 33 | JButton b1; 34 | JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9; 35 | 36 | Connection con; 37 | PreparedStatement ps,ps1; 38 | Statement stmt; 39 | ResultSet rs; 40 | 41 | 42 | int atno,acno,pno; 43 | String actype,strdate,strtime; 44 | float givam,amt,abal,amtmin,sumbal; 45 | 46 | DefaultTableModel model = new DefaultTableModel(); 47 | JTable tabGrid = new JTable(model); 48 | JScrollPane scrlPane = new JScrollPane(tabGrid); 49 | 50 | public MiniStatement(int atno1,int acno1,int pno1,String actype1) 51 | { 52 | atno=atno1; 53 | acno=acno1; 54 | pno=pno1; 55 | actype=actype1;//int atno=1000,acno=10001; 56 | 57 | 58 | jf=new JFrame(); 59 | try { 60 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bak2.jpg"))))); 61 | } catch (IOException e) { 62 | System.out.println("image failure"); 63 | } 64 | f = new Font("Times New Roman",Font.BOLD,20);//button 65 | f1 = new Font("Times New Roman",Font.BOLD,15);//label 66 | jf.setLayout(null); 67 | 68 | 69 | 70 | l1=new JLabel("MINI STATEMENT"); 71 | l1.setFont(new Font("Times New Roman",Font.BOLD,30)); 72 | l1.setForeground(Color.BLUE); 73 | l1.setBounds(270,70,500,30); 74 | jf.add(l1); 75 | 76 | l2=new JLabel("Account Holder:"); 77 | l2.setFont(f1); 78 | l2.setForeground(Color.red); 79 | l2.setBounds(100,250,150,20); 80 | jf.add(l2); 81 | 82 | l3=new JLabel( ); 83 | l3.setFont(f1); 84 | l3.setForeground(Color.DARK_GRAY); 85 | l3.setBounds(100,270,150,20); 86 | jf.add(l3); 87 | 88 | 89 | l4=new JLabel("Acc no:"); 90 | l4.setFont(f1); 91 | l4.setForeground(Color.red); 92 | l4.setBounds(350,250,70,20); 93 | jf.add(l4); 94 | 95 | l5=new JLabel( ); 96 | l5.setFont(f1); 97 | l5.setForeground(Color.DARK_GRAY); 98 | l5.setBounds(350,270,150,20); 99 | jf.add(l5); 100 | 101 | l6=new JLabel("ATM NO:"); 102 | l6.setFont(f1); 103 | l6.setForeground(Color.red); 104 | l6.setBounds(600,250,110,20); 105 | jf.add(l6); 106 | 107 | l7=new JLabel(); 108 | l7.setFont(f1); 109 | l7.setForeground(Color.DARK_GRAY); 110 | l7.setBounds(600,270,300,20); 111 | jf.add(l7); 112 | 113 | scrlPane.setBounds(100,300,600,190); 114 | jf.add(scrlPane); 115 | tabGrid.setFont(new Font ("Aerial",0,15)); 116 | 117 | model.addColumn("TR-Date"); 118 | model.addColumn("Deposit-amt"); 119 | model.addColumn("Withdraw-amt"); 120 | model.addColumn("Balance"); 121 | 122 | l8=new JLabel("Available balance:"); 123 | l8.setFont(f1); 124 | l8.setForeground(Color.red); 125 | l8.setBounds(100,500,130,20); 126 | jf.add(l8); 127 | 128 | l9=new JLabel(); 129 | l9.setFont(f1); 130 | l9.setForeground(Color.DARK_GRAY); 131 | l9.setBounds(230,500,150,20); 132 | jf.add(l9); 133 | 134 | b1=new JButton("Cancel" ); 135 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 136 | b1.setIcon(new ImageIcon(img2)); 137 | b1.setFont(f); 138 | b1.setBounds(320,600,150,60); 139 | jf.add(b1); 140 | b1.addActionListener(this); 141 | 142 | jf.setTitle("Mini Statement"); 143 | jf.setSize(800,700); 144 | jf.setLocation(520,150); 145 | jf.setResizable(false); 146 | jf.setVisible(true); 147 | 148 | try 149 | { 150 | Class.forName("com.mysql.jdbc.Driver"); 151 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 152 | System.out.println("Connected to database."); 153 | ps1=con.prepareStatement("select * from transaction where atmno='"+atno+"' and accno='"+acno+"'"); 154 | rs=ps1.executeQuery(); 155 | int r=0; 156 | rs.last(); 157 | while(rs.previous()) 158 | { 159 | model.insertRow(r++,new Object[]{rs.getString(7),rs.getString(4),rs.getString(5),rs.getString(6)}); 160 | 161 | } 162 | 163 | ps=con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 164 | rs=ps.executeQuery(); 165 | while(rs.next()) 166 | { 167 | String acname=rs.getString(5); 168 | System.out.println(acname); 169 | l3.setText(acname); 170 | int accno =rs.getInt(2); 171 | System.out.println("account number is :"+accno); 172 | l5.setText(String.valueOf(accno)); 173 | String atno2=rs.getString(1); 174 | System.out.println("ATM NO is :"+atno2); 175 | l7.setText(atno2); 176 | String curbal=rs.getString(6); 177 | System.out.println("Available balance are:"+curbal+"/-"); 178 | l9.setText(curbal+"/-"); 179 | } 180 | con.close(); 181 | } 182 | catch(SQLException se) 183 | { 184 | System.out.println(se); 185 | //JOptionPane.showMessageDialog(null,"SQL Error:"+se); 186 | } 187 | catch(Exception e) 188 | { 189 | System.out.println(e); 190 | //JOptionPane.showMessageDialog(null,"Error:"+e); 191 | } 192 | 193 | 194 | } 195 | public void actionPerformed(ActionEvent ae) 196 | { 197 | if(ae.getSource()==b1) 198 | { 199 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 200 | 201 | 202 | new Welcome(); 203 | jf.setVisible(false); 204 | } 205 | } 206 | /* public static void main(String args[]) 207 | { 208 | new MiniStatement(1000,10001,1111,"saving"); 209 | } 210 | */ 211 | } 212 | -------------------------------------------------------------------------------- /src/files/TransactionMenu.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Image; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.sql.Connection; 12 | import java.sql.DriverManager; 13 | import java.sql.PreparedStatement; 14 | import java.sql.ResultSet; 15 | import java.sql.Statement; 16 | 17 | import javax.imageio.ImageIO; 18 | import javax.swing.ImageIcon; 19 | import javax.swing.JButton; 20 | import javax.swing.JFrame; 21 | import javax.swing.JLabel; 22 | import javax.swing.JOptionPane; 23 | import javax.swing.JTextField; 24 | import javax.swing.Timer; 25 | 26 | 27 | public class TransactionMenu extends JFrame implements ActionListener 28 | { 29 | 30 | JFrame jf; 31 | Font f,f1; 32 | JButton b1,b2,b3,b4,b5,b6,b7; 33 | JLabel l1; 34 | JTextField t1; 35 | 36 | Connection con; 37 | PreparedStatement ps; 38 | Statement stmt; 39 | ResultSet rs; 40 | 41 | Timer t; 42 | int atno,acno,pno; 43 | String actype; 44 | 45 | public TransactionMenu(int atno1,int acno1,int pno1,String actype1) 46 | { 47 | atno=atno1; 48 | acno=acno1; 49 | pno=pno1; 50 | actype=actype1; 51 | 52 | jf=new JFrame(); 53 | f = new Font("Times New Roman",Font.BOLD,20);//button 54 | f1 = new Font("Times New Roman",Font.BOLD,25);//label 55 | jf.setLayout(null); 56 | try { 57 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\1.jpg"))))); 58 | // jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("F:\\images_mini\\IMG.jpg"))))); 59 | } catch (IOException e) { 60 | System.out.println("image failure"); 61 | } 62 | 63 | 64 | 65 | 66 | l1=new JLabel("Select Any One Option From The Following"); 67 | l1.setFont(f1); 68 | l1.setForeground(Color.BLUE); 69 | l1.setBounds(130,250,600,30); 70 | jf.add(l1); 71 | 72 | b1=new JButton("Cash Withdrawal"); 73 | b1.setFont(f); 74 | b1.setBounds(120,300,200,50); 75 | jf.add(b1); 76 | b1.addActionListener(this); 77 | 78 | b2=new JButton("Balance Enquiry"); 79 | b2.setFont(f); 80 | b2.setBounds(120,400,200,50); 81 | jf.add(b2); 82 | b2.addActionListener(this); 83 | 84 | b3=new JButton("Mini Statement"); 85 | b3.setFont(f); 86 | b3.setBounds(120,500,200,50); 87 | jf.add(b3); 88 | b3.addActionListener(this); 89 | 90 | 91 | 92 | b4=new JButton("Pin change"); 93 | b4.setFont(f); 94 | b4.setBounds(450,300,200,50); 95 | jf.add(b4); 96 | b4.addActionListener(this); 97 | 98 | b5=new JButton("Loan Information"); 99 | b5.setFont(f); 100 | b5.setBounds(450,400,200,50); 101 | jf.add(b5); 102 | b5.addActionListener(this); 103 | 104 | b6=new JButton("Help"); 105 | b6.setFont(f); 106 | b6.setBounds(450,500,200,50); 107 | jf.add(b6); 108 | b6.addActionListener(this); 109 | 110 | b7=new JButton("Cancel"); 111 | Image img = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 112 | b7.setIcon(new ImageIcon(img)); 113 | b7.setFont(f); 114 | b7.setBounds(300,580,170,60); 115 | jf.add(b7); 116 | b7.addActionListener(this); 117 | 118 | t1 = new JTextField(20); 119 | t1.setBounds(0,640,800,25); 120 | t1.setBackground(Color.LIGHT_GRAY); 121 | jf.add(t1); 122 | 123 | try { 124 | Class.forName("com.mysql.jdbc.Driver"); 125 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 126 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 127 | rs=ps.executeQuery(); 128 | while(rs.next()) 129 | { 130 | String acname=rs.getString(5); 131 | System.out.println(acname); 132 | t1.setText(acname); 133 | } 134 | ps.close(); 135 | con.close(); 136 | 137 | } catch (Exception e) { 138 | // TODO Auto-generated catch block 139 | e.printStackTrace(); 140 | } 141 | 142 | jf.setTitle("TRANSACTION MENU"); 143 | jf.setSize(800,700); 144 | jf.setLocation(520,150); 145 | jf.setResizable(false); 146 | jf.setVisible(true); 147 | 148 | t =new Timer(20000,this);// 20 miLLisecond 149 | t.start(); 150 | } 151 | 152 | 153 | public void actionPerformed(ActionEvent ae) 154 | { 155 | if(ae.getSource()==t) 156 | { 157 | t.stop(); 158 | int reply=JOptionPane.showConfirmDialog(null,"Do you want continue?","ATM Time Warning",JOptionPane.YES_NO_OPTION); 159 | 160 | if (reply == JOptionPane.YES_OPTION) 161 | { 162 | 163 | t.start(); 164 | } 165 | else if (reply == JOptionPane.NO_OPTION) 166 | { 167 | 168 | t.stop(); 169 | new Welcome(); 170 | jf.setVisible(false); 171 | } 172 | } 173 | else if(ae.getSource()==b1) 174 | { 175 | 176 | t.stop(); 177 | new CashWithdrawal(atno,acno,pno,actype); 178 | jf.setVisible(false); 179 | } 180 | 181 | else if(ae.getSource()==b2) 182 | { 183 | 184 | t.stop(); 185 | new BalanceEnquiry(atno,acno,pno,actype); 186 | jf.setVisible(false); 187 | } 188 | else if(ae.getSource()==b3) 189 | { 190 | 191 | t.stop(); 192 | new MiniStatement(atno,acno,pno,actype); 193 | jf.setVisible(false); 194 | 195 | } 196 | 197 | else if(ae.getSource()==b4) 198 | { 199 | 200 | t.stop(); 201 | new pinChange(atno,acno,pno,actype); 202 | jf.setVisible(false); 203 | } 204 | 205 | else if(ae.getSource()==b5) 206 | { 207 | 208 | t.stop(); 209 | new LoanInformation(); 210 | jf.setVisible(false); 211 | } 212 | else if(ae.getSource()==b6) 213 | { 214 | 215 | t.stop(); 216 | new Help(); 217 | jf.setVisible(false); 218 | } 219 | 220 | else if(ae.getSource()==b7) 221 | { 222 | 223 | t.stop(); 224 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 225 | 226 | new Welcome(); 227 | jf.setVisible(false); 228 | } 229 | 230 | 231 | } 232 | /* public static void main(String args[]) 233 | { 234 | new TransactionMenu(1000,10001,1111,"saving"); 235 | } */ 236 | } 237 | -------------------------------------------------------------------------------- /src/files/pinChange.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Image; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.PreparedStatement; 13 | import java.sql.ResultSet; 14 | 15 | import javax.imageio.ImageIO; 16 | import javax.swing.ImageIcon; 17 | import javax.swing.JButton; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JOptionPane; 21 | import javax.swing.JPasswordField; 22 | 23 | import com.mysql.jdbc.Statement; 24 | 25 | 26 | 27 | public class pinChange extends JFrame implements ActionListener{ 28 | //private static final long serialVersionUID = 1L; 29 | JFrame jf; 30 | Font f,f1; 31 | JButton b1,b2,b3; 32 | JLabel l1,l2,l3; 33 | JPasswordField pwd1,pwd2,pwd3; 34 | 35 | Connection con; 36 | Statement stmt; 37 | PreparedStatement ps; 38 | ResultSet rs; 39 | 40 | int atno,acno,pno; 41 | int pp1,pp2,pp3; 42 | String actype; 43 | public pinChange(int atno1,int acno1,int pno1,String actype1) 44 | { 45 | atno=atno1; 46 | acno=acno1; 47 | pno=pno1; 48 | actype=actype1; 49 | 50 | jf=new JFrame(); 51 | jf.setLayout(null); 52 | try { 53 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\back.jpg"))))); 54 | } catch (IOException e) { 55 | System.out.println("image failure"); 56 | } 57 | f = new Font("Times New Roman",Font.BOLD,20); // for button 58 | f1 = new Font("Times New Roman",Font.BOLD,25); //for label 59 | jf.setLayout(null); 60 | 61 | l1=new JLabel("Old pin"); 62 | l1.setFont(f1); 63 | l1.setForeground(Color.BLUE); 64 | l1.setBounds(250,250,300,30); 65 | jf.add(l1); 66 | 67 | l2=new JLabel("New pin"); 68 | l2.setFont(f1); 69 | l2.setForeground(Color.BLUE); 70 | l2.setBounds(250,300,300,30); 71 | jf.add(l2); 72 | 73 | l3=new JLabel("Confirm pin"); 74 | l3.setFont(f1); 75 | l3.setForeground(Color.BLUE); 76 | l3.setBounds(250,350,300,30); 77 | jf.add(l3); 78 | 79 | pwd1=new JPasswordField(10); 80 | pwd1.setFont(f1); 81 | pwd1.setBounds(400,250,200,30); 82 | jf.add(pwd1); 83 | 84 | pwd2=new JPasswordField(10); 85 | pwd2.setFont(f1); 86 | pwd2.setBounds(400,300,200,30); 87 | jf.add(pwd2); 88 | 89 | pwd3=new JPasswordField(10); 90 | pwd3.setFont(f1); 91 | pwd3.setBounds(400,350,200,30); 92 | jf.add(pwd3); 93 | 94 | b1=new JButton("Enter"); 95 | Image img = new ImageIcon(this.getClass().getResource("/ok.png")).getImage(); 96 | b1.setIcon(new ImageIcon(img)); 97 | b1.setFont(f); 98 | b1.setBounds(120,450,150,60); 99 | jf.add(b1); 100 | b1.addActionListener(this); 101 | 102 | b2=new JButton("Clear"); 103 | Image img1 = new ImageIcon(this.getClass().getResource("/clear.png")).getImage(); 104 | b2.setIcon(new ImageIcon(img1)); 105 | b2.setFont(f); 106 | b2.setBounds(310,450,150,60); 107 | jf.add(b2); 108 | b2.addActionListener(this); 109 | 110 | b3=new JButton("Cancel"); 111 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 112 | b3.setIcon(new ImageIcon(img2)); 113 | b3.setFont(f); 114 | b3.setBounds(500,450,150,60); 115 | jf.add(b3); 116 | b3.addActionListener(this); 117 | 118 | jf.setTitle("Pin Change"); 119 | jf.setSize(800,700); 120 | jf.setLocation(520,150) ; 121 | jf.setResizable(false); 122 | jf.setVisible(true); 123 | } 124 | public void actionPerformed(ActionEvent ae) 125 | { 126 | if(ae.getSource()==b1) //ok hai 127 | { 128 | if(((pwd1.getText()).equals(""))&&((pwd2.getText()).equals(""))&&((pwd3.getText()).equals(""))) 129 | { 130 | JOptionPane.showInternalMessageDialog(this, "Please enter old PIN no 1 times and new PIN 2 times !!","Warning",JOptionPane.WARNING_MESSAGE); 131 | } 132 | else if((Integer.parseInt(pwd2.getText()))!=(Integer.parseInt(pwd3.getText()))) 133 | { 134 | JOptionPane.showMessageDialog(this,"NEW PIN and does not match with repeated PIN !!","Warning",JOptionPane.WARNING_MESSAGE); 135 | 136 | pwd1.setText(""); 137 | pwd2.setText(""); 138 | pwd3.setText(""); 139 | } 140 | else 141 | { 142 | try 143 | { 144 | int foundrec =0; 145 | int oldpin=Integer.parseInt(pwd1.getText()); 146 | Class.forName("com.mysql.jdbc.Driver"); 147 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 148 | System.out.println("Connection established"); 149 | pp1=Integer.parseInt(pwd1.getText()); 150 | pp2=Integer.parseInt(pwd2.getText()); 151 | pp3=Integer.parseInt(pwd3.getText()); 152 | ps=con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and acctype='"+actype+"' and pinno='"+oldpin+"' "); 153 | rs=ps.executeQuery(); 154 | while(rs.next()) 155 | { 156 | foundrec=1; 157 | } 158 | if(foundrec==1) 159 | { 160 | stmt=(Statement) con.createStatement(); 161 | stmt.executeUpdate("update accountdetail set pinno="+pp2+" where atmno='"+atno+"' and accno='"+acno+"' and acctype='"+actype+"' and pinno='"+pp1+"' "); 162 | JOptionPane.showMessageDialog(null,"You have update PIN no succesfully."); 163 | new Welcome(); 164 | jf.setVisible(false); 165 | con.close(); 166 | 167 | } 168 | else 169 | { 170 | JOptionPane.showMessageDialog(null,"You enter wrong old PIN no."); 171 | pwd1.setText(""); 172 | pwd2.setText(""); 173 | pwd3.setText(""); 174 | } 175 | 176 | 177 | } 178 | catch(Exception e) { 179 | e.printStackTrace(); 180 | } 181 | } 182 | } 183 | else if(ae.getSource()==b2) // clear hai 184 | { 185 | pwd1.setText(""); 186 | pwd2.setText(""); 187 | pwd3.setText(""); 188 | } 189 | else //cancel 190 | { 191 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 192 | 193 | new Welcome(); 194 | jf.setVisible(false); 195 | } 196 | } 197 | /* public static void main(String args[]) 198 | { 199 | new pinChange(1000,10001,1111,"saving"); 200 | }*/ 201 | 202 | } 203 | -------------------------------------------------------------------------------- /src/files/AccountType.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Image; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.ResultSet; 13 | import java.sql.SQLException; 14 | 15 | import javax.imageio.ImageIO; 16 | import javax.swing.ImageIcon; 17 | import javax.swing.JButton; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JOptionPane; 21 | import javax.swing.JTextField; 22 | import javax.swing.Timer; 23 | 24 | import com.mysql.jdbc.PreparedStatement; 25 | import com.mysql.jdbc.Statement; 26 | 27 | public class AccountType extends JFrame implements ActionListener 28 | { 29 | JFrame jf; 30 | Font f,f1; 31 | JButton b1,bs1,bc1; 32 | JLabel l2,l4; 33 | JTextField t1; 34 | Connection con; 35 | PreparedStatement ps; 36 | Statement stmt; 37 | ResultSet rs; 38 | 39 | Timer t; 40 | int atno,acno,pno; 41 | String actype,actypegive; 42 | 43 | public AccountType(int atno1,int acno1,int pno1) throws SQLException, ClassNotFoundException 44 | { 45 | atno=atno1; 46 | acno=acno1; 47 | pno=pno1; 48 | 49 | jf=new JFrame(); 50 | 51 | f = new Font("Times New Roman",Font.BOLD,20); //button 52 | f1 = new Font("Times New Roman",Font.BOLD,25); //label 53 | jf.setLayout(null); 54 | try { 55 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bank.jpg"))))); 56 | } catch (IOException e) { 57 | System.out.println("image failure"); 58 | } 59 | 60 | 61 | l4=new JLabel("Account Type"); 62 | l4.setFont(new Font("Times New ROman",Font.BOLD,30)); 63 | l4.setForeground(Color.BLUE); 64 | l4.setBounds(300,250,300,30); 65 | jf.add(l4); 66 | 67 | l2=new JLabel("Select Account Type:"); 68 | l2.setFont(f1); 69 | l2.setForeground(Color.WHITE); 70 | l2.setBounds(120,400,250,30); 71 | jf.add(l2); 72 | 73 | bs1=new JButton("Saving"); 74 | Image img = new ImageIcon(this.getClass().getResource("/saving.png")).getImage(); 75 | bs1.setIcon(new ImageIcon(img)); 76 | bs1.setFont(f); 77 | bs1.setBounds(390,360,180,60); 78 | jf.add(bs1); 79 | bs1.addActionListener(this); 80 | 81 | bc1=new JButton("Current"); 82 | Image img1 = new ImageIcon(this.getClass().getResource("/current.png")).getImage(); 83 | bc1.setIcon(new ImageIcon(img1)); 84 | bc1.setFont(f); 85 | bc1.setBounds(390,440,180,60); 86 | jf.add(bc1); 87 | bc1.addActionListener(this); 88 | 89 | b1=new JButton("Cancel"); 90 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 91 | b1.setIcon(new ImageIcon(img2)); 92 | b1.setFont(f); 93 | b1.setBounds(300,550,180,60); 94 | jf.add(b1); 95 | b1.addActionListener(this); 96 | 97 | t1 = new JTextField(20); 98 | t1.setBounds(0,640,800,25); 99 | t1.setBackground(Color.LIGHT_GRAY); 100 | jf.add(t1); 101 | 102 | jf.setTitle("ACCOUNT TYPE"); 103 | jf.setSize(800,700); 104 | jf.setLocation(520,150); 105 | jf.setResizable(false); 106 | jf.setVisible(true); 107 | 108 | Class.forName("com.mysql.jdbc.Driver"); 109 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 110 | 111 | 112 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 113 | rs=ps.executeQuery(); 114 | while(rs.next()) 115 | { 116 | String acname=rs.getString(5); 117 | System.out.println(acname); 118 | t1.setText(acname); 119 | } 120 | ps.close(); 121 | con.close(); 122 | t =new Timer(20000,this);// 20 millisecond 123 | t.start(); 124 | } 125 | public void actionPerformed(ActionEvent ae) 126 | { 127 | if(ae.getSource()==t) 128 | { 129 | t.stop(); 130 | int reply=JOptionPane.showConfirmDialog(null,"Do you want continue?","ATM Time Warning",JOptionPane.YES_NO_OPTION); 131 | 132 | if (reply == JOptionPane.YES_OPTION) 133 | { 134 | 135 | t.start(); 136 | } 137 | else if (reply == JOptionPane.NO_OPTION) 138 | { 139 | 140 | t.stop(); 141 | new Welcome(); 142 | jf.setVisible(false); 143 | } 144 | } 145 | else if(ae.getSource()==b1) 146 | { 147 | 148 | t.stop(); 149 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 150 | 151 | new Welcome(); 152 | jf.setVisible(false); 153 | } 154 | else if(ae.getSource()==bs1)//saving account matching 155 | { 156 | 157 | t.stop(); 158 | 159 | try 160 | { 161 | 162 | int foundrec = 0; 163 | Class.forName("com.mysql.jdbc.Driver"); 164 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 165 | System.out.println("Connected to database."); 166 | 167 | ps=(PreparedStatement) con.prepareStatement("select acctype from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' "); 168 | rs=ps.executeQuery(); 169 | while(rs.next()) 170 | { 171 | actypegive=rs.getString(1); 172 | System.out.println(actypegive); 173 | foundrec = 1; 174 | } 175 | if (foundrec == 1) 176 | { 177 | if(actypegive.equals("saving")) 178 | { 179 | actype="saving"; 180 | System.out.println(actypegive); 181 | new TransactionMenu(atno,acno,pno,actype); 182 | jf.setVisible(false); 183 | } 184 | else 185 | { 186 | JOptionPane.showMessageDialog(null,"Your account type is not match with given account type.","Warning",JOptionPane.WARNING_MESSAGE); 187 | 188 | new Welcome(); 189 | jf.setVisible(false); 190 | } 191 | } 192 | ps.close(); 193 | con.close(); 194 | } 195 | catch(SQLException se) 196 | { 197 | System.out.println(se); 198 | se.printStackTrace( ); 199 | } 200 | catch(Exception e) 201 | { 202 | System.out.println(e); 203 | e.printStackTrace( ); 204 | } 205 | 206 | } 207 | else if(ae.getSource()==bc1)//current account matching 208 | { 209 | 210 | t.stop(); 211 | try 212 | { 213 | 214 | int foundrec1 = 0; 215 | Class.forName("com.mysql.jdbc.Driver"); 216 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 217 | System.out.println("Connected to database."); 218 | ps=(PreparedStatement) con.prepareStatement("select acctype from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' "); 219 | rs=ps.executeQuery(); 220 | while(rs.next()) 221 | { 222 | actypegive=rs.getString(1); 223 | System.out.println(actypegive); 224 | foundrec1 = 1; 225 | } 226 | if (foundrec1 == 1) 227 | { 228 | if(actypegive.equals("current")) 229 | { 230 | actype="current"; 231 | System.out.println(actype); 232 | new TransactionMenu(atno,acno,pno,actype); 233 | jf.setVisible(false); 234 | } 235 | else 236 | { 237 | JOptionPane.showMessageDialog(null,"Your account type is not match with given account type.","Warning",JOptionPane.WARNING_MESSAGE); 238 | 239 | new Welcome(); 240 | jf.setVisible(false); 241 | } 242 | } 243 | con.close(); 244 | } 245 | catch(SQLException se) 246 | { 247 | System.out.println(se); 248 | JOptionPane.showMessageDialog(null,"SQL Error:"+se); 249 | } 250 | catch(Exception e) 251 | { 252 | System.out.println(e); 253 | JOptionPane.showMessageDialog(null,"Error:"+e); 254 | } 255 | } 256 | } 257 | /* public static void main(String args[]) 258 | { 259 | new AccountType(); 260 | }*/ 261 | 262 | } 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /src/files/Atmcardno.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | 4 | import javax.imageio.ImageIO; 5 | 6 | import javax.swing.ImageIcon; 7 | import javax.swing.JButton; 8 | import javax.swing.JFrame; 9 | import javax.swing.JLabel; 10 | import javax.swing.JOptionPane; 11 | import javax.swing.JPanel; 12 | import javax.swing.JPasswordField; 13 | import javax.swing.JTextField; 14 | import javax.swing.Timer; 15 | 16 | import com.mysql.jdbc.PreparedStatement; 17 | import com.mysql.jdbc.Statement; 18 | 19 | import java.awt.Color; 20 | import java.awt.Font; 21 | import java.awt.Image; 22 | import java.awt.event.ActionEvent; 23 | import java.awt.event.ActionListener; 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.sql.Connection; 27 | import java.sql.DriverManager; 28 | import java.sql.ResultSet; 29 | import java.sql.SQLException; 30 | import java.text.ParseException; 31 | import java.text.SimpleDateFormat; 32 | import java.util.Date; 33 | import java.util.Calendar; 34 | import java.util.GregorianCalendar; 35 | 36 | 37 | public class Atmcardno extends JFrame implements ActionListener 38 | { 39 | JFrame jf; 40 | JPanel statusPanel; 41 | Font f,f1; 42 | JButton b1,b2,b3; 43 | JLabel l2,l3,l4, statuslabel; 44 | 45 | JTextField t1,t2; 46 | JPasswordField pwd; 47 | Connection con; 48 | PreparedStatement ps; 49 | Statement stmt; 50 | ResultSet rs; 51 | 52 | 53 | Timer t; 54 | int atno,acno,pno; 55 | String curdate; 56 | Date date; 57 | GregorianCalendar calendar; 58 | 59 | 60 | public Atmcardno() 61 | { 62 | date= new Date(); 63 | calendar=new GregorianCalendar(); 64 | calendar.setTime(date); 65 | curdate =calendar.get(Calendar.YEAR)+"-"+(calendar.get(Calendar.MONTH)+1)+"-"+calendar.get(Calendar.DATE); 66 | System.out.println(curdate); 67 | 68 | jf=new JFrame(); 69 | try { 70 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\bank.jpg"))))); 71 | } catch (IOException e) { 72 | System.out.println("image failure"); 73 | } 74 | f = new Font("Times New Roman",Font.BOLD,20);//button 75 | f1 = new Font("Times New Roman",Font.BOLD,25);//label 76 | jf.setLayout(null); 77 | 78 | 79 | 80 | l4=new JLabel("ATM Card Number"); 81 | l4.setFont(new Font("Times New Roman",Font.BOLD,30)); 82 | l4.setForeground(Color.BLUE); 83 | l4.setBounds(250,250,300,30); 84 | jf.add(l4); 85 | 86 | l2=new JLabel("Enter ATM card no:"); 87 | l2.setFont(f1); 88 | l2.setForeground(Color.WHITE); 89 | l2.setBounds(120,380,250,30); 90 | jf.add(l2); 91 | 92 | t1 = new JTextField(20); 93 | t1.setBounds(370,380,200,30); 94 | jf.add(t1); 95 | 96 | l3=new JLabel("Enter PIN no:"); 97 | l3.setFont(f1); 98 | l3.setForeground(Color.WHITE); 99 | l3.setBounds(120,430,250,30); 100 | jf.add(l3); 101 | 102 | pwd=new JPasswordField(10); 103 | pwd.setFont(f1); 104 | pwd.setBounds(370,430,200,30); 105 | jf.add(pwd); 106 | 107 | b1=new JButton("Enter"); 108 | Image img = new ImageIcon(this.getClass().getResource("/ok.png")).getImage(); 109 | b1.setIcon(new ImageIcon(img)); 110 | b1.setFont(f); 111 | b1.setBounds(120,550,150,60); 112 | jf.add(b1); 113 | b1.addActionListener(this); 114 | 115 | b2=new JButton("Clear"); 116 | Image img1 = new ImageIcon(this.getClass().getResource("/clear.png")).getImage(); 117 | b2.setIcon(new ImageIcon(img1)); 118 | b2.setFont(f); 119 | b2.setBounds(310,550,150,60); 120 | jf.add(b2); 121 | b2.addActionListener(this); 122 | 123 | b3=new JButton("Cancel"); 124 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 125 | b3.setIcon(new ImageIcon(img2)); 126 | b3.setFont(f); 127 | b3.setBounds(500,550,150,60); 128 | jf.add(b3); 129 | b3.addActionListener(this); 130 | 131 | t2 = new JTextField(20); 132 | t2.setBounds(0,640,800,25); 133 | t2.setBackground(Color.LIGHT_GRAY); 134 | jf.add(t2); 135 | /* statusPanel=new JPanel(); 136 | statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));*/ 137 | /*Creates a bevel border with the specified type and whose colors 138 | will be derived from the background color of the component 139 | passed into the paintBorder method.*/ 140 | /* jf.add(statusPanel,BorderLayout.SOUTH); 141 | statusPanel.setPreferredSize(new Dimension(jf.getWidth(),20)); 142 | statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); 143 | 144 | statuslabel =new JLabel("Login Required...."); 145 | statusPanel.add(statuslabel);*/ 146 | 147 | jf.setTitle("ATM CARD NUMBER"); 148 | jf.setSize(800,700); 149 | jf.setLocation(520,150) ; 150 | jf.setResizable(false); 151 | jf.setVisible(true); 152 | 153 | t =new Timer(20000,this);// 20 Millisecond 154 | t.start(); 155 | 156 | } 157 | 158 | public void actionPerformed(ActionEvent ae) 159 | { 160 | if(ae.getSource()==t) 161 | { 162 | t.stop(); 163 | int reply=JOptionPane.showConfirmDialog(null,"Do you want continue?","ATM Time Warning",JOptionPane.YES_NO_OPTION); 164 | 165 | if (reply == JOptionPane.YES_OPTION) 166 | { 167 | t.start(); 168 | } 169 | else if (reply == JOptionPane.NO_OPTION) 170 | { 171 | t.stop(); 172 | new Welcome(); 173 | jf.setVisible(false); 174 | } 175 | } 176 | else if(ae.getSource()==b1) 177 | { 178 | //fetch 179 | t.stop(); 180 | try 181 | { 182 | if(((t1.getText()).equals(""))&&((pwd.getText()).equals(""))) 183 | { 184 | JOptionPane.showMessageDialog(this,"Please enter ATM card no and PIN no!","Warning",JOptionPane.WARNING_MESSAGE); 185 | } 186 | else 187 | { 188 | int foundrec = 0; 189 | Class.forName("com.mysql.jdbc.Driver"); 190 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 191 | System.out.println("Connected to database."); 192 | t2.setText("Connected to database."); 193 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+t1.getText()+"' and pinno='"+pwd.getText()+"'"); 194 | rs=ps.executeQuery(); 195 | while(rs.next()) 196 | { 197 | 198 | atno=rs.getInt(1); System.out.println("ATM-no:"+atno); 199 | acno=rs.getInt(2); System.out.println("Account-no:"+acno); 200 | pno=rs.getInt(3); System.out.println("pin-no:"+pno); 201 | String cardname=rs.getString(5); System.out.println("card-holder :"+cardname); 202 | String expdate=rs.getString(7); 203 | 204 | try 205 | { 206 | 207 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //CHANGE date format here 208 | Date date1 = sdf.parse(expdate); 209 | Date date2 = sdf.parse(curdate); 210 | 211 | System.out.println("expiry date of atm card:"+sdf.format(date1)); 212 | System.out.println("TodayS date:"+sdf.format(date2)); 213 | 214 | if(date1.compareTo(date2)>=0) 215 | { 216 | System.out.println("Expiry date of atm:"+sdf.format(date1)+" is after today date:"+sdf.format(date2)); 217 | JOptionPane.showMessageDialog(null,"Hello "+cardname); 218 | 219 | new AccountType(atno,acno,pno); 220 | jf.setVisible(false); 221 | } 222 | else if(date1.compareTo(date2)<0) 223 | { 224 | System.out.println("Date1 is before Date2"); 225 | JOptionPane.showMessageDialog(this,"Your atm card is out of expiry date. Please take new ATM card from your home bank.","Warning",JOptionPane.WARNING_MESSAGE); 226 | 227 | new Welcome(); 228 | jf.setVisible(false); 229 | 230 | } 231 | } 232 | catch(ParseException ex) 233 | { 234 | System.out.println("Exception in date format"+ex); 235 | ex.printStackTrace(); 236 | } 237 | 238 | foundrec = 1; 239 | 240 | } 241 | if (foundrec == 0) 242 | { 243 | JOptionPane.showMessageDialog(null,"Invalid ATM card no or PIN no.","Warning",JOptionPane.WARNING_MESSAGE); 244 | 245 | t1.setText("");t2.setText("invalid user..........."); 246 | pwd.setText(""); 247 | } 248 | } con.close(); 249 | } 250 | catch(SQLException se) 251 | { 252 | System.out.println(se); 253 | JOptionPane.showMessageDialog(null,"SQL Error : " +se); 254 | } 255 | catch(Exception e) 256 | { 257 | System.out.println(e); 258 | JOptionPane.showMessageDialog(null,"Error : "+e); 259 | } 260 | } 261 | else if(ae.getSource()==b2) 262 | { 263 | 264 | t1.setText(""); 265 | pwd.setText(""); 266 | 267 | } 268 | else if(ae.getSource()==b3) 269 | { 270 | 271 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 272 | 273 | new Welcome(); 274 | jf.setVisible(false); 275 | } 276 | } 277 | /* public static void main(String args[]) 278 | { 279 | new Atmcardno(); 280 | }*/ 281 | 282 | } 283 | -------------------------------------------------------------------------------- /src/files/CashWithdrawal.java: -------------------------------------------------------------------------------- 1 | package files; 2 | 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Image; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.sql.Connection; 12 | import java.sql.DriverManager; 13 | import java.sql.ResultSet; 14 | import java.sql.SQLException; 15 | import java.util.Calendar; 16 | import java.util.Date; 17 | import java.util.GregorianCalendar; 18 | 19 | import javax.imageio.ImageIO; 20 | import javax.swing.ImageIcon; 21 | import javax.swing.JButton; 22 | import javax.swing.JFrame; 23 | import javax.swing.JLabel; 24 | import javax.swing.JOptionPane; 25 | import javax.swing.JTextField; 26 | 27 | import com.mysql.jdbc.PreparedStatement; 28 | import com.mysql.jdbc.Statement; 29 | 30 | 31 | public class CashWithdrawal extends JFrame implements ActionListener{ 32 | 33 | JFrame jf=new JFrame(); 34 | 35 | Font f,f1; 36 | JButton b1,b2,b3,bs1,bc1; 37 | JLabel l1,l2,l3,l4; 38 | JTextField t1; 39 | 40 | Connection con; 41 | PreparedStatement ps; 42 | Statement stmt,stmt1; 43 | ResultSet rs; 44 | 45 | 46 | int atno,acno,pno; 47 | String actype,strdate; 48 | String curdate; 49 | float givam,amt,abal,amtmin,sumbal; 50 | Date date; 51 | GregorianCalendar calendar; 52 | 53 | public CashWithdrawal(int atno1,int acno1,int pno1,String actype1) 54 | { 55 | atno=atno1; 56 | acno=acno1; 57 | pno=pno1; 58 | actype=actype1; 59 | 60 | date=new Date(); 61 | calendar=new GregorianCalendar(); 62 | calendar.setTime(date); 63 | strdate=calendar.get(Calendar.YEAR)+"-"+(calendar.get(Calendar.MONTH)+1)+"-"+calendar.get(Calendar.DATE); 64 | System.out.println(strdate); 65 | System.out.println(actype); 66 | 67 | jf=new JFrame(); 68 | 69 | 70 | f = new Font("Times New Roman",Font.BOLD,20);//button 71 | f1 = new Font("Times New Roman",Font.BOLD,25);//label 72 | jf.setLayout(null); 73 | try { 74 | jf.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("I:\\PROGRAM\\JAVA PROGRAMS\\programINhome2\\OOPS_PROJECT\\img\\1.jpg"))))); 75 | } catch (IOException e) { 76 | System.out.println("image failure"); 77 | } 78 | 79 | 80 | l1=new JLabel("Cash Withdrawl"); 81 | l1.setFont(new Font("Times New ROman",Font.BOLD,30)); 82 | l1.setForeground(Color.BLUE); 83 | l1.setBounds(250,250,250,30); 84 | jf.add(l1); 85 | 86 | l2=new JLabel("Enter the amount to be withdrawal:"); 87 | l2.setFont(f1); 88 | l2.setForeground(Color.WHITE); 89 | l2.setBounds(100,380,400,30); 90 | jf.add(l2); 91 | 92 | t1=new JTextField(40); 93 | t1.setBounds(500,380,200,30); 94 | jf.add(t1); 95 | 96 | b1=new JButton("Enter"); 97 | Image img = new ImageIcon(this.getClass().getResource("/ok.png")).getImage(); 98 | b1.setIcon(new ImageIcon(img)); 99 | b1.setFont(f); 100 | b1.setBounds( 120,550,150,60); 101 | jf.add(b1); 102 | b1.addActionListener(this); 103 | 104 | b2=new JButton("Clear"); 105 | Image img1 = new ImageIcon(this.getClass().getResource("/clear.png")).getImage(); 106 | b2.setIcon(new ImageIcon(img1)); 107 | b2.setFont(f); 108 | b2.setBounds(320,550,150,60); 109 | jf.add(b2); 110 | b2.addActionListener(this); 111 | 112 | b3=new JButton("Cancel"); 113 | Image img2 = new ImageIcon(this.getClass().getResource("/cancel.png")).getImage(); 114 | b3.setIcon(new ImageIcon(img2)); 115 | b3.setFont(f); 116 | b3.setBounds(520,550,150,60); 117 | jf.add(b3); 118 | b3.addActionListener(this); 119 | 120 | 121 | 122 | jf.setTitle("Cash Withdrawal"); 123 | jf.setSize(800,700); 124 | jf.setLocation(520,150); 125 | jf.setResizable(false); 126 | jf.setVisible(true); 127 | 128 | 129 | } 130 | 131 | public void actionPerformed(ActionEvent ae) 132 | { 133 | if(ae.getSource()==b1) 134 | { 135 | 136 | if(((t1.getText()).equals(""))) 137 | { 138 | JOptionPane.showMessageDialog(this,"Please enter withdrawal amount!","Warning",JOptionPane.WARNING_MESSAGE); 139 | 140 | } 141 | givam=0; 142 | amt=0; 143 | givam=Float.parseFloat(t1.getText()); 144 | System.out.println("You enter amount are:"+givam); 145 | 146 | try 147 | { 148 | 149 | Class.forName("com.mysql.jdbc.Driver"); 150 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atmdb","root","root"); 151 | System.out.println("Connected to database."); 152 | ps=(PreparedStatement) con.prepareStatement("select sum(withamt) from transaction where tdate='"+strdate+"' and atmno='"+atno+"' and accno='"+acno+"'"); 153 | rs=ps.executeQuery(); 154 | while(rs.next())//check today withdrawal sum 155 | { 156 | sumbal=0; 157 | sumbal=sumbal+rs.getFloat(1); 158 | System.out.println("You Today previous wihthdraw Rs:"+sumbal); 159 | } 160 | if(sumbal>1.0) ////if record found on current date then 161 | { 162 | if(actype=="saving")//saving account checking previous amt on current date and enter amt on current date 163 | { 164 | if((sumbal+givam)<=25000) //limit for todays withdrawal............ 165 | { 166 | if(givam<100) 167 | { 168 | JOptionPane.showMessageDialog(this,"You can not withdraw amount less than 100 RS!","Warning",JOptionPane.WARNING_MESSAGE); 169 | 170 | t1.setText(""); 171 | } 172 | else if(givam>10000) 173 | { 174 | JOptionPane.showMessageDialog(this,"You can not withdraw amount greater than 10000 RS at the same time!","Warning",JOptionPane.WARNING_MESSAGE); 175 | 176 | t1.setText(""); 177 | } 178 | else if(givam>100 && (!(givam % 100 ==0))) 179 | { 180 | JOptionPane.showMessageDialog(this,"Withdrawal amount should be multiple of 100","Warning",JOptionPane.WARNING_MESSAGE); 181 | 182 | t1.setText(""); 183 | } 184 | else 185 | { 186 | 187 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' and acctype='"+actype+"'"); 188 | rs=ps.executeQuery(); 189 | if(rs.next()) 190 | { 191 | abal=Float.parseFloat(rs.getString(6)); 192 | 193 | if(abal>1000) // 1000 is min amount in account 194 | { 195 | if(givam<=(abal-1000)) 196 | { 197 | amt=((abal-1000)-givam); 198 | amtmin=(amt+1000); 199 | stmt=(Statement) con.createStatement(); 200 | stmt.executeUpdate("update accountdetail set balance="+amtmin+" where atmno='"+atno+"'"); 201 | System.out.println("You withdraw rs:"+t1.getText()); 202 | stmt1=(Statement) con.createStatement(); 203 | stmt1.executeUpdate("insert into transaction (atmno,accno,depositamt,withamt,avbalance,tdate)values('"+atno+"','"+acno+"',0,'"+givam+"','"+amtmin+"','"+strdate+"') ");// 204 | int reply=JOptionPane.showConfirmDialog(null,"Your cash withdrawal is in processing take money from machine.Do you have to take receipt?","Cash withdrawl Message",JOptionPane.YES_NO_OPTION); 205 | 206 | if (reply == JOptionPane.YES_OPTION) 207 | { 208 | 209 | 210 | new BalanceEnquiry(atno,acno,pno,actype); 211 | jf.setVisible(false); 212 | } 213 | else if (reply == JOptionPane.NO_OPTION) 214 | { 215 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 216 | rs=ps.executeQuery(); 217 | while(rs.next()) 218 | { 219 | float curbal=rs.getFloat(6); 220 | JOptionPane.showMessageDialog(null,"Your available balance are: '"+curbal+"'","Available balance",JOptionPane.INFORMATION_MESSAGE); 221 | 222 | 223 | new Welcome(); 224 | jf.setVisible(false); 225 | } 226 | } 227 | }/// 228 | else 229 | { 230 | JOptionPane.showMessageDialog(this,"Your balance is less to withdraw amount","Warning",JOptionPane.WARNING_MESSAGE); 231 | 232 | t1.setText(""); 233 | } 234 | } 235 | else 236 | { 237 | JOptionPane.showMessageDialog(this,"Your balance is less,You should keep minimum balance 1000 RS","Warning",JOptionPane.WARNING_MESSAGE); 238 | t1.setText(""); 239 | } 240 | } 241 | } 242 | } 243 | else 244 | { 245 | JOptionPane.showMessageDialog(this,"Your can not withdraw per day greater than 25000 RS","Warning",JOptionPane.WARNING_MESSAGE); 246 | 247 | t1.setText(""); 248 | }// 249 | } 250 | else 251 | { 252 | if(actype=="current")//current account checking previous amt on current date and enter amt on current date 253 | { 254 | if((sumbal+givam)<=50000) 255 | { 256 | if(givam<100) 257 | { 258 | JOptionPane.showMessageDialog(this,"You can not withdraw amount less than 100 RS!","Warning",JOptionPane.WARNING_MESSAGE); 259 | 260 | t1.setText(""); 261 | } 262 | else if(givam>10000) 263 | { 264 | JOptionPane.showMessageDialog(this,"You can not withdraw amount greater than 10000 RS at the same time!","Warning",JOptionPane.WARNING_MESSAGE); 265 | 266 | t1.setText(""); 267 | } 268 | else if(givam>100 && (!(givam % 100 ==0))) 269 | { 270 | JOptionPane.showMessageDialog(this,"Withdrawal amount should be multiple of 100","Warning",JOptionPane.WARNING_MESSAGE); 271 | 272 | t1.setText(""); 273 | } 274 | else 275 | { 276 | 277 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' and acctype='"+actype+"'"); 278 | rs=ps.executeQuery(); 279 | if(rs.next()) 280 | { 281 | abal=Float.parseFloat(rs.getString(6)); 282 | 283 | if(abal>1000) 284 | { 285 | if(givam<=(abal-1000)) 286 | { 287 | amt=((abal-1000)-givam); 288 | amtmin=(amt+1000); 289 | stmt=(Statement) con.createStatement(); 290 | stmt.executeUpdate("update accountdetail set balance="+amtmin+" where atmno='"+atno+"'"); 291 | System.out.println("You withdraw rs:"+t1.getText()); 292 | stmt1=(Statement) con.createStatement(); 293 | stmt1.executeUpdate("insert into transaction (atmno,accno,depositamt,withamt,avbalance,tdate)values('"+atno+"','"+acno+"',0,'"+givam+"','"+amtmin+"','"+strdate+"') ");// 294 | int reply=JOptionPane.showConfirmDialog(null,"Your cash withdrawal is in processing take money from machine.Do you have to take receipt?","Cash withdrawl Message",JOptionPane.YES_NO_OPTION); 295 | 296 | if (reply == JOptionPane.YES_OPTION) 297 | { 298 | 299 | 300 | new BalanceEnquiry(atno,acno,pno,actype); 301 | jf.setVisible(false); 302 | } 303 | else if (reply == JOptionPane.NO_OPTION) 304 | { 305 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 306 | rs=ps.executeQuery(); 307 | while(rs.next()) 308 | { 309 | float curbal=rs.getFloat(6); 310 | JOptionPane.showMessageDialog(null,"Your available balance are: '"+curbal+"'","Available balance",JOptionPane.INFORMATION_MESSAGE); 311 | new Welcome(); 312 | jf.setVisible(false); 313 | } 314 | } 315 | }/// 316 | else 317 | { 318 | JOptionPane.showMessageDialog(this,"Your balance is less to withdraw amount","Warning",JOptionPane.WARNING_MESSAGE); 319 | 320 | t1.setText(""); 321 | } 322 | } 323 | else 324 | { 325 | JOptionPane.showMessageDialog(this,"Your balance is less,You should keep minimum balance 1000 RS","Warning",JOptionPane.WARNING_MESSAGE); 326 | 327 | t1.setText(""); 328 | } 329 | } 330 | } 331 | } 332 | else 333 | { 334 | JOptionPane.showMessageDialog(this,"Your can not withdraw per day greater than 50000 RS","Warning",JOptionPane.WARNING_MESSAGE); 335 | 336 | t1.setText("");// 337 | } 338 | } 339 | } 340 | } //if record not found on current date then else 341 | else 342 | { 343 | if(actype=="saving") 344 | { System.out.println(actype); 345 | 346 | if(givam<=25000) 347 | { 348 | if(givam<100) 349 | { 350 | JOptionPane.showMessageDialog(this,"You can not withdraw amount less than 100 RS!","Warning",JOptionPane.WARNING_MESSAGE); 351 | 352 | t1.setText(""); 353 | } 354 | else if(givam>10000) 355 | { 356 | JOptionPane.showMessageDialog(this,"You can not withdraw amount greater than 10000 RS at the same time!","Warning",JOptionPane.WARNING_MESSAGE); 357 | 358 | t1.setText(""); 359 | } 360 | else if(givam>100 && (!(givam % 100 ==0))) 361 | { 362 | JOptionPane.showMessageDialog(this,"Withdrawal amount should be multiple of 100","Warning",JOptionPane.WARNING_MESSAGE); 363 | t1.setText(""); 364 | } 365 | else 366 | { 367 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' and acctype='"+actype+"'"); 368 | rs=ps.executeQuery(); 369 | while(rs.next()) 370 | { 371 | abal=Float.parseFloat(rs.getString(6)); 372 | 373 | if(abal>1000) 374 | { 375 | if(givam<=(abal-1000)) 376 | { 377 | amt=((abal-1000)-givam); 378 | amtmin=(amt+1000); 379 | stmt=(Statement) con.createStatement(); 380 | stmt.executeUpdate("update accountdetail set balance="+amtmin+" where atmno='"+atno+"'"); 381 | System.out.println("You withdraw rs:"+t1.getText()); 382 | stmt1=(Statement) con.createStatement(); 383 | stmt1.executeUpdate("insert into transaction (atmno,accno,depositamt,withamt,avbalance,tdate)values('"+atno+"','"+acno+"',0,'"+givam+"','"+amtmin+"','"+strdate+"') "); 384 | 385 | int reply=JOptionPane.showConfirmDialog(null,"Your cash withdrawal is in processing take money from machine.Do you have to take receipt?","Cash withdrawl Message",JOptionPane.YES_NO_OPTION); 386 | 387 | if (reply == JOptionPane.YES_OPTION)//go to balance diaplay 388 | { 389 | 390 | 391 | new BalanceEnquiry(atno,acno,pno,actype); 392 | jf.setVisible(false); 393 | } 394 | else if (reply == JOptionPane.NO_OPTION)//only display the balance on dialog box 395 | { 396 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 397 | rs=ps.executeQuery(); 398 | while(rs.next()) 399 | { 400 | int curbal=rs.getInt(6); 401 | JOptionPane.showMessageDialog(null,"Your available balance are: '"+curbal+"'","Available balance",JOptionPane.INFORMATION_MESSAGE); 402 | 403 | 404 | new Welcome(); 405 | jf.setVisible(false); 406 | } 407 | } 408 | }/// 409 | else 410 | { 411 | JOptionPane.showMessageDialog(this,"Your balance is less to withdraw amount","Warning",JOptionPane.WARNING_MESSAGE); 412 | 413 | t1.setText(""); 414 | } 415 | } 416 | else 417 | { 418 | JOptionPane.showMessageDialog(this,"Your balance is less,You should keep minimum balance 1000 RS","Warning",JOptionPane.WARNING_MESSAGE); 419 | 420 | t1.setText(""); 421 | } 422 | } 423 | } 424 | } 425 | else 426 | { 427 | JOptionPane.showMessageDialog(this,"Your can not withdraw per day greater than 25000 RS","Warning",JOptionPane.WARNING_MESSAGE); 428 | t1.setText(""); 429 | } 430 | }// 431 | else if(actype=="current")//current acc type if record are not found on current date 432 | { 433 | if(givam<=50000) 434 | { 435 | if(givam<100) 436 | { 437 | JOptionPane.showMessageDialog(this,"You can not withdraw amount less than 100 RS!","Warning",JOptionPane.WARNING_MESSAGE); 438 | 439 | t1.setText(""); 440 | } 441 | else if(givam>10000) 442 | { 443 | JOptionPane.showMessageDialog(this,"You can not withdraw amount greater than 10000 RS at the same time!","Warning",JOptionPane.WARNING_MESSAGE); 444 | 445 | t1.setText(""); 446 | } 447 | else if(givam>100 && (!(givam % 100 ==0))) 448 | { 449 | JOptionPane.showMessageDialog(this,"Wihdrawal amount should be multiple of 100","Warning",JOptionPane.WARNING_MESSAGE); 450 | 451 | t1.setText(""); 452 | } 453 | else 454 | { 455 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"' and pinno='"+pno+"' and acctype='"+actype+"'"); 456 | rs=ps.executeQuery(); 457 | while(rs.next()) 458 | { 459 | abal=Float.parseFloat(rs.getString(6)); 460 | 461 | if(abal>1000) 462 | { 463 | if(givam<=(abal-1000)) 464 | { 465 | amt=((abal-1000)-givam); 466 | amtmin=(amt+1000); 467 | stmt=(Statement) con.createStatement(); 468 | stmt.executeUpdate("update accountdetail set balance="+amtmin+" where atmno='"+atno+"'"); 469 | System.out.println("You withdraw rs:"+t1.getText()); 470 | stmt1=(Statement) con.createStatement(); 471 | stmt1.executeUpdate("insert into transaction (atmno,accno,depositamt,withamt,avbalance,tdate)values('"+atno+"','"+acno+"',0,'"+givam+"','"+amtmin+"','"+strdate+"') "); 472 | 473 | int reply=JOptionPane.showConfirmDialog(null,"Your cash withdrawal is in processing take money from machine.Do you have to take receipt?","Cash withdrawl Message",JOptionPane.YES_NO_OPTION); 474 | 475 | if (reply == JOptionPane.YES_OPTION)//go to balance diaplay 476 | { 477 | 478 | 479 | new BalanceEnquiry(atno,acno,pno,actype); 480 | jf.setVisible(false); 481 | } 482 | else if (reply == JOptionPane.NO_OPTION)//only display the balance on dialog box 483 | { 484 | ps=(PreparedStatement) con.prepareStatement("select * from accountdetail where atmno='"+atno+"' and accno='"+acno+"'"); 485 | rs=ps.executeQuery(); 486 | while(rs.next()) 487 | { 488 | int curbal=rs.getInt(6); 489 | JOptionPane.showMessageDialog(null,"Your available balance are: '"+curbal+"'","Available balance",JOptionPane.INFORMATION_MESSAGE); 490 | 491 | 492 | new Welcome(); 493 | jf.setVisible(false); 494 | } 495 | } 496 | }/// 497 | else 498 | { 499 | JOptionPane.showMessageDialog(this,"Your balance is less to withdraw amount","Warning",JOptionPane.WARNING_MESSAGE); 500 | 501 | t1.setText(""); 502 | } 503 | } 504 | else 505 | { 506 | JOptionPane.showMessageDialog(this,"Your balance is less,You should keep minimum balance 1000 RS","Warning",JOptionPane.WARNING_MESSAGE); 507 | 508 | t1.setText(""); 509 | } 510 | } 511 | } 512 | } 513 | //}// 514 | else 515 | { 516 | JOptionPane.showMessageDialog(this,"Your can not withdraw per day greater than 50000 RS","Warning",JOptionPane.WARNING_MESSAGE); 517 | 518 | t1.setText(""); 519 | } 520 | } 521 | } 522 | con.close(); 523 | } 524 | catch(SQLException se) 525 | { 526 | System.out.println(se); 527 | se.printStackTrace(); 528 | } 529 | catch(Exception e) 530 | { 531 | System.out.println(e); 532 | e.printStackTrace( ); 533 | } 534 | 535 | } 536 | else if(ae.getSource()==b2) 537 | { 538 | 539 | t1.setText(""); 540 | } 541 | else if(ae.getSource()==b3) 542 | { 543 | 544 | JOptionPane.showMessageDialog(this,"Your last transaction cancel."); 545 | 546 | new Welcome(); 547 | jf.setVisible(false); 548 | } 549 | } 550 | public static void main(String args[]) 551 | { 552 | //new CashWithdrawal(1000,10001,1111,"saving"); 553 | 554 | } 555 | 556 | 557 | 558 | } 559 | --------------------------------------------------------------------------------