Anda di halaman 1dari 15

BANK PROJECT Main Form

[http://2.bp.blogspot.com/-XRdVJ9ODXk/UjKaWbL1cDI/AAAAAAAAAMk/4llI4e7jByw/s1600/mainform .gif]

package bank_dbc;

import java.awt.*; import java.awt.event.*; class Abc extends Frame implements ActionListener { Button bt1,bt2,bt3,bt4,bt5,bt6,bt7; public Abc(String x) { super(x); bt1=new Button("New account"); bt1.setBounds(150,50,200,50); add(bt1); bt1.addActionListener(this); bt2=new Button("Deposit"); bt2.setBounds(150,130,200,50); add(bt2); bt2.addActionListener(this); bt3=new Button("Withdrawl"); bt3.setBounds(150,210,200,50); add(bt3); bt3.addActionListener(this); bt4=new Button("Balance"); bt4.setBounds(150,290,200,50); add(bt4); bt4.addActionListener(this); bt5=new Button("Transfer"); bt5.setBounds(150,380,200,50); add(bt5); bt5.addActionListener(this); bt6=new Button("Mini Statement"); bt6.setBounds(150,460,200,50); add(bt6); bt6.addActionListener(this); bt7=new Button("exit"); bt7.setBounds(150,540,200,50); add(bt7); bt7.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==bt1) { final Abc1 ob = new Abc1("New Account"); ob.setLayout(null);

ob.setBounds(10, 10, 400, 500); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); } }); } else if (e.getSource() == bt2) { final Abc2 ob = new Abc2("Deposit"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); } }); } else if (e.getSource() == bt3) { final Abc3 ob = new Abc3("Withdrawl"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); } }); } else if (e.getSource() == bt4) { final Abc4 ob = new Abc4("Balance"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); }

}); } else if (e.getSource() == bt5) { final Abc5 ob = new Abc5("Transfer"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); } }); } else if (e.getSource() == bt6) { final Abc6 ob = new Abc6("Mini Statement"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { ob.setVisible(false); } }); } } } public class Main {

public static void main(String[] args) { Abc ob=new Abc("Bank Full Project"); ob.setLayout(null); ob.setBounds(10, 10, 500, 700); ob.setVisible(true); ob.setBackground(Color.magenta); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } });

Open new acount


package bank_dbc; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class Abc1 extends Frame implements ActionListener { Label l1, l2, l3, l4; TextField t1, t2, t3; TextArea t4; Button bt; public Abc1(String x) { super(x); l1 = new Label("Name"); l1.setBounds(50, 50, 100, 20); add(l1);
January 2nd, 2014

November 29th, 2013

t1 = new TextField(0); t1.setBounds(150, 50, 100, 20); add(t1); l2 = new Label("Password"); l2.setBounds(50, 100, 100, 20); add(l2); t2 = new TextField(0); t2.setEchoChar('*'); t2.setBounds(150, 100, 100, 20); add(t2); l3 = new Label("Phone"); l3.setBounds(50, 150, 100, 20); add(l3); t3 = new TextField(0); t3.setBounds(150, 150, 100, 20); add(t3); l4 = new search Label("Address");

November 12th, 2013

October 25th, 2013

October 16th, 2013

October 15th, 2013

October 14th, 2013

October 9th, 2013

October 9th, 2013

October 8th, 2013

October 4th, 2013 JAVA CORE Sidebar

core java Practical October 1st, 2013


September 20th, 2013

l4.setBounds(50, 200, 100, 20); add(l4); knowl t4 = new TextArea(0,0); t4.setBounds(150, 200, 100, 100); add(t4);

September 20th, 2013

September 19th, 2013

September 13th, 2013

bt = new Button(" Open account "); bt.setBounds(80, 350, 150, 30); add(bt); bt.addActionListener((ActionListener) this); }

September 13th, 2013

September 13th, 2013

September 12th, 2013

September 9th, 2013

JEditorPane

September 6th, 2013

public void actionPerformed(ActionEvent e) { if (e.getSource() == bt) { try { Connection cn; Statement st; Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/vimal", "root", "jaysun"); st = cn.createStatement(); String query = "insert into customer (name,password,phone,address) values ('"+t1.getText() +"','"+t2.getText()+"',"+t3.getText()+",'"+t4.getText()+"')"; int re = st.executeUpdate(query); if (re > 0) { String acno=""; String name=""; query="select * from customer"; ResultSet rs=st.executeQuery(query); while(rs.next()) { acno=rs.getString(1); name=rs.getString(2); } JOptionPane.showMessageDialog(null, "Welcome "+name +" in my bank ! Your acount number is "+acno);

September 6th, 2013

September 5th, 2013

September 5th, 2013

} cn.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error " + ex); corejavapoint. Dynamic View s template. Pow ered by Blogger. Send feedback } }

} } public class account_no { public static void main(String[] args) { Abc1 ob = new Abc1("Accountnumber"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } }

Diposit
package bank_dbc; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class Abc2 extends Frame implements ActionListener { Label l1, l2; TextField t1, t2; Button bt; public Abc2(String x) { super(x); l1 = new Label("Account_No"); l1.setBounds(50, 50, 100, 20); add(l1); t1 = new TextField(0); t1.setBounds(150, 50, 100, 20); add(t1); l2 = new Label("Amount");

l2.setBounds(50, 100, 100, 20); add(l2); t2 = new TextField(0); t2.setBounds(150, 100, 100, 20); add(t2); bt = new Button("Deposit"); bt.setBounds(80, 150, 100, 30); add(bt); bt.addActionListener((ActionListener) this); } public void actionPerformed(ActionEvent e) { if (e.getSource() == bt) { try { Connection cn; Statement st; Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/vimal", "root", "jaysun"); st = cn.createStatement(); java.util.Date dt=new java.util.Date(); String d=dt.getDate()+"/"+(dt.getMonth()+1)+"/"+ (dt.getYear()+1900); String query = "insert into transaction (acno,tdate,amount,dip_Or_with) values ("+t1.getText() +",'"+d+"',"+t2.getText()+",0)"; int re = st.executeUpdate(query); if (re > 0) { String trid=""; query="select * from transaction"; ResultSet rs=st.executeQuery(query); while(rs.next()) { trid=rs.getString(1); } JOptionPane.showMessageDialog(null, "Diposit Successfull ! Your Transaction Id is "+trid); } cn.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error " + ex); } } }

} public class Deposit { public static void main(String[] args) { Abc2 ob = new Abc2("Deposit"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } }

withdrawl
package bank_dbc; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class Abc3 extends Frame implements ActionListener { Label l1, l2, l3; TextField t1, t2, t3; Button bt; public Abc3(String x) { super(x); l1 = new Label("Account_No"); l1.setBounds(50, 50, 100, 20); add(l1); t1 = new TextField(0); t1.setBounds(150, 50, 100, 20); add(t1); l2 = new Label("Password"); l2.setBounds(50, 100, 100, 20); add(l2);

t2 = new TextField(0); t2.setEchoChar('*'); t2.setBounds(150, 100, 100, 20); add(t2); l3 = new Label("Amount"); l3.setBounds(50, 150, 100, 20); add(l3); t3 = new TextField(0); t3.setBounds(150, 150, 100, 20); add(t3); bt = new Button("Withdrawl"); bt.setBounds(80, 200, 100, 30); add(bt); bt.addActionListener((ActionListener) this); } public void actionPerformed(ActionEvent e) { if (e.getSource() == bt) { try { Connection cn; Statement st; Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/vimal", "root", "jaysun"); st = cn.createStatement(); String query = "select * from customer where ( acno=" + t1.getText() + " and password='" + t2.getText() + "' )"; ResultSet rs = st.executeQuery(query); if (rs.next()) { java.util.Date dt = new java.util.Date(); String d = dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + (dt.getYear() + 1900); query = "insert into transaction (acno,tdate,amount,dip_Or_with) values (" + t1.getText() + ",'" + d + "'," + t3.getText() + ",1)"; int re = st.executeUpdate(query); if (re >= 0) { JOptionPane.showMessageDialog(null, "Withdrawl Successfull ! Please take cash count it. "); } } else { JOptionPane.showMessageDialog(null, "Acount number

and password is not match "); } cn.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error " + ex); } } } } public class Withdrawl { public static void main(String[] args) { Abc3 ob = new Abc3("Withdrawl"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } }

Balance
package bank_dbc; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class Abc4 extends Frame implements ActionListener { Label l1, l2, l3; TextField t1, t2, t3; Button bt; public Abc4(String x) { super(x); l1 = new Label("Account_No"); l1.setBounds(50, 50, 100, 20); add(l1);

t1 = new TextField(0); t1.setBounds(150, 50, 100, 20); add(t1); l2 = new Label("Password"); l2.setBounds(50, 100, 100, 20); add(l2); t2 = new TextField(0); t2.setEchoChar('*'); t2.setBounds(150, 100, 100, 20); add(t2); bt = new Button("Balance"); bt.setBounds(80, 150, 100, 20); add(bt); bt.addActionListener((ActionListener) this); l3 = new Label("Balance"); l3.setBounds(50, 200, 100, 20); add(l3); t3 = new TextField(0); t3.setBounds(150, 200, 100, 20); add(t3);

} public void actionPerformed(ActionEvent e) { if (e.getSource() == bt) { try { int tdip = 0, twith = 0, bal = 0; Connection cn; Statement st; Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/vimal", "root", "jaysun"); st = cn.createStatement(); String query = "select * from customer where ( acno=" + t1.getText() + " and password='" + t2.getText() + "' )"; ResultSet rs = st.executeQuery(query); if (rs.next()) { query = "select sum(Amount) from transaction where ( acno=" + t1.getText() + " and dip_Or_With=0)"; rs = st.executeQuery(query); if (rs.next()) {

try { tdip = Integer.parseInt(rs.getString(1)); } catch (Exception ex) { } } query = "select sum(Amount) from transaction where ( acno=" + t1.getText() + " and dip_Or_With=1)"; rs = st.executeQuery(query); if (rs.next()) { try { twith = Integer.parseInt(rs.getString(1)); } catch (Exception ex) { } } bal = tdip - twith; t3.setText("" + bal); } else { JOptionPane.showMessageDialog(null, "Acount number and password is not match "); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error " + ex); } } } } public class Balance { public static void main(String[] args) { Abc4 ob = new Abc4("Balance"); ob.setLayout(null); ob.setBounds(10, 10, 400, 400); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } }

Mini Statement
package bank_dbc; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class Abc6 extends Frame implements ActionListener { Label l1, l2; TextField t1, t2; Button bt; TextArea t3; public Abc6(String x) { super(x); l1 = new Label("Account_No"); l1.setBounds(50, 50, 100, 20); add(l1); t1 = new TextField(0); t1.setBounds(150, 50, 100, 20); add(t1); l2 = new Label("Password"); l2.setBounds(50, 100, 100, 20); add(l2); t2 = new TextField(0); t2.setBounds(150, 100, 100, 20); add(t2); bt = new Button("Get Statement"); bt.setBounds(80, 150, 100, 30); add(bt); bt.addActionListener((ActionListener) this); t3 = new TextArea(0, 0); t3.setEditable(false); t3.setBounds(20, 200, 450, 300); add(t3); } public void actionPerformed(ActionEvent e) {

public class Mini_statement { public static void main(String[] args) { Abc6 ob = new Abc6("Mini Statement"); ob.setLayout(null); ob.setBounds(10, 10, 500, 600); ob.setBackground(Color.red); ob.setVisible(true); ob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } } Posted 12th September 2013 by Jay Prakash View comments

Anda mungkin juga menyukai