├── BM_System ├── E_Statement_2021-07-23T09_59_37.603298300.pdf ├── libs │ ├── barcodes-7.1.9.jar │ ├── font-asian-7.1.9.jar │ ├── forms-7.1.9.jar │ ├── html2pdf-2.1.6.jar │ ├── hyph-7.1.9.jar │ ├── io-7.1.9.jar │ ├── kernel-7.1.9.jar │ ├── layout-7.1.9.jar │ ├── mysql-connector-java-8.0.22.jar │ ├── pdfa-7.1.9.jar │ ├── pdftest-7.1.9.jar │ ├── sign-7.1.9.jar │ ├── slf4j-api-1.7.2.jar │ ├── slf4j-simple-1.7.2.jar │ ├── styled-xml-parser-7.1.9.jar │ └── svg-7.1.9.jar └── src │ └── def_pkg │ ├── Accountant.java │ ├── BM_System.java │ ├── Bank_Account.java │ ├── Client.java │ ├── DB_Handler.java │ ├── GUI.java │ ├── Login_Account.java │ ├── Manager.java │ ├── Rough.txt │ ├── Transaction_History.java │ ├── anchor.png │ └── ddot.png ├── MySQL Script.sql ├── README.md └── Screenshots ├── 1-Login.PNG ├── 2-User_Screen.PNG ├── 3-E-Statement.PNG ├── 4-Manager_Screen.PNG ├── 5-Create Account.PNG ├── 6-Search Account.PNG ├── 7-Accountant_Screen.PNG ├── 8_Cheque_Deposit.PNG └── 9-Sample_E_Statement.PNG /BM_System/E_Statement_2021-07-23T09_59_37.603298300.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/E_Statement_2021-07-23T09_59_37.603298300.pdf -------------------------------------------------------------------------------- /BM_System/libs/barcodes-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/barcodes-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/font-asian-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/font-asian-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/forms-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/forms-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/html2pdf-2.1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/html2pdf-2.1.6.jar -------------------------------------------------------------------------------- /BM_System/libs/hyph-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/hyph-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/io-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/io-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/kernel-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/kernel-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/layout-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/layout-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/mysql-connector-java-8.0.22.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/mysql-connector-java-8.0.22.jar -------------------------------------------------------------------------------- /BM_System/libs/pdfa-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/pdfa-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/pdftest-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/pdftest-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/sign-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/sign-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/slf4j-api-1.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/slf4j-api-1.7.2.jar -------------------------------------------------------------------------------- /BM_System/libs/slf4j-simple-1.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/slf4j-simple-1.7.2.jar -------------------------------------------------------------------------------- /BM_System/libs/styled-xml-parser-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/styled-xml-parser-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/libs/svg-7.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/libs/svg-7.1.9.jar -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Accountant.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import java.util.List; 4 | 5 | public class Accountant { 6 | 7 | public String name; 8 | 9 | public Accountant( ) { 10 | this.name = ""; 11 | } 12 | 13 | public Accountant( String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return this.name; 19 | } 20 | 21 | // Search Account function 22 | Bank_Account searchAccount1(String accountNum, String CNIC) { 23 | DB_Handler db = new DB_Handler(); 24 | Bank_Account account = db.searchAccount1(accountNum, CNIC); 25 | db = null; 26 | System.out.println("Account infoACC: "+account.getType() ); 27 | return account; 28 | } 29 | 30 | // Search Client function 31 | public Client searchClient1(String accountNum, String CNIC) { 32 | DB_Handler db = new DB_Handler(); 33 | Client client = db.searchClient1( accountNum, CNIC ); 34 | db = null; 35 | return client; 36 | } 37 | 38 | public int chequeDeposit(String accNum, String chequeNum, int amount ) { 39 | DB_Handler db = new DB_Handler(); 40 | return db.chequeDeposit(accNum, chequeNum, amount); 41 | } 42 | 43 | public List getTransactions( String acc_num, String From, String To) { 44 | DB_Handler db = new DB_Handler(); 45 | List list = db.getTransactions( acc_num, From, To); 46 | return list; 47 | } 48 | 49 | // end of class 50 | } 51 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/BM_System.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import javax.swing.*; 4 | 5 | public class BM_System { 6 | 7 | public static void main(String[] args) { 8 | JFrame frame=new JFrame("Bank Managment System"); 9 | frame.setIconImage( new ImageIcon(System.getProperty("user.dir") + "\\src\\def_pkg\\ddot.png").getImage() ); 10 | 11 | GUI interf = new GUI(); 12 | Login_Account user = new Login_Account(); 13 | interf.openSignInForm(frame, user); 14 | frame.setSize(800,500); 15 | frame.setVisible(true); 16 | frame.setDefaultCloseOperation(frame.DISPOSE_ON_CLOSE); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Bank_Account.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | // Bank_Account Class 4 | public class Bank_Account { 5 | private String acc_num; 6 | private String client_id; 7 | private String login_id; 8 | private String type; 9 | private String balance; 10 | private String status; 11 | private String opening_date; 12 | private String closing_date; 13 | private String card_num; 14 | 15 | // default constructor 16 | Bank_Account() { 17 | acc_num = ""; 18 | client_id = ""; 19 | login_id = ""; 20 | type = ""; 21 | balance = ""; 22 | status = ""; 23 | opening_date=""; 24 | closing_date=""; 25 | card_num = ""; 26 | } 27 | 28 | // parameterized constructor 29 | Bank_Account(String acc_num, String client_id, String login_id, String type, 30 | String balance, String status, String opening_date, String closing_date, String card_num) { 31 | this.acc_num = acc_num; 32 | this.client_id = client_id; 33 | this.login_id = login_id; 34 | this.type = type; 35 | this.balance = balance; 36 | this.status = status; 37 | this.opening_date= opening_date; 38 | this.closing_date= closing_date; 39 | this.card_num = card_num; 40 | } 41 | 42 | // updates the object member variables 43 | public void addInfo(String acc_num, String client_id, String login_id, String type, 44 | String balance, String status, String opening_date, String closing_date, String card_num) { 45 | this.acc_num = acc_num; 46 | this.client_id = client_id; 47 | this.login_id = login_id; 48 | this.type = type; 49 | this.balance = balance; 50 | this.status = status; 51 | this.opening_date= opening_date; 52 | this.closing_date= closing_date; 53 | this.card_num = card_num; 54 | } 55 | 56 | // setter function for type 57 | public void setType(String type) { 58 | this.type = type; 59 | } 60 | 61 | // setter function for balance 62 | public void setBalance(String balance) { 63 | this.balance = balance; 64 | } 65 | 66 | // setter function for balance 67 | public void setStatus(String status) { 68 | this.status = status; 69 | } 70 | 71 | // setter function for closing date 72 | public void setClosingDate(String closing_date) { 73 | this.closing_date = closing_date; 74 | } 75 | 76 | // getter function for account number 77 | public String getAccountNum() { 78 | return this.acc_num; 79 | } 80 | 81 | // getter function for client id 82 | public String getClientId() { 83 | return this.client_id; 84 | } 85 | 86 | public String getLoginId() { 87 | return this.login_id; 88 | } 89 | 90 | // getter function for type 91 | public String getType() { 92 | return this.type; 93 | } 94 | 95 | // getter function for balance 96 | public String getBalance() { 97 | return this.balance; 98 | } 99 | 100 | // getter function for status 101 | public String getStatus() { 102 | return this.status; 103 | } 104 | 105 | // getter function for opening date 106 | public String getOpeningDate() { 107 | return this.opening_date; 108 | } 109 | 110 | // getter function for closing date 111 | public String getClosingDate() { 112 | return this.closing_date; 113 | } 114 | 115 | public String getCardNum() { 116 | return this.card_num; 117 | } 118 | 119 | public int addAmount(int b) { 120 | DB_Handler db = new DB_Handler(); 121 | int i = db.updateBalance( this, b, 1 ); 122 | if( i == 1 ) { 123 | b += Integer.valueOf( this.balance ); 124 | balance = String.valueOf(b); 125 | } 126 | return i; 127 | } 128 | 129 | public int removeAmount(int b) { 130 | if( b > Integer.valueOf(this.balance) ) { 131 | return 2; 132 | } 133 | DB_Handler db = new DB_Handler(); 134 | b *= -1; 135 | int i = db.updateBalance( this, b, 2 ); 136 | if( i == 1 ) { 137 | b += Integer.valueOf( this.balance ); 138 | balance = String.valueOf(b); 139 | } 140 | return i; 141 | } 142 | 143 | public void updateBalance() { 144 | DB_Handler db = new DB_Handler(); 145 | String b = db.getBalance(this.acc_num); 146 | if( b.compareTo("") == 0 ) { 147 | } 148 | else { 149 | this.balance = b; 150 | } 151 | } 152 | 153 | 154 | public void finalize() { 155 | System.out.println("Bank Account Destructor"); 156 | } 157 | 158 | // end of class 159 | } 160 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Client.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import java.util.List; 4 | 5 | public class Client { 6 | private String client_id; 7 | private String f_name; 8 | private String l_name; 9 | private String father_name; 10 | private String mother_name; 11 | private String CNIC; 12 | private String DOB; 13 | private String phone; 14 | private String email; 15 | private String address; 16 | 17 | // Default Constructor 18 | public Client() { 19 | client_id = ""; 20 | f_name = ""; 21 | l_name = ""; 22 | father_name = ""; 23 | mother_name = ""; 24 | CNIC = ""; 25 | DOB = ""; 26 | phone = ""; 27 | email = ""; 28 | address = ""; 29 | } 30 | 31 | // Parameterized Constructor 32 | public Client(String f_name, String l_name, String father_name, String mother_name, String cnic, String dob, String phone, String email, String address) { 33 | client_id = ""; 34 | this.f_name = f_name; 35 | this.l_name = l_name; 36 | this.father_name = father_name; 37 | this.mother_name = mother_name; 38 | this.CNIC = cnic; 39 | this.DOB = dob; 40 | this.phone = phone; 41 | this.email = email; 42 | this.address = address; 43 | } 44 | 45 | // Parameterized Constructor 46 | public Client(String id, String pf_name, String pl_name, String pfather_name, String pmother_name, String pcnic, String pdob, String pphone, String pemail, String paddress) { 47 | this.client_id = id; 48 | this.f_name = pf_name; 49 | this.l_name = pl_name; 50 | this.father_name = pfather_name; 51 | this.mother_name = pmother_name; 52 | this.CNIC = pcnic; 53 | this.DOB = pdob; 54 | this.phone = pphone; 55 | this.email = pemail; 56 | this.address = paddress; 57 | } 58 | 59 | void showClientInfo() { 60 | System.out.println("First Name: "+f_name); 61 | System.out.println("Last Name: "+l_name); 62 | System.out.println("Father Name: "+father_name); 63 | System.out.println("Mother Name: "+mother_name); 64 | System.out.println("CNIC Name: "+CNIC); 65 | System.out.println("DOB Name: "+DOB); 66 | System.out.println("Phone Name: "+phone); 67 | System.out.println("Email Name: "+email); 68 | System.out.println("Address Name: "+address); 69 | } 70 | 71 | public String getClientID() { 72 | return this.client_id; 73 | } 74 | 75 | public String getFName() { 76 | return f_name; 77 | } 78 | 79 | public String getLName() { 80 | return l_name; 81 | } 82 | 83 | public String getFatherName() { 84 | return father_name; 85 | } 86 | 87 | public String getMotherName() { 88 | return mother_name; 89 | } 90 | 91 | public String getCNIC() { 92 | return CNIC; 93 | } 94 | 95 | public String getDOB() { 96 | return DOB; 97 | } 98 | 99 | public String getPhone() { 100 | return phone; 101 | } 102 | 103 | public String getEmail() { 104 | return email; 105 | } 106 | 107 | public String getAddress() { 108 | return address; 109 | } 110 | 111 | public int transferMoney( String recv_acc, int amount) { 112 | DB_Handler db = new DB_Handler(); 113 | return db.TransferMoney(this, recv_acc, amount); 114 | } 115 | 116 | String do_cardless_cash_withdrawal(Bank_Account account, String amount, String pin) 117 | { 118 | 119 | DB_Handler db = new DB_Handler(); 120 | 121 | if (db.is_card_active(Integer.parseInt(account.getCardNum()))) 122 | { 123 | int curr_balance = Integer.parseInt(account.getBalance()); 124 | int requested_amount = Integer.parseInt(amount); 125 | if (curr_balance >= requested_amount) 126 | { 127 | String temp_num = db.add_cardless_entry(Integer.parseInt(account.getAccountNum()), Integer.parseInt(account.getCardNum()), requested_amount, pin ); 128 | if (temp_num.compareTo("") != 0) 129 | { 130 | db.reduce_balance(curr_balance-requested_amount, Integer.parseInt(account.getAccountNum())); 131 | return temp_num; //0 means successfull operation 132 | } 133 | else 134 | return "c"; //-3 means could not be successfull 135 | } 136 | else 137 | { 138 | return "b"; //-2 means that the available balance was lower 139 | } 140 | } 141 | else 142 | { 143 | return "a"; //-1 means card was blocked 144 | } 145 | } 146 | 147 | int change_password(String curr_pass, String new_pass_1, String new_pass_2, String acc_num) 148 | { 149 | DB_Handler db = new DB_Handler(); 150 | int acc_no = Integer.parseInt(acc_num); 151 | int login_id = db.getLoginID(acc_no); 152 | if (login_id == -1) 153 | { 154 | return -1; //could not find portal 155 | } 156 | else if ( !curr_pass.equals(db.get_password(login_id))) 157 | { 158 | return -2; 159 | } 160 | else if (new_pass_1.equals(new_pass_2)) 161 | { 162 | db.change_password(new_pass_1, login_id); 163 | return 0; 164 | } 165 | else 166 | { 167 | return -3; 168 | } 169 | } 170 | 171 | public List getTransactions( String acc_num, String From, String To) { 172 | DB_Handler db = new DB_Handler(); 173 | List list = db.getTransactions( acc_num, From, To); 174 | return list; 175 | } 176 | 177 | 178 | 179 | // end of class 180 | } 181 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/DB_Handler.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import java.io.FileOutputStream; 4 | import java.sql.Connection; 5 | import java.sql.DriverManager; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.sql.Statement; 9 | import java.util.*; 10 | 11 | import com.itextpdf.html2pdf.HtmlConverter; 12 | 13 | public class DB_Handler { 14 | 15 | private String url = "jdbc:mysql://localhost:3307/bank_schema"; 16 | private String username = "root"; 17 | private String password = "sunshine"; 18 | private Connection conn; 19 | 20 | 21 | 22 | public DB_Handler() { 23 | try { 24 | conn = DriverManager.getConnection(url, username, password); 25 | System.out.println("Connection established successfully!"); 26 | } 27 | catch (SQLException e) { 28 | throw new IllegalStateException("Unable to connect to the database. " + e.getMessage()); 29 | } 30 | } 31 | 32 | 33 | 34 | public Login_Account signIn( String username, String password ) { 35 | Login_Account user = new Login_Account(); 36 | try { 37 | // finding the account in database 38 | String laQuery = "Select * From bank_schema.login_account Where username = \""+username+"\" and " 39 | + "password = \""+password+"\""; 40 | System.out.println(laQuery); 41 | Statement laSt = conn.createStatement(); 42 | ResultSet laRs = laSt.executeQuery(laQuery); 43 | if( laRs.next() ) { 44 | // removing old instance of bank account and adding new instance with information 45 | user = new Login_Account( laRs.getString("login_id"), laRs.getString("username"), "", laRs.getString("type") ); 46 | } 47 | } 48 | catch (SQLException e) { 49 | System.out.println("Something went wrong while checking if account exists"); 50 | } 51 | return user; 52 | } 53 | 54 | 55 | 56 | public Client getClient( String login_id ) { 57 | Client client = new Client(); 58 | try { 59 | // finding the account in database 60 | String cQuery = "Select * From bank_schema.client Where client_id = (select client_id from bank_schema.bank_account where " 61 | + "login_id = "+login_id+")"; 62 | System.out.println(cQuery); 63 | Statement cSt = conn.createStatement(); 64 | ResultSet cRs = cSt.executeQuery(cQuery); 65 | if( cRs.next() ) { 66 | // removing old instance of bank account and adding new instance with information 67 | client = new Client( cRs.getString("client_id"), cRs.getString("f_name"), cRs.getString("l_name"), cRs.getString("father_name"), cRs.getString("mother_name"), cRs.getString("CNIC"), cRs.getString("DOB"), cRs.getString("phone"), cRs.getString("email"), cRs.getString("address") ); 68 | } 69 | } 70 | catch (SQLException e) { 71 | System.out.println("Something went wrong while checking if account exists"); 72 | } 73 | return client; 74 | } 75 | 76 | 77 | 78 | public Bank_Account getAccount( String login_id ) { 79 | Bank_Account account = new Bank_Account(); 80 | try { 81 | // finding the account in database 82 | String aQuery = "Select * from bank_schema.bank_account where login_id = "+login_id; 83 | System.out.println(aQuery); 84 | Statement aSt = conn.createStatement(); 85 | ResultSet aRs = aSt.executeQuery(aQuery); 86 | if( aRs.next() ) { 87 | // removing old instance of bank account and adding new instance with information 88 | account = new Bank_Account( aRs.getString("acc_num"), aRs.getString("client_id"), aRs.getString("login_id"), aRs.getString("type"), aRs.getString("balance"), aRs.getString("status"), aRs.getString("opening_date"), aRs.getString("closing_date"), aRs.getString("card_num") ); 89 | } 90 | } 91 | catch (SQLException e) { 92 | System.out.println("Something went wrong while checking if account exists"); 93 | } 94 | return account; 95 | } 96 | 97 | 98 | 99 | public boolean is_card_active(int card_num) 100 | { 101 | try 102 | { 103 | String uaQuery = "Select * From bank_schema.card Where card_num = "+ card_num; 104 | System.out.println(uaQuery); 105 | Statement uaSt = conn.createStatement(); 106 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 107 | if( uaRs.next() ) 108 | { 109 | String card_status = uaRs.getString("status"); 110 | if (card_status.compareTo("A") == 0 || card_status.compareTo("a")==0) 111 | { 112 | return true; 113 | } 114 | else 115 | { 116 | System.out.println("The card with card_num:" + card_num + " is blocked as status is neither A nor a"); 117 | return false; 118 | } 119 | } 120 | else 121 | return false; 122 | } 123 | catch (SQLException e) 124 | { 125 | System.out.println("Something went wrong while verifying cnic"); 126 | } 127 | return false; 128 | } 129 | 130 | 131 | 132 | public String add_cardless_entry(int acc_num, int card_num, int amount, String temp_pin) 133 | { 134 | Random rand = new Random(); 135 | String temp_OTC = ( String.valueOf( (rand.nextInt(9999)+1) ) + String.valueOf( (rand.nextInt(9999)+1) ) + String.valueOf( (rand.nextInt(9999)+1) ) ); 136 | try 137 | { 138 | String uaQuery = "Insert into bank_schema.cardless_withdrawl values (NULL, " +card_num +", " +amount +", \"" + temp_OTC + "\", \"" +temp_pin +"\", \"p\", CURDATE(), CURRENT_TIME() )"; 139 | System.out.println(uaQuery); 140 | Statement uaSt = conn.createStatement(); 141 | uaSt.executeUpdate(uaQuery); 142 | } 143 | catch (SQLException e) 144 | { 145 | System.out.println("Something went wrong while adding entry to cardless table"); 146 | } 147 | 148 | try 149 | { 150 | String uaQuery = "Select * from bank_schema.cardless_withdrawl where card_no = " + card_num + " and amount = " + amount + " and temp_pin = \"" + temp_pin + "\""; 151 | System.out.println(uaQuery); 152 | Statement uaSt = conn.createStatement(); 153 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 154 | if (uaRs.next()) 155 | { 156 | int temp_serial = uaRs.getInt("serial_no"); 157 | if (temp_serial != 0) 158 | return temp_OTC; 159 | else 160 | return ""; 161 | } 162 | } 163 | catch (SQLException e) 164 | { 165 | System.out.println("Something went wrong while retrieving OTP from database"); 166 | } 167 | return ""; 168 | } 169 | 170 | 171 | 172 | public void reduce_balance(int amount, int acc_num) 173 | { 174 | try 175 | { 176 | String uaQuery = "Update bank_schema.bank_account set balance = " + amount + " where acc_num = " + acc_num; 177 | System.out.println(uaQuery); 178 | Statement uaSt = conn.createStatement(); 179 | uaSt.executeUpdate(uaQuery); 180 | } 181 | catch (SQLException e) 182 | { 183 | System.out.println("Something went wrong while verifying cnic"); 184 | } 185 | } 186 | 187 | 188 | 189 | public int get_client_id(int acc_num) 190 | { 191 | try 192 | { 193 | String uaQuery = "Select client_id From bank_schema.bank_account Where acc_num = "+ acc_num; 194 | System.out.println(uaQuery); 195 | Statement uaSt = conn.createStatement(); 196 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 197 | if( uaRs.next() ) 198 | { 199 | return uaRs.getInt("client_id"); 200 | } 201 | else 202 | return -1; 203 | } 204 | catch (SQLException e) { 205 | System.out.println("Something went wrong while getting client_id"); 206 | } 207 | return -1; 208 | } 209 | 210 | 211 | 212 | public int get_account_status(int acc_num) 213 | { 214 | try { 215 | // Check if client already exists 216 | String uaQuery = "Select * From bank_schema.bank_account Where acc_num = " + acc_num; 217 | System.out.println(uaQuery); 218 | Statement uaSt = conn.createStatement(); 219 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 220 | if( uaRs.next() ) { 221 | return uaRs.getInt("status"); 222 | } 223 | else 224 | return -1; 225 | } 226 | catch (SQLException e) { 227 | System.out.println("Something went wrong while getting account_type"); 228 | } 229 | return -1; 230 | } 231 | 232 | 233 | 234 | public String get_cnic(int client_id) 235 | { 236 | try 237 | { 238 | String uaQuery = "Select * From bank_schema.client Where client_id = "+ client_id; 239 | System.out.println(uaQuery); 240 | Statement uaSt = conn.createStatement(); 241 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 242 | if( uaRs.next() ) 243 | { 244 | return uaRs.getString("CNIC"); 245 | } 246 | else 247 | return ""; 248 | } 249 | catch (SQLException e) 250 | { 251 | System.out.println("Something went wrong while verifying cnic"); 252 | } 253 | return ""; 254 | } 255 | 256 | 257 | 258 | public void block_account(int acc_num) 259 | { 260 | try { 261 | // Check if client already exists 262 | String uaQuery = "Update bank_schema.bank_account set status = 2 Where acc_num = " + acc_num; 263 | System.out.println(uaQuery); 264 | Statement uaSt = conn.createStatement(); 265 | uaSt.executeUpdate(uaQuery); 266 | } 267 | catch (SQLException e) { 268 | System.out.println("Something went wrong while getting current password"); 269 | } 270 | } 271 | 272 | 273 | 274 | public void unblock_account(int acc_num) 275 | { 276 | try { 277 | // Check if client already exists 278 | String uaQuery = "Update bank_schema.bank_account set status = 1 Where acc_num = " + acc_num; 279 | System.out.println(uaQuery); 280 | Statement uaSt = conn.createStatement(); 281 | uaSt.executeUpdate(uaQuery); 282 | } 283 | catch (SQLException e) { 284 | System.out.println("Something went wrong while getting current password"); 285 | } 286 | } 287 | 288 | 289 | 290 | public int get_card_num(int acc_num) 291 | { 292 | try 293 | { 294 | String uaQuery = "Select * From bank_schema.bank_account Where acc_num = "+ acc_num; 295 | System.out.println(uaQuery); 296 | Statement uaSt = conn.createStatement(); 297 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 298 | if( uaRs.next() ) 299 | { 300 | return uaRs.getInt("card_num"); 301 | } 302 | else 303 | return 0; 304 | } 305 | catch (SQLException e) 306 | { 307 | System.out.println("Something went wrong while verifying cnic"); 308 | } 309 | return 0; 310 | } 311 | 312 | 313 | 314 | public void block_card(int card_num) 315 | { 316 | try 317 | { 318 | String uaQuery = "Update bank_schema.card set status=\"B\" where card_num = " + card_num; //B=Blocked 319 | System.out.println(uaQuery); 320 | Statement uaSt = conn.createStatement(); 321 | uaSt.executeUpdate(uaQuery); 322 | } 323 | catch (SQLException e) 324 | { 325 | System.out.println("Something went wrong while blocking card"); 326 | } 327 | } 328 | 329 | 330 | 331 | public void unblock_card(int card_num) 332 | { 333 | try 334 | { 335 | String uaQuery = "Update bank_schema.card set status=\"A\" where card_num = " + card_num; //A=Active 336 | System.out.println(uaQuery); 337 | Statement uaSt = conn.createStatement(); 338 | uaSt.executeUpdate(uaQuery); 339 | } 340 | catch (SQLException e) 341 | { 342 | System.out.println("Something went wrong while unblocking card"); 343 | } 344 | } 345 | 346 | 347 | 348 | public void close_account(int acc_num) 349 | { 350 | try 351 | { 352 | String uaQuery = "Update bank_schema.bank_account set status = 0 Where acc_num = "+ acc_num; 353 | System.out.println(uaQuery); 354 | Statement uaSt = conn.createStatement(); 355 | uaSt.executeUpdate(uaQuery); 356 | } 357 | catch (SQLException e) 358 | { 359 | System.out.println("Something went wrong while verifying cnic"); 360 | } 361 | } 362 | 363 | 364 | 365 | public boolean login_exists(int client_id) 366 | { 367 | try 368 | { 369 | String uaQuery = "Select * From bank_schema.bank_account Where client_id = "+ client_id; 370 | System.out.println(uaQuery); 371 | Statement uaSt = conn.createStatement(); 372 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 373 | if( uaRs.next() ) 374 | { 375 | int temp_login_id = uaRs.getInt("login_id"); 376 | System.out.println("login id of client with client id=" + client_id +" is: " + temp_login_id); 377 | if ( temp_login_id == 0) 378 | return true; 379 | else 380 | return false; 381 | } 382 | else 383 | return false; 384 | } 385 | catch (SQLException e) 386 | { 387 | System.out.println("Something went wrong while checking existanec of login account"); 388 | } 389 | return false; 390 | } 391 | 392 | 393 | 394 | public boolean verify_cnic(int client_id, String cnic) 395 | { 396 | try 397 | { 398 | String uaQuery = "Select * From bank_schema.client Where client_id = "+ client_id; 399 | System.out.println(uaQuery); 400 | Statement uaSt = conn.createStatement(); 401 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 402 | if( uaRs.next() ) 403 | { 404 | String temp_cnic = uaRs.getString("CNIC"); 405 | System.out.println("Client id=" + client_id + "\tCNIC=" + temp_cnic); 406 | if ( temp_cnic.equals(cnic)) 407 | return true; 408 | else 409 | return false; 410 | } 411 | else 412 | return false; 413 | } 414 | catch (SQLException e) 415 | { 416 | System.out.println("Something went wrong while verifying cnic"); 417 | } 418 | return false; 419 | } 420 | 421 | 422 | 423 | public int create_login(String username, String password) 424 | { 425 | try 426 | { 427 | String uaQuery = "INSERT INTO bank_schema.login_account VALUES (NULL,\"" + username + "\",\"" + password + "\",\"C\");"; 428 | System.out.println(uaQuery); 429 | Statement uaSt = conn.createStatement(); 430 | uaSt.executeUpdate(uaQuery); 431 | } 432 | catch (SQLException e) 433 | { 434 | throw new IllegalStateException("Unable to insert values into login_account " + e.getMessage()); 435 | } 436 | 437 | try 438 | { 439 | String uaQuery = "select login_id from bank_schema.login_account where username = \"" + username + "\" and password = \"" + password + "\""; 440 | System.out.println(uaQuery); 441 | Statement uaSt = conn.createStatement(); 442 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 443 | if( uaRs.next() ) 444 | { 445 | return uaRs.getInt("login_id"); 446 | } 447 | else 448 | return -1; 449 | } 450 | catch (SQLException e) 451 | { 452 | System.out.println("Something went wrong is creating login account"); 453 | } 454 | return -1; 455 | 456 | } 457 | 458 | 459 | 460 | public void set_login_id(int login_id, int client_id) 461 | { 462 | try 463 | { 464 | String uaQuery = "update bank_schema.bank_account set login_id = " + login_id + " where client_id = " + client_id ; 465 | System.out.println(uaQuery); 466 | Statement uaSt = conn.createStatement(); 467 | uaSt.executeUpdate(uaQuery); 468 | 469 | uaQuery = "select login_id from bank_schema.bank_account where client_id = " + client_id ; 470 | System.out.println(uaQuery); 471 | uaSt = conn.createStatement(); 472 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 473 | if( uaRs.next() ) 474 | { 475 | System.out.println("The login_id of this account is " + uaRs.getInt("login_id") ); 476 | } 477 | else 478 | { 479 | System.out.println("The login id could not be found"); 480 | return; 481 | } 482 | } 483 | catch (SQLException e) 484 | { 485 | System.out.println("Something went wrong in setting login_id of account"); 486 | } 487 | } 488 | 489 | 490 | 491 | public int DB_CreateAccount( Client new_client, String aType ) { 492 | int res = 0; 493 | try { 494 | // Check if client already exists 495 | String dQuery = "Select * From bank_schema.client Where cnic = \""+new_client.getCNIC()+"\""; 496 | System.out.println(dQuery); 497 | Statement dSt = conn.createStatement(); 498 | ResultSet dRs = dSt.executeQuery(dQuery); 499 | int dRecord = 0; 500 | 501 | while( dRs.next() ) 502 | dRecord++; 503 | System.out.println(dRecord); 504 | if( dRecord < 1 ) { 505 | System.out.println("No duplicate record"); 506 | 507 | // Insert new client 508 | String ciQuery = "Insert Into bank_schema.client Values(NULL, \""+new_client.getFName()+"\", \""+ 509 | new_client.getLName()+"\", \""+new_client.getFatherName()+"\", \""+ 510 | new_client.getMotherName()+"\", \""+new_client.getCNIC()+"\", STR_TO_DATE(\""+ 511 | new_client.getDOB()+"\", \"%d,%m,%Y\"), \""+ 512 | new_client.getPhone()+"\", \""+new_client.getEmail()+"\", \""+new_client.getAddress()+"\")"; 513 | System.out.println(ciQuery); 514 | Statement ciSt = conn.createStatement(); 515 | ciSt.executeUpdate(ciQuery); 516 | 517 | // Find the client id 518 | String cQuery = "Select * From bank_schema.client Where cnic = \""+new_client.getCNIC()+"\""; 519 | Statement cSt = conn.createStatement(); 520 | ResultSet cRs = cSt.executeQuery(cQuery); 521 | if( cRs.next() ) { 522 | System.out.println("Client was added "+cRs.getString("client_id")); 523 | int c_id = cRs.getInt("client_id"); 524 | // Make client's bank account 525 | String baQuery = "Insert Into bank_schema.bank_account Values(NULL, "+String.valueOf(c_id)+", NULL, \""+ 526 | aType+"\", 0, 1, CURDATE(), NULL, NULL)"; 527 | System.out.println(baQuery); 528 | Statement baSt = conn.createStatement(); 529 | baSt.executeUpdate(baQuery); 530 | 531 | res = 1; 532 | } 533 | } 534 | else 535 | res = 2; 536 | } 537 | catch (SQLException e) { 538 | System.out.println("Something went wrong"); 539 | } 540 | return res; 541 | } 542 | 543 | 544 | 545 | public int TransferMoney( Client client, String rAccNum, int amount) { 546 | try { 547 | // Check if receiving client already exists 548 | String uaQuery = "Select acc_num, balance From bank_schema.bank_account Where acc_num = "+rAccNum+" and status = 1"; 549 | System.out.println(uaQuery); 550 | Statement uaSt = conn.createStatement(); 551 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 552 | if( uaRs.next() ) { 553 | int recv_balance = uaRs.getInt("balance"); 554 | String bQuery = "Select acc_num, balance From bank_schema.bank_account Where client_id = "+client.getClientID(); 555 | System.out.println(bQuery); 556 | Statement bSt = conn.createStatement(); 557 | ResultSet bRs = uaSt.executeQuery(bQuery); 558 | if( bRs.next() ) { 559 | String snd_acc_num = bRs.getString("acc_num"); 560 | int snd_balance = bRs.getInt("balance"); 561 | if( snd_balance >= amount ) { 562 | snd_balance -= amount; 563 | recv_balance += amount; 564 | 565 | String usQuery = "Update bank_schema.bank_account Set balance = "+snd_balance+" where client_id="+client.getClientID(); 566 | System.out.println("SQL-> "+usQuery); 567 | Statement usSt = conn.createStatement(); 568 | usSt.executeUpdate(usQuery); 569 | 570 | String urQuery = "Update bank_schema.bank_account Set balance = "+recv_balance+" where acc_num="+rAccNum; 571 | System.out.println("SQL-> "+urQuery); 572 | Statement urSt = conn.createStatement(); 573 | urSt.executeUpdate(urQuery); 574 | 575 | // insert into transaction history 576 | String thQuery = "Insert into bank_schema.transaction_history values(NULL,"+String.valueOf(amount)+", \"transfer\", CURDATE(), CURRENT_TIME(), "+snd_acc_num+", "+rAccNum+" , NULL )"; 577 | System.out.println("SQL-> "+thQuery); 578 | Statement thSt = conn.createStatement(); 579 | thSt.executeUpdate(thQuery); 580 | 581 | return 3; 582 | } 583 | else 584 | return 2; 585 | } 586 | } 587 | else 588 | return 1; 589 | } 590 | catch (SQLException e) { 591 | System.out.println("Something went wrong while logging in"); 592 | } 593 | 594 | return 0; 595 | } 596 | 597 | 598 | 599 | // Check if any account with provided account number and CNIC is present or not and returning the account if found 600 | Bank_Account searchAccount1( String accountNum, String CNIC ) { 601 | Bank_Account account = new Bank_Account(); 602 | try { 603 | // finding the account in database 604 | String aQuery = "Select * From bank_schema.bank_account Where acc_num = "+accountNum+" and " 605 | + " client_id = (select client_id from bank_schema.client where CNIC=\""+CNIC+"\")"; 606 | System.out.println(aQuery); 607 | Statement uaSt = conn.createStatement(); 608 | ResultSet uaRs = uaSt.executeQuery(aQuery); 609 | 610 | if( uaRs.next() ) { 611 | // removing old instance of bank account and adding new instance with information 612 | account = new Bank_Account( uaRs.getString("acc_num"), uaRs.getString("client_id"), uaRs.getString("login_id"), uaRs.getString("type"), uaRs.getString("balance"), uaRs.getString("status"), uaRs.getString("opening_date"), uaRs.getString("closing_date"), uaRs.getString("card_num") ); 613 | } 614 | return account; 615 | } 616 | catch (SQLException e) { 617 | System.out.println("Something went wrong while checking if account exists"); 618 | return account; 619 | } 620 | } 621 | 622 | 623 | 624 | // Check if any client with provided CNIC and bank account number is present or not and returning that client information 625 | Client searchClient1( String accountNum, String CNIC ) { 626 | Client client = new Client(); 627 | try { 628 | // finding the client in database 629 | String aQuery = "Select * From bank_schema.client Where CNIC = \""+CNIC+"\" and ( select count(*)" 630 | + " from bank_schema.bank_account where acc_num = "+accountNum+") = 1"; 631 | System.out.println(aQuery); 632 | Statement uaSt = conn.createStatement(); 633 | ResultSet uaRs = uaSt.executeQuery(aQuery); 634 | 635 | if( uaRs.next() ) { 636 | // removing old instance of client and adding new instance with information 637 | client = new Client( uaRs.getString("client_id"), uaRs.getString("f_name"), uaRs.getString("l_name"), uaRs.getString("father_name"), uaRs.getString("mother_name"), uaRs.getString("CNIC"), uaRs.getString("DOB"), uaRs.getString("phone"), uaRs.getString("email"), uaRs.getString("address") ); 638 | } 639 | return client; 640 | } 641 | catch (SQLException e) { 642 | System.out.println("Something went wrong while checking if client exists"); 643 | return client; 644 | } 645 | } 646 | 647 | 648 | 649 | // Check if any account with provided account number is present or not and returning the account if found 650 | Bank_Account searchAccount2( String accountNum ) { 651 | Bank_Account account = new Bank_Account(); 652 | try { 653 | // finding the account in database 654 | String aQuery = "Select * From bank_schema.bank_account Where acc_num = "+accountNum; 655 | System.out.println(aQuery); 656 | Statement uaSt = conn.createStatement(); 657 | ResultSet uaRs = uaSt.executeQuery(aQuery); 658 | 659 | if( uaRs.next() ) { 660 | // removing old instance of bank account and adding new instance with information 661 | account = new Bank_Account( uaRs.getString("acc_num"), uaRs.getString("client_id"), uaRs.getString("login_id"), uaRs.getString("type"), uaRs.getString("balance"), uaRs.getString("status"), uaRs.getString("opening_date"), uaRs.getString("closing_date"), uaRs.getString("card_num") ); 662 | } 663 | return account; 664 | } 665 | catch (SQLException e) { 666 | System.out.println("Something went wrong while checking if account exists"); 667 | return account; 668 | } 669 | } 670 | 671 | 672 | 673 | // Check if any client with provided CNIC and bank account number is present or not and returning that client information 674 | Client searchClient2( String accountNum ) { 675 | Client client = new Client(); 676 | try { 677 | // finding the client in database 678 | String aQuery = "Select * From bank_schema.client Where client_id = ( select client_id " 679 | + " from bank_schema.bank_account where acc_num = "+accountNum+") = 1"; 680 | System.out.println(aQuery); 681 | Statement uaSt = conn.createStatement(); 682 | ResultSet uaRs = uaSt.executeQuery(aQuery); 683 | 684 | if( uaRs.next() ) { 685 | // removing old instance of client and adding new instance with information 686 | client = new Client( uaRs.getString("client_id"), uaRs.getString("f_name"), uaRs.getString("l_name"), uaRs.getString("father_name"), uaRs.getString("mother_name"), uaRs.getString("CNIC"), uaRs.getString("DOB"), uaRs.getString("phone"), uaRs.getString("email"), uaRs.getString("address") ); 687 | } 688 | return client; 689 | } 690 | catch (SQLException e) { 691 | System.out.println("Something went wrong while checking if client exists"); 692 | return client; 693 | } 694 | } 695 | 696 | 697 | 698 | public int updateBalance( Bank_Account account, int balance, int t ) { 699 | int res = 0; 700 | try { 701 | // update balance of account 702 | int temp_balance = Integer.valueOf( account.getBalance() ) + balance; 703 | String bsQuery = "Update bank_schema.bank_account Set balance = "+temp_balance+" where acc_num="+account.getAccountNum(); 704 | System.out.println("SQL-> "+bsQuery); 705 | Statement bsSt = conn.createStatement(); 706 | bsSt.executeUpdate(bsQuery); 707 | 708 | // check if it is updated successfully 709 | String bQuery = "Select balance From bank_schema.bank_account Where acc_num = "+account.getAccountNum(); 710 | System.out.println(bQuery); 711 | Statement bSt = conn.createStatement(); 712 | ResultSet bRs = bSt.executeQuery(bQuery); 713 | if( bRs.next() ) { 714 | int b = bRs.getInt("balance"); 715 | if( b == temp_balance ) { 716 | 717 | String type_ = "deposit"; 718 | if( t == 2 ) { 719 | type_ = "withdraw"; 720 | balance *= -1; 721 | } 722 | // make an entry in transaction history 723 | String thQuery = "Insert into bank_schema.transaction_history values(NULL,"+balance+", \""+type_+"\", CURDATE(), CURRENT_TIME(), "+account.getAccountNum()+", NULL, NULL )"; 724 | System.out.println("SQL-> "+thQuery); 725 | Statement thSt = conn.createStatement(); 726 | bsSt.executeUpdate(thQuery); 727 | 728 | res = 1; 729 | } 730 | } 731 | return res; 732 | } 733 | catch (SQLException e) { 734 | System.out.println("Something went wrong while checking if account exists"); 735 | return res; 736 | } 737 | } 738 | 739 | 740 | 741 | public List getTransactions(String accNum, String From, String To) { 742 | List list=new ArrayList(); 743 | try { 744 | // finding the transactions 745 | String tQuery = "Select * From bank_schema.transaction_history Where ( account_num = "+accNum+" or recv_acc_num = "+accNum+" ) and ( date between '"+From+"'" 746 | + " and '"+To+"')"; 747 | System.out.println(tQuery); 748 | Statement tSt = conn.createStatement(); 749 | ResultSet tRs = tSt.executeQuery(tQuery); 750 | while( tRs.next() ) { 751 | // removing old instance of client and adding new instance with information 752 | Transaction_History th = new Transaction_History( tRs.getString("serial_no"), tRs.getString("amount"), tRs.getString("type"), tRs.getString("date"), tRs.getString("time"), tRs.getString("account_num"), tRs.getString("recv_acc_num"), tRs.getString("cheque_num") ); 753 | System.out.print("@-"); 754 | list.add( th ); 755 | } 756 | } 757 | catch (SQLException e) { 758 | System.out.println("Something went wrong"); 759 | } 760 | return list; 761 | } 762 | 763 | 764 | 765 | public int createPDF( Client client, Bank_Account account, String From, String To ) { 766 | int res = 0; 767 | try { 768 | 769 | String html_start = "

ABC Bank

F9 Branch, Islamabad

" 770 | + "

"+client.getFName()+" "+client.getLName()+"
Account Number: "+account.getAccountNum()+"
Current Account" 771 | + "
Transaction Dates: "+From+" - "+To+"

E Bank Statement

" 772 | + "" 773 | + "" 774 | + ""; 775 | String html_end = "
Serial NoAmountTypeDateTimeAccount NumReciever Account NumCheque Num
"; 776 | String html_data=""; 777 | 778 | // finding the transactions 779 | String tQuery = "Select * From bank_schema.transaction_history Where ( account_num = "+account.getAccountNum()+" or recv_acc_num = "+account.getAccountNum()+" ) and ( date between '"+From+"'" 780 | + " and '"+To+"')"; 781 | System.out.println(tQuery); 782 | Statement tSt = conn.createStatement(); 783 | ResultSet tRs = tSt.executeQuery(tQuery); 784 | int rows = 0; 785 | while( tRs.next() ) { 786 | rows++; 787 | html_data += ""+tRs.getString("serial_no")+"" 788 | + ""+tRs.getString("amount")+"" 789 | + ""+tRs.getString("type")+"" 790 | + ""+tRs.getString("date")+"" 791 | + ""+tRs.getString("time")+"" 792 | + ""+tRs.getString("account_num")+"" 793 | + ""+tRs.getString("recv_acc_num")+"" 794 | + ""+tRs.getString("cheque_num")+""; 795 | } 796 | if( rows > 0 ) { 797 | String html = html_start + html_data + html_end; 798 | try { 799 | String file_name = "E_Statement_" + java.time.LocalDateTime.now() + ".pdf"; 800 | file_name = file_name.replaceAll(":", "_"); 801 | HtmlConverter.convertToPdf( html, new FileOutputStream(file_name)); 802 | res = 1; 803 | } 804 | catch( Exception e) { 805 | System.out.println("Unknown error"); 806 | } 807 | } 808 | } 809 | catch (SQLException e) { 810 | System.out.println("Something went wrong"); 811 | } 812 | return res; 813 | } 814 | 815 | 816 | 817 | public int chequeDeposit( String accNum, String chequeNum, int amount ) { 818 | int res = 0; 819 | try { 820 | // finding the account in database 821 | String aQuery = "Select * From bank_schema.bank_account Where acc_num = "+accNum; 822 | System.out.println(aQuery); 823 | Statement uaSt = conn.createStatement(); 824 | ResultSet uaRs = uaSt.executeQuery(aQuery); 825 | if( uaRs.next() ) { 826 | if( Integer.valueOf( uaRs.getString("status")) == 0 ) 827 | { 828 | res = 4; // closed 829 | } 830 | else if( Integer.valueOf( uaRs.getString("status")) == 2 ) 831 | { 832 | res = 3; // blocked 833 | } 834 | else { 835 | int balance = amount + Integer.valueOf( uaRs.getString("balance") ); 836 | // account is found 837 | String bsQuery = "Update bank_schema.bank_account Set balance = "+balance+" where acc_num="+accNum; 838 | System.out.println("SQL-> "+bsQuery); 839 | Statement bsSt = conn.createStatement(); 840 | bsSt.executeUpdate(bsQuery); 841 | 842 | // make an entry in transaction history 843 | String thQuery = "Insert into bank_schema.transaction_history values(NULL,"+balance+", \"deposit\", CURDATE(), CURRENT_TIME(), "+accNum+", NULL, "+chequeNum+")"; 844 | System.out.println("SQL-> "+thQuery); 845 | Statement thSt = conn.createStatement(); 846 | thSt.executeUpdate(thQuery); 847 | 848 | res = 1; // successful 849 | } 850 | } 851 | else 852 | res = 2; // not found 853 | } 854 | catch (SQLException e) { 855 | System.out.println("Something went wrong"); 856 | } 857 | return res; 858 | } 859 | 860 | 861 | 862 | // update client info 863 | public void updateClientInfo(String client_id, String phone, String email, String address ) { 864 | try { 865 | String ucQuery = "Update bank_schema.client Set phone = \""+phone+"\" , email = \""+email+"\" , address = \""+ address 866 | + "\" where client_id="+client_id; 867 | System.out.println( ucQuery ); 868 | Statement ucSt = conn.createStatement(); 869 | ucSt.executeUpdate(ucQuery); 870 | } 871 | catch (SQLException e) { 872 | System.out.println("Something went wrong"); 873 | } 874 | } 875 | 876 | public int getLoginID(int acc_num) 877 | { 878 | try 879 | { 880 | String uaQuery = "Select login_id From bank_schema.bank_account Where acc_num = "+ acc_num; 881 | System.out.println(uaQuery); 882 | Statement uaSt = conn.createStatement(); 883 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 884 | if( uaRs.next() ) 885 | { 886 | return uaRs.getInt("login_id"); 887 | } 888 | else 889 | return -1; 890 | } 891 | catch (SQLException e) { 892 | System.out.println("Something went wrong while getting login_id"); 893 | } 894 | return -1; 895 | } 896 | 897 | public String get_password(int login_id) 898 | { 899 | try { 900 | // Check if client already exists 901 | String uaQuery = "Select * From bank_schema.login_account Where login_id = " + login_id; 902 | System.out.println(uaQuery); 903 | Statement uaSt = conn.createStatement(); 904 | ResultSet uaRs = uaSt.executeQuery(uaQuery); 905 | if( uaRs.next() ) { 906 | return uaRs.getString("password"); 907 | } 908 | else 909 | return ""; 910 | } 911 | catch (SQLException e) { 912 | System.out.println("Something went wrong while getting current password"); 913 | } 914 | return ""; 915 | } 916 | 917 | public void change_password(String pass, int login_id) 918 | { 919 | try { 920 | // Check if client already exists 921 | String uaQuery = "Update bank_schema.login_account set password = \"" + pass + "\" Where login_id = " + login_id; 922 | System.out.println(uaQuery); 923 | Statement uaSt = conn.createStatement(); 924 | uaSt.executeUpdate(uaQuery); 925 | } 926 | catch (SQLException e) { 927 | System.out.println("Something went wrong while getting current password"); 928 | } 929 | } 930 | 931 | public String getName(String id) { 932 | String name = ""; 933 | try 934 | { 935 | String eQuery = "Select * From bank_schema.employee Where login_id = "+ id; 936 | System.out.println(eQuery); 937 | Statement eSt = conn.createStatement(); 938 | ResultSet eRs = eSt.executeQuery(eQuery); 939 | if( eRs.next() ) 940 | { 941 | name = eRs.getString("f_name") + " " + eRs.getString("l_name"); 942 | } 943 | } 944 | catch (SQLException e) 945 | { 946 | System.out.println("Something went wrong while verifying cnic"); 947 | } 948 | return name; 949 | } 950 | 951 | public String getBalance(String acc_num) { 952 | String b = ""; 953 | try { 954 | // finding the account in database 955 | String aQuery = "Select * From bank_schema.bank_account Where acc_num = "+acc_num; 956 | System.out.println(aQuery); 957 | Statement uaSt = conn.createStatement(); 958 | ResultSet uaRs = uaSt.executeQuery(aQuery); 959 | if( uaRs.next() ) { 960 | b = uaRs.getString("balance"); 961 | } 962 | } 963 | catch (SQLException e) { 964 | System.out.println("Something went wrong while checking if account exists"); 965 | } 966 | return b; 967 | } 968 | 969 | public String getAccNum(String CNIC) { 970 | String b = ""; 971 | try { 972 | String aQuery = "Select * From bank_schema.bank_account Where client_id = (select client_id from bank_schema.client where CNIC=\""+CNIC+"\")"; 973 | System.out.println(aQuery); 974 | Statement uaSt = conn.createStatement(); 975 | ResultSet uaRs = uaSt.executeQuery(aQuery); 976 | if( uaRs.next() ) { 977 | b = uaRs.getString("acc_num"); 978 | } 979 | } 980 | catch (SQLException e) { 981 | System.out.println("Something went wrong while checking if account exists"); 982 | } 983 | return b; 984 | } 985 | 986 | public void finalize() { 987 | try { 988 | System.out.println("Connection Closed"); 989 | conn.close(); 990 | } 991 | catch (SQLException e) { 992 | throw new IllegalStateException("Trying to close a not opened db connection" + e.getMessage()); 993 | } 994 | } 995 | 996 | } 997 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/GUI.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import java.awt.event.*; 4 | import java.util.List; 5 | import java.awt.*; 6 | import javax.swing.*; 7 | import javax.swing.table.DefaultTableModel; 8 | 9 | public class GUI { 10 | 11 | // remake the screen 12 | public void remakeScreen(JFrame frame, JPanel f) { 13 | f.setLayout(null); 14 | frame.setContentPane(f); 15 | frame.setVisible(true); 16 | } 17 | 18 | 19 | 20 | //------------------------------------------------------------ 21 | // Login Related Screen Functions | 22 | //------------------------------------------------------------ 23 | 24 | 25 | // sign in form which is displayed at the start of program 26 | public void openSignInForm(JFrame frame, Login_Account user) { 27 | JPanel f = new JPanel(); 28 | f.setBackground(Color.white); 29 | 30 | // main screen picture 31 | JLabel imgLabel = new JLabel(new ImageIcon( System.getProperty("user.dir") + "\\src\\def_pkg\\anchor.png")); 32 | imgLabel.setBounds(20,24,450, 400); 33 | f.add(imgLabel); 34 | 35 | //---------------------------------Creating Labels------------------------------------------ 36 | JLabel l_hSignIn = new JLabel("Sign In"); 37 | l_hSignIn.setFont( l_hSignIn.getFont().deriveFont(30f) ); 38 | l_hSignIn.setBounds(550,50,100, 40); 39 | f.add(l_hSignIn); 40 | 41 | JLabel l_UserName = new JLabel("User Name"); 42 | l_UserName.setBounds(500,120,100, 40); 43 | f.add(l_UserName); 44 | 45 | JLabel l_Password = new JLabel("Password"); 46 | l_Password.setBounds(500,200,100, 40); 47 | f.add(l_Password); 48 | 49 | JLabel l_Signup = new JLabel("Dont have an account?"); 50 | l_Signup.setBounds(500,380,150, 40); 51 | f.add(l_Signup); 52 | 53 | //-----------------------------------Creating TextFields-------------------------------------------------- 54 | JTextField tf_UserName = new JTextField(); 55 | tf_UserName.setBounds(500,170,180, 25); 56 | f.add(tf_UserName); 57 | 58 | JPasswordField tf_Password = new JPasswordField(); 59 | tf_Password.setBounds(500,250,180, 25); 60 | f.add(tf_Password); 61 | 62 | //-------------------------------------Creating Buttons-------------------------------------------------- 63 | JButton btn_SignIn = new JButton("Sign In"); 64 | btn_SignIn.setFont( btn_SignIn.getFont().deriveFont(18f) ); 65 | btn_SignIn.setBackground( new Color(0, 204, 153) ); 66 | btn_SignIn.setForeground(Color.white); 67 | btn_SignIn.setBounds(550,300,110, 40); 68 | f.add(btn_SignIn); 69 | 70 | JButton btn_SignUp = new JButton("Sign Up"); 71 | btn_SignUp.setFont( btn_SignUp.getFont().deriveFont(18f) ); 72 | btn_SignUp.setBackground( new Color(0, 204, 153) ); 73 | btn_SignUp.setForeground(Color.white); 74 | btn_SignUp.setBounds(650,380,110, 40); 75 | f.add(btn_SignUp); 76 | 77 | //---------------------------------------SignUp functionality---------------------------------------------- 78 | 79 | btn_SignUp.addActionListener(new ActionListener() { 80 | public void actionPerformed(ActionEvent e) { 81 | 82 | open_Signup_form_1(frame, user); 83 | 84 | } 85 | }); 86 | 87 | //----------------------------------Sign in Functionality----------------------------------------------- 88 | btn_SignIn.addActionListener( new ActionListener() { 89 | public void actionPerformed(ActionEvent e) { 90 | 91 | DB_Handler db = new DB_Handler(); 92 | Login_Account user = db.signIn( tf_UserName.getText(), tf_Password.getText() ); 93 | if( user.getLoginId().compareTo("") == 0 ) { 94 | JOptionPane.showMessageDialog(f, "Wrong username or password"); 95 | } 96 | else { 97 | System.out.println("Login type="+user.getType()); 98 | if( user.getType().compareTo("Client") == 0 ) { 99 | Client client = db.getClient( user.getLoginId() ); 100 | Bank_Account account = db.getAccount( user.getLoginId() ); 101 | 102 | if ( Integer.valueOf(account.getStatus()) == 0 ) 103 | JOptionPane.showMessageDialog(f, "No active account found with these credentials"); 104 | else if( Integer.valueOf(account.getStatus()) == 1 ) { 105 | frame.remove(f); 106 | frame.repaint(); 107 | frame.validate(); 108 | openClientMenu(frame, client, account); 109 | } 110 | else if( Integer.valueOf(account.getStatus()) == 2 ) { 111 | JOptionPane.showMessageDialog(f, "This account is blocked so you cannot sign in"); 112 | } 113 | else { 114 | JOptionPane.showMessageDialog(f, "Sign In failed"); 115 | } 116 | } 117 | else if( user.getType().compareTo("Manager") == 0 ) { 118 | Manager manager = new Manager( user.getName() ); 119 | frame.remove(f); 120 | frame.repaint(); 121 | frame.validate(); 122 | openManagerMenu(frame, manager); 123 | } 124 | else if( user.getType().compareTo("Accountant") == 0 ) { 125 | Accountant accountant = new Accountant( user.getName() ); 126 | frame.remove(f); 127 | frame.repaint(); 128 | frame.validate(); 129 | openAccountantMenu(frame, accountant); 130 | } 131 | } 132 | } 133 | }); 134 | remakeScreen(frame, f); 135 | } 136 | 137 | 138 | 139 | 140 | 141 | // sign up form 1, getting account# and CNIC# from user 142 | void open_Signup_form_1(JFrame frame, Login_Account user) 143 | { 144 | System.out.println("Control Shifted to Signup form_1 page"); 145 | JPanel f = new JPanel(); 146 | f.setBackground(Color.white); 147 | 148 | remakeScreen(frame, f); 149 | 150 | // Sign Up Label 151 | JLabel lSignUp = new JLabel("Sign Up"); 152 | lSignUp.setFont( lSignUp.getFont().deriveFont(30f) ); 153 | lSignUp.setBounds(320,40,300, 40); 154 | f.add(lSignUp); 155 | 156 | //-----------------------------------------Creating Labels------------------------------------- 157 | JLabel l_AccountNo = new JLabel("Enter Account#:"); 158 | l_AccountNo.setBounds(200,110,100, 90); 159 | f.add(l_AccountNo); 160 | 161 | JLabel l_CNIC = new JLabel("Enter the CNIC:"); 162 | l_CNIC.setBounds(200, 180, 100, 90); 163 | f.add(l_CNIC); 164 | 165 | //-----------------------------------------Creating Textfields--------------------------------------- 166 | JTextField tf_AccountNo = new JTextField(); 167 | tf_AccountNo.setBounds(350, 140 ,200, 25); 168 | f.add(tf_AccountNo); 169 | 170 | JTextField tf_CNIC = new JTextField(); 171 | tf_CNIC.setBounds(350,210,200, 25); 172 | f.add(tf_CNIC); 173 | 174 | //-------------------------------------------Creating Buttons---------------------------------------- 175 | JButton btn_Verify_Account = new JButton("Verify Account"); 176 | btn_Verify_Account.setBackground( new Color(0, 204, 153) ); 177 | btn_Verify_Account.setForeground(Color.white); 178 | btn_Verify_Account.setBounds(290,280,150, 40); 179 | f.add(btn_Verify_Account); 180 | 181 | JButton btn_BACK = new JButton("BACK"); 182 | btn_BACK.setBackground( new Color(0, 204, 153) ); 183 | btn_BACK.setForeground(Color.white); 184 | btn_BACK.setBounds(50,400,100, 40); 185 | f.add(btn_BACK); 186 | 187 | // function executed when Back button is clicked 188 | btn_BACK.addActionListener(new ActionListener() { 189 | public void actionPerformed(ActionEvent e) { 190 | frame.remove(f); 191 | frame.repaint(); 192 | frame.validate(); 193 | openSignInForm(frame, user); 194 | } 195 | }); 196 | 197 | // function executed when Verify Account Button is clicked 198 | btn_Verify_Account.addActionListener(new ActionListener() { 199 | public void actionPerformed(ActionEvent e) { 200 | 201 | int verify_status = user.verify_account(tf_AccountNo.getText(), tf_CNIC.getText()); 202 | System.out.println("Verify Status Value: " + verify_status ); 203 | if (verify_status == -1) 204 | { 205 | JOptionPane.showMessageDialog(f, "There is no account present with this detail"); 206 | frame.remove(f); 207 | frame.repaint(); 208 | frame.validate(); 209 | openSignInForm(frame, user); 210 | } 211 | else if (verify_status == -2) 212 | { 213 | JOptionPane.showMessageDialog(f, "A login account is already made for this account"); 214 | System.out.println("The login account cannot be created as there is already a login account associated with this account"); 215 | frame.remove(f); 216 | frame.repaint(); 217 | frame.validate(); 218 | openSignInForm(frame, user); 219 | } 220 | 221 | else if (verify_status == -3) 222 | { 223 | // System.out.println("The CNIC matched with the client having client id=" + temp_client_id); 224 | open_Signup_form_2(frame, user, tf_AccountNo.getText()); 225 | } 226 | else 227 | { 228 | JOptionPane.showMessageDialog(f, "No account found with this CNIC"); 229 | // ************************************** 230 | System.out.println("The CNIC did not match with any client"); 231 | frame.remove(f); 232 | frame.repaint(); 233 | frame.validate(); 234 | openSignInForm(frame, user); 235 | } 236 | } 237 | }); 238 | } 239 | 240 | 241 | 242 | 243 | 244 | // open sign up form 2, getting user name and password 245 | void open_Signup_form_2(JFrame frame, Login_Account user, String acc_num) 246 | { 247 | System.out.println("Control Shifted to Signup form_2 page"); 248 | JPanel f = new JPanel(); 249 | f.setBackground(Color.white); 250 | 251 | remakeScreen(frame, f); 252 | 253 | // Sign Up Label 254 | JLabel lSignUp = new JLabel("Sign Up"); 255 | lSignUp.setFont( lSignUp.getFont().deriveFont(30f) ); 256 | lSignUp.setBounds(320,40,300, 40); 257 | f.add(lSignUp); 258 | 259 | //-------------------------------------------Creating labels----------------------------------------------- 260 | JLabel l_username = new JLabel("Enter Username:"); 261 | l_username.setBounds(200,100,100, 90); 262 | f.add(l_username); 263 | 264 | JLabel l_password = new JLabel("Enter Password:"); 265 | l_password.setBounds(200, 160, 100, 90); 266 | f.add(l_password); 267 | 268 | JLabel l_password_2 = new JLabel("Confirm the password:"); 269 | l_password_2.setBounds(200, 220, 150, 90); 270 | f.add(l_password_2); 271 | 272 | //---------------------------------------------Creating Textfileds------------------------------------------ 273 | JTextField tf_username = new JTextField(); 274 | tf_username.setBounds(350, 130 ,200, 25); 275 | f.add(tf_username); 276 | 277 | JTextField tf_password = new JTextField(); 278 | tf_password.setBounds(350,190,200, 25); 279 | f.add(tf_password); 280 | 281 | JTextField tf_password_2 = new JTextField(); 282 | tf_password_2.setBounds(350,250,200, 25); 283 | f.add(tf_password_2); 284 | 285 | //-----------------------------------------------Creating Buttons---------------------------------------- 286 | JButton btn_create_login_Account = new JButton("Create Login Account"); 287 | btn_create_login_Account.setBackground( new Color(0, 204, 153) ); 288 | btn_create_login_Account.setForeground(Color.white); 289 | btn_create_login_Account.setBounds(300,320,200, 40); 290 | f.add(btn_create_login_Account); 291 | 292 | JButton btn_BACK = new JButton("BACK"); 293 | btn_BACK.setBackground( new Color(0, 204, 153) ); 294 | btn_BACK.setForeground(Color.white); 295 | btn_BACK.setBounds(50,400,100, 40); 296 | f.add(btn_BACK); 297 | 298 | // function executed when back button is clicked 299 | btn_BACK.addActionListener(new ActionListener() { 300 | public void actionPerformed(ActionEvent e) { 301 | frame.remove(f); 302 | frame.repaint(); 303 | frame.validate(); 304 | open_Signup_form_1(frame, user); 305 | } 306 | }); 307 | 308 | // function executed when Create Login Account Button is clicked 309 | btn_create_login_Account.addActionListener(new ActionListener() { 310 | public void actionPerformed(ActionEvent e) { 311 | 312 | int signup_status = user.signup(tf_username.getText(), tf_password.getText(), tf_password_2.getText(), acc_num); 313 | if (signup_status == -1) 314 | { 315 | System.out.println("The 2 passwords did not match"); 316 | JOptionPane.showMessageDialog(f, "The entered passwords do not match"); 317 | frame.remove(f); 318 | frame.repaint(); 319 | frame.validate(); 320 | open_Signup_form_2(frame, user, acc_num); 321 | } 322 | else if (signup_status == -2) 323 | { 324 | System.out.println("Something went wrong in creating login account because the returned login id is -1"); 325 | JOptionPane.showMessageDialog(f, "Unfortunately the login account could not be made"); 326 | frame.remove(f); 327 | frame.repaint(); 328 | frame.validate(); 329 | openSignInForm(frame, user); 330 | } 331 | else 332 | { 333 | JOptionPane.showMessageDialog(f, "Your Login Account has been successfully created. Please Login to continue"); 334 | frame.remove(f); 335 | frame.repaint(); 336 | frame.validate(); 337 | openSignInForm(frame, user); 338 | } 339 | } 340 | }); 341 | } 342 | 343 | 344 | 345 | //------------------------------------------------------ 346 | // Client Related Functions | 347 | //------------------------------------------------------ 348 | 349 | 350 | // this function display the menu screen for client 351 | void openClientMenu(JFrame frame, Client client, Bank_Account account) { 352 | JPanel f = new JPanel(); 353 | f.setBackground(Color.white); 354 | 355 | // Log Out button 356 | JButton btnLogOut = new JButton("Sign Out"); 357 | btnLogOut.setFont( btnLogOut.getFont().deriveFont(14f) ); 358 | btnLogOut.setBackground( new Color(0, 204, 153) ); 359 | btnLogOut.setForeground(Color.white); 360 | //btnLogOut.setBounds(580,58,100, 30); 361 | btnLogOut.setBounds(650,30,100, 30); 362 | btnLogOut.setFocusPainted(false); 363 | f.add(btnLogOut); 364 | 365 | // function to be executed when Log Out Button is clicked 366 | btnLogOut.addActionListener(new ActionListener() { 367 | public void actionPerformed(ActionEvent e) { 368 | frame.remove(f); 369 | frame.repaint(); 370 | frame.validate(); 371 | Login_Account user = new Login_Account (); 372 | openSignInForm(frame, user); 373 | } 374 | }); 375 | 376 | // User Name label 377 | JLabel lUser = new JLabel(client.getFName() + " " + client.getLName()); 378 | lUser.setFont( lUser.getFont().deriveFont(30f) ); 379 | lUser.setBounds(100,50,250, 40); 380 | f.add(lUser); 381 | 382 | // Designation label 383 | JLabel lDesg = new JLabel("User"); 384 | lDesg.setBounds(100,80,100, 40); 385 | f.add(lDesg); 386 | 387 | // Account Info Button 388 | JButton btnAccInfo = new JButton("Account Info"); 389 | btnAccInfo.setBounds(100,180,150, 40); 390 | btnAccInfo.setBackground( new Color(0, 204, 153) ); 391 | btnAccInfo.setForeground(Color.white); 392 | f.add(btnAccInfo); 393 | 394 | // function to be executed when Account Info Button is clicked 395 | btnAccInfo.addActionListener(new ActionListener () { 396 | public void actionPerformed(ActionEvent e) { 397 | open_info_page(frame, client, account); 398 | } 399 | }); 400 | 401 | // Cardless Cash WithDrawal Button 402 | JButton btnCCWithdrawal = new JButton("Cardless Cash Withdrawal"); 403 | btnCCWithdrawal.setBounds(300,180,200, 40); 404 | btnCCWithdrawal.setBackground( new Color(0, 204, 153) ); 405 | btnCCWithdrawal.setForeground(Color.white); 406 | f.add(btnCCWithdrawal); 407 | 408 | // function to be executed when Cardless Cash Withdrawal Button is clicked 409 | btnCCWithdrawal.addActionListener(new ActionListener() { 410 | public void actionPerformed(ActionEvent e) { 411 | open_cardless_page_1(frame, client, account); 412 | } 413 | }); 414 | 415 | // Transfer Money Button 416 | JButton btnTransferMoney = new JButton("Transfer Money"); 417 | btnTransferMoney.setBounds(550,180,150, 40); 418 | btnTransferMoney.setBackground( new Color(0, 204, 153) ); 419 | btnTransferMoney.setForeground(Color.white); 420 | f.add(btnTransferMoney); 421 | 422 | // EStatement Button 423 | JButton btnEStatement = new JButton("View EStatement"); 424 | btnEStatement.setBounds(100,250,150, 40); 425 | btnEStatement.setBackground( new Color(0, 204, 153) ); 426 | btnEStatement.setForeground(Color.white); 427 | f.add(btnEStatement); 428 | 429 | // function to be executed when transfer money button is clicked 430 | btnTransferMoney.addActionListener( new ActionListener() { 431 | public void actionPerformed(ActionEvent e) { 432 | frame.remove(f); 433 | frame.repaint(); 434 | frame.validate(); 435 | openTransferMoneyForm(frame, client, account); 436 | } 437 | }); 438 | 439 | // function to be executed when View EStatement Button is clicked 440 | btnEStatement.addActionListener( new ActionListener() { 441 | public void actionPerformed(ActionEvent e) { 442 | frame.remove(f); 443 | frame.repaint(); 444 | frame.validate(); 445 | eStatement2(frame, client, account); 446 | } 447 | }); 448 | 449 | //change password 450 | JButton btnChangePass = new JButton("Change Password"); 451 | btnChangePass.setBounds(300, 250, 200, 40); 452 | btnChangePass.setBackground( new Color(0, 204, 153) ); 453 | btnChangePass.setForeground(Color.white); 454 | f.add(btnChangePass); 455 | 456 | btnChangePass.addActionListener( new ActionListener() { 457 | public void actionPerformed(ActionEvent e) { 458 | frame.remove(f); 459 | frame.repaint(); 460 | frame.validate(); 461 | open_change_password_form(frame, client, account); 462 | } 463 | }); 464 | 465 | f.setLayout(null); 466 | frame.setContentPane(f); 467 | frame.setVisible(true); 468 | } 469 | 470 | 471 | 472 | 473 | 474 | // this function displays the clients account details on screen 475 | void open_info_page(JFrame frame, Client client, Bank_Account account) 476 | { 477 | JPanel f = new JPanel(); 478 | f.setBackground(Color.white); 479 | remakeScreen(frame, f); 480 | 481 | // Account Info Label 482 | JLabel lAccInfo = new JLabel("Account Info"); 483 | lAccInfo.setHorizontalAlignment(JLabel.CENTER); 484 | lAccInfo.setFont( lAccInfo.getFont().deriveFont(30f) ); 485 | lAccInfo.setBounds(300,40,200, 40); 486 | f.add(lAccInfo); 487 | 488 | // Account Holder Name 489 | JLabel l_name = new JLabel("Account Holder Name"); 490 | l_name.setHorizontalAlignment(JLabel.CENTER); 491 | l_name.setBounds(300, 70, 200, 90); 492 | f.add(l_name); 493 | JTextField tf_name = new JTextField(); 494 | tf_name.setHorizontalAlignment(JTextField.CENTER); 495 | tf_name.setBounds(300, 130 ,200, 25); 496 | tf_name.setText(client.getFName() + " " + client.getLName()); 497 | tf_name.setEditable(false); 498 | f.add(tf_name); 499 | 500 | // Account Number 501 | JLabel l_acc_num = new JLabel("Account Number:"); 502 | l_acc_num.setHorizontalAlignment(JLabel.CENTER); 503 | l_acc_num.setBounds(150, 160, 200, 90); 504 | f.add(l_acc_num); 505 | JTextField tf_acc_num = new JTextField(); 506 | tf_acc_num.setHorizontalAlignment(JTextField.CENTER); 507 | tf_acc_num.setBounds(150, 220 ,200, 25); 508 | tf_acc_num.setText( account.getAccountNum() ); 509 | tf_acc_num.setEditable(false); 510 | f.add(tf_acc_num); 511 | 512 | // Account Type 513 | JLabel l_acc_type = new JLabel("Account Type"); 514 | l_acc_type.setHorizontalAlignment(JLabel.CENTER); 515 | l_acc_type.setBounds(400, 160, 200, 90); 516 | f.add(l_acc_type); 517 | JTextField tf_acc_type = new JTextField(account.getType() ); 518 | tf_acc_type.setHorizontalAlignment(JTextField.CENTER); 519 | tf_acc_type.setBounds(400, 220 ,200, 25); 520 | tf_acc_type.setEditable(false); 521 | f.add(tf_acc_type); 522 | 523 | // Account Current Balance 524 | JLabel l_balance = new JLabel("Account Current Balance"); 525 | l_balance.setHorizontalAlignment(JLabel.CENTER); 526 | l_balance.setBounds(150, 250, 200, 90); 527 | f.add(l_balance); 528 | JTextField tf_balance = new JTextField(); 529 | tf_balance.setHorizontalAlignment(JTextField.CENTER); 530 | tf_balance.setBounds(150, 310 ,200, 25); 531 | tf_balance.setText( account.getBalance() ); 532 | tf_balance.setEditable(false);; 533 | f.add(tf_balance); 534 | 535 | // Account Opening Date 536 | JLabel l_open_date = new JLabel("Account Opening Date"); 537 | l_open_date.setHorizontalAlignment(JLabel.CENTER); 538 | l_open_date.setBounds(400, 250, 200, 90); 539 | f.add(l_open_date); 540 | JTextField tf_open_date = new JTextField(); 541 | tf_open_date.setHorizontalAlignment(JTextField.CENTER); 542 | tf_open_date.setBounds(400, 310 ,200, 25); 543 | tf_open_date.setText( account.getOpeningDate() ); 544 | tf_open_date.setEditable(false); 545 | f.add(tf_open_date); 546 | 547 | JButton btn_BACK = new JButton("Main Menu"); 548 | btn_BACK.setBackground( new Color(0, 204, 153) ); 549 | btn_BACK.setForeground(Color.white); 550 | btn_BACK.setBounds(50,400,100, 30); 551 | f.add(btn_BACK); 552 | 553 | btn_BACK.addActionListener(new ActionListener() { 554 | public void actionPerformed(ActionEvent e) { 555 | frame.remove(f); 556 | frame.repaint(); 557 | frame.validate(); 558 | openClientMenu(frame, client, account); 559 | } 560 | }); 561 | 562 | JButton btn_sign_out = new JButton("Sign Out"); 563 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 564 | btn_sign_out.setForeground(Color.white); 565 | btn_sign_out.setBounds(650,30,100, 30); 566 | f.add(btn_sign_out); 567 | 568 | btn_sign_out.addActionListener(new ActionListener() { 569 | public void actionPerformed(ActionEvent e) { 570 | frame.remove(f); 571 | frame.repaint(); 572 | frame.validate(); 573 | Login_Account user = new Login_Account(); 574 | openSignInForm(frame, user); 575 | } 576 | }); 577 | } 578 | 579 | 580 | 581 | 582 | 583 | // cardless cash withdrawal screen 584 | void open_cardless_page_1(JFrame frame, Client client, Bank_Account account) 585 | { 586 | System.out.println("Control Shifted to Cardless form_1 page"); 587 | JPanel f = new JPanel(); 588 | f.setBackground(Color.white); 589 | 590 | remakeScreen(frame, f); 591 | 592 | // Cardless Cash Withdrawal Label 593 | JLabel lCCWithdrawal = new JLabel("Cardless Cash Withdrawal"); 594 | lCCWithdrawal.setFont( lCCWithdrawal.getFont().deriveFont(30f) ); 595 | lCCWithdrawal.setBounds(200,40,400, 40); 596 | f.add(lCCWithdrawal); 597 | 598 | //-------------------------------------------Creating labels----------------------------------------------- 599 | JLabel l_card_no = new JLabel("Enter Your Card No:"); 600 | l_card_no.setBounds(150,100,180, 90); 601 | f.add(l_card_no); 602 | 603 | JLabel l_amount = new JLabel("Enter the amount of withdrawal:"); 604 | l_amount.setBounds(150, 160, 180, 90); 605 | f.add(l_amount); 606 | 607 | JLabel l_temp_pin = new JLabel("Enter the 4-digit temporary pin:"); 608 | l_temp_pin.setBounds(150, 220, 180, 90); 609 | f.add(l_temp_pin); 610 | 611 | //---------------------------------------------Creating Textfileds------------------------------------------ 612 | JTextField tf_card_no = new JTextField(); 613 | tf_card_no.setBounds(380, 130 ,200, 25); 614 | f.add(tf_card_no); 615 | 616 | JTextField tf_amount = new JTextField(); 617 | tf_amount.setBounds(380,190,200, 25); 618 | f.add(tf_amount); 619 | 620 | JTextField tf_temp_pin = new JTextField(); 621 | tf_temp_pin.setBounds(380,250,200, 25); 622 | f.add(tf_temp_pin); 623 | 624 | //-----------------------------------------------Creating Buttons---------------------------------------- 625 | JButton btn_create_cardless_entry = new JButton("Generate transaction OTP"); 626 | btn_create_cardless_entry.setBackground( new Color(0, 204, 153) ); 627 | btn_create_cardless_entry.setForeground(Color.white); 628 | btn_create_cardless_entry.setBounds(300,300,200, 40); 629 | f.add(btn_create_cardless_entry); 630 | 631 | JButton btn_sign_out = new JButton("Sign Out"); 632 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 633 | btn_sign_out.setForeground(Color.white); 634 | btn_sign_out.setBounds(650,30,100, 30); 635 | f.add(btn_sign_out); 636 | 637 | // function to be executed when Sign Out Button is clicked 638 | btn_sign_out.addActionListener(new ActionListener() { 639 | public void actionPerformed(ActionEvent e) { 640 | frame.remove(f); 641 | frame.repaint(); 642 | frame.validate(); 643 | Login_Account user = new Login_Account(); 644 | openSignInForm(frame, user); 645 | } 646 | }); 647 | 648 | // Main Menu Button 649 | JButton btn_mm = new JButton("Main Menu"); 650 | btn_mm.setBackground( new Color(0, 204, 153) ); 651 | btn_mm.setForeground(Color.white); 652 | btn_mm.setBounds(50,400,100, 30); 653 | f.add(btn_mm); 654 | 655 | // function to be executed when Main Menu Button is clicked 656 | btn_mm.addActionListener( new ActionListener() { 657 | public void actionPerformed(ActionEvent e) { 658 | frame.remove(f); 659 | frame.repaint(); 660 | frame.validate(); 661 | openClientMenu(frame, client, account); 662 | } 663 | }); 664 | 665 | // function to be executed when 666 | btn_create_cardless_entry.addActionListener(new ActionListener () { 667 | public void actionPerformed (ActionEvent e) { 668 | 669 | if ( account.getCardNum().compareTo(tf_card_no.getText()) != 0 ) 670 | { 671 | System.out.println("There is no card associated with this account as the card num received is 0"); 672 | JOptionPane.showMessageDialog(f, "You do not have any associated cards with this account"); 673 | frame.remove(f); 674 | frame.repaint(); 675 | frame.validate(); 676 | open_cardless_page_1(frame, client, account); 677 | } 678 | else { 679 | String cardless_status = client.do_cardless_cash_withdrawal(account, tf_amount.getText(), tf_temp_pin.getText()); 680 | if ( cardless_status.compareTo("a")==0 ) 681 | { 682 | JOptionPane.showMessageDialog(f, "Your card is currently blocked"); 683 | frame.remove(f); 684 | frame.repaint(); 685 | frame.validate(); 686 | open_cardless_page_1(frame, client, account); 687 | } 688 | else if( cardless_status.compareTo("b")==0 ) 689 | { 690 | // System.out.println("Your card is active because status was either A or a"); 691 | JOptionPane.showMessageDialog(f, "You do not have enough balance to complete this transaction"); 692 | frame.remove(f); 693 | frame.repaint(); 694 | frame.validate(); 695 | open_cardless_page_1(frame, client, account); 696 | } 697 | else if (cardless_status.compareTo("c")==0) 698 | { 699 | JOptionPane.showMessageDialog(f, "Your request of cardless withdrawal could not be completed"); 700 | frame.remove(f); 701 | frame.repaint(); 702 | frame.validate(); 703 | open_cardless_page_1(frame, client, account); 704 | } 705 | else 706 | { 707 | // System.out.println("You have enough balance to carry out this transaction"); 708 | System.out.println("Your request of cardless withdrawal has been successfully completed"); 709 | JOptionPane.showMessageDialog(f, "Your request of cardless withdrawal has been completed and your OTP is "+String.valueOf(cardless_status)); 710 | account.updateBalance(); 711 | frame.remove(f); 712 | frame.repaint(); 713 | frame.validate(); 714 | openClientMenu(frame, client, account); 715 | } 716 | } 717 | } 718 | }); 719 | } 720 | 721 | 722 | 723 | 724 | 725 | // money transfer screen 726 | void openTransferMoneyForm(JFrame frame, Client client, Bank_Account account) { 727 | JPanel f = new JPanel(); 728 | f.setBackground(Color.white); 729 | 730 | // Transfer Money Label 731 | JLabel l_hcreate = new JLabel("Transfer Money"); 732 | l_hcreate.setFont( l_hcreate.getFont().deriveFont(30f) ); 733 | l_hcreate.setBounds(300,60,300, 40); 734 | f.add(l_hcreate); 735 | 736 | // Receiver Account Number Label 737 | JLabel l_rAccNum = new JLabel("Reciever Account Number: "); 738 | l_rAccNum.setBounds(200,140,200, 40); 739 | f.add(l_rAccNum); 740 | 741 | // Amount Label 742 | JLabel l_amount = new JLabel("Amount: "); 743 | l_amount.setBounds(200,190,100, 40); 744 | f.add(l_amount); 745 | 746 | // Receiver Account Number Text Field 747 | JTextField tf_rAccNum = new JTextField(); 748 | tf_rAccNum.setBounds(400,150,180, 25); 749 | f.add(tf_rAccNum); 750 | 751 | // Amount Text field 752 | JTextField tf_amount = new JTextField(); 753 | tf_amount.setBounds(400,200,180, 25); 754 | f.add(tf_amount); 755 | 756 | // Transfer Button 757 | JButton btn_Transfer = new JButton("Transfer"); 758 | btn_Transfer.setBackground( new Color(0, 204, 153) ); 759 | btn_Transfer.setForeground(Color.white); 760 | btn_Transfer.setBounds(300,270,180, 40); 761 | f.add(btn_Transfer); 762 | 763 | // Main Menu Button 764 | JButton btn_mm = new JButton("Main Menu"); 765 | btn_mm.setBackground( new Color(0, 204, 153) ); 766 | btn_mm.setForeground(Color.white); 767 | btn_mm.setBounds(50,400,100, 30); 768 | f.add(btn_mm); 769 | 770 | // function to be executed when Transfer Button is clicked 771 | btn_Transfer.addActionListener( new ActionListener() { 772 | public void actionPerformed(ActionEvent e) { 773 | if( tf_rAccNum.getText().compareTo( account.getAccountNum() ) == 0 ) 774 | JOptionPane.showMessageDialog(f, "You cannot enter your own account number"); 775 | else { 776 | int r = client.transferMoney( tf_rAccNum.getText(), Integer.parseInt( tf_amount.getText() )); 777 | if( r == 1 ) 778 | JOptionPane.showMessageDialog(f, "Reciever account not found, is blocked or closed"); 779 | else if( r == 2) 780 | JOptionPane.showMessageDialog(f, "You have low balance"); 781 | else if( r == 3 ) { 782 | JOptionPane.showMessageDialog(f, "Transaction successful"); 783 | account.updateBalance(); 784 | frame.remove(f); 785 | frame.repaint(); 786 | frame.validate(); 787 | openClientMenu(frame, client, account); 788 | } 789 | else { 790 | 791 | } 792 | } 793 | } 794 | }); 795 | 796 | // function to be executed when Main Menu Button is clicked 797 | btn_mm.addActionListener( new ActionListener() { 798 | public void actionPerformed(ActionEvent e) { 799 | frame.remove(f); 800 | frame.repaint(); 801 | frame.validate(); 802 | openClientMenu(frame, client, account); 803 | } 804 | }); 805 | 806 | // Sign Out Button 807 | JButton btn_sign_out = new JButton("Sign Out"); 808 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 809 | btn_sign_out.setForeground(Color.white); 810 | btn_sign_out.setBounds(650,30,100, 30); 811 | f.add(btn_sign_out); 812 | 813 | btn_sign_out.addActionListener(new ActionListener() { 814 | public void actionPerformed(ActionEvent e) { 815 | frame.remove(f); 816 | frame.repaint(); 817 | frame.validate(); 818 | Login_Account user = new Login_Account(); 819 | openSignInForm(frame, user); 820 | } 821 | }); 822 | 823 | f.setLayout(null); 824 | frame.setContentPane(f); 825 | frame.setVisible(true); 826 | } 827 | 828 | 829 | 830 | 831 | 832 | // view e statement screen for client 833 | void eStatement2(JFrame frame, Client client, Bank_Account account) { 834 | JPanel f = new JPanel(); 835 | f.setBackground(Color.white); 836 | 837 | // E-Statement Label 838 | JLabel lEStatement = new JLabel("E-Statement"); 839 | lEStatement.setFont( lEStatement.getFont().deriveFont(30f) ); 840 | lEStatement.setBounds(50,50,250, 40); 841 | f.add(lEStatement); 842 | 843 | // From Date Label 844 | JLabel lFrom = new JLabel("From ( DD : MM : YY )"); 845 | lFrom.setBounds(50,100,150, 40); 846 | f.add(lFrom); 847 | 848 | // To Date Label 849 | JLabel lTo = new JLabel("To ( DD : MM : YY )"); 850 | lTo.setBounds(450,100,150, 40); 851 | f.add(lTo); 852 | 853 | // Day, Month and Year for From Date 854 | SpinnerModel fromDayValues = new SpinnerNumberModel(21, 1, 31, 1); 855 | JSpinner fromDaySpinner = new JSpinner(fromDayValues); 856 | fromDaySpinner.setBounds(50,130,40,25); 857 | f.add(fromDaySpinner); 858 | SpinnerModel fromMonthValues = new SpinnerNumberModel(12, 1, 12, 1); 859 | JSpinner fromMonthSpinner = new JSpinner(fromMonthValues); 860 | fromMonthSpinner.setBounds(100,130,40,25); 861 | f.add(fromMonthSpinner); 862 | SpinnerModel fromYearValues = new SpinnerNumberModel(2020, 2018, 2021, 1); 863 | JSpinner fromYearSpinner = new JSpinner(fromYearValues); 864 | fromYearSpinner.setBounds(150,130,55,25); 865 | f.add(fromYearSpinner); 866 | 867 | // Day, Month and Year for From Date 868 | SpinnerModel toDayValues = new SpinnerNumberModel(30, 1, 31, 1); 869 | JSpinner toDaySpinner = new JSpinner(toDayValues); 870 | toDaySpinner.setBounds(450,130,40,25); 871 | f.add(toDaySpinner); 872 | SpinnerModel toMonthValues = new SpinnerNumberModel(12, 1, 12, 1); 873 | JSpinner toMonthSpinner = new JSpinner( toMonthValues); 874 | toMonthSpinner.setBounds(500,130,40,25); 875 | f.add(toMonthSpinner); 876 | SpinnerModel toYearValues = new SpinnerNumberModel(2020, 2018, 2021, 1); 877 | JSpinner toYearSpinner = new JSpinner(toYearValues); 878 | toYearSpinner.setBounds(550,130,55,25); 879 | f.add(toYearSpinner); 880 | 881 | // E-Statement Button 882 | JButton btnEStatement = new JButton("Get E-Statement"); 883 | btnEStatement.setBackground( new Color(0, 204, 153) ); 884 | btnEStatement.setForeground(Color.white); 885 | btnEStatement.setBounds(50,180,150, 30); 886 | f.add(btnEStatement); 887 | 888 | // Download Button 889 | JButton btnDownload = new JButton("Download"); 890 | btnDownload.setBackground( new Color(0, 204, 153) ); 891 | btnDownload.setForeground(Color.white); 892 | btnDownload.setBounds(450,180,100, 30); 893 | f.add(btnDownload); 894 | btnDownload.setEnabled(false); 895 | 896 | // creating table for transaction data 897 | DefaultTableModel tableModel = new DefaultTableModel(); 898 | JTable table=new JTable(tableModel); 899 | tableModel.addColumn("Serial No"); 900 | tableModel.addColumn("Amount"); 901 | tableModel.addColumn("Type"); 902 | tableModel.addColumn("Date"); 903 | tableModel.addColumn("Time"); 904 | tableModel.addColumn("Account Number"); 905 | tableModel.addColumn("Reciever Account Number"); 906 | tableModel.addColumn("Cheque No"); 907 | table.setEnabled(false); 908 | JScrollPane sp=new JScrollPane(table); 909 | sp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); 910 | sp.setBounds(50,230,700,150); 911 | f.add(sp); 912 | sp.setVisible(true); 913 | 914 | // function to be executed when E Statement Button is clicked 915 | btnEStatement.addActionListener( new ActionListener() { 916 | public void actionPerformed(ActionEvent e) { 917 | tableModel.setRowCount(0); 918 | //sp.setVisible(false); 919 | 920 | String From = String.valueOf(fromYearSpinner.getValue()) +"-"+ String.valueOf(fromMonthSpinner.getValue()) +"-"+ String.valueOf(fromDaySpinner.getValue()); 921 | String To = String.valueOf(toYearSpinner.getValue()) +"-"+ String.valueOf(toMonthSpinner.getValue()) +"-"+ String.valueOf(toDaySpinner.getValue()); 922 | 923 | List list = client.getTransactions( account.getAccountNum(), From, To); 924 | if( list.size() > 0 ) { 925 | for( Transaction_History th: list) { 926 | tableModel.addRow(new Object[] { th.getSerialNo(), th.getAmount(), th.getType(), th.getDate(), th.getTime(), th.getAccountNumber(), th.getRecvAccNum(), th.getChequeNum() }); 927 | } 928 | tableModel.fireTableDataChanged(); 929 | sp.setVisible(true); 930 | //btnEStatement.setEnabled(false); 931 | btnDownload.setEnabled(true); 932 | } 933 | else { 934 | btnDownload.setEnabled(false); 935 | } 936 | } 937 | }); 938 | 939 | // function to be executed when Download Button is clicked 940 | btnDownload.addActionListener( new ActionListener() { 941 | public void actionPerformed(ActionEvent e) { 942 | String From = String.valueOf(fromYearSpinner.getValue()) +"-"+ String.valueOf(fromMonthSpinner.getValue()) +"-"+ String.valueOf(fromDaySpinner.getValue()); 943 | String To = String.valueOf(toYearSpinner.getValue()) +"-"+ String.valueOf(toMonthSpinner.getValue()) +"-"+ String.valueOf(toDaySpinner.getValue()); 944 | 945 | DB_Handler db = new DB_Handler(); 946 | int r = db.createPDF(client, account, From, To); 947 | if( r == 1 ) 948 | JOptionPane.showMessageDialog(f, "E-Statement is downloaded"); 949 | else 950 | JOptionPane.showMessageDialog(f, "Error in downloading the e-statement"); 951 | frame.remove(f); 952 | frame.repaint(); 953 | frame.validate(); 954 | //openAccountantMenu(frame, accountant); 955 | } 956 | }); 957 | 958 | // Main Menu Button 959 | JButton btnMM = new JButton("Main Menu"); 960 | btnMM.setBackground( new Color(0, 204, 153) ); 961 | btnMM.setForeground(Color.white); 962 | btnMM.setBounds(50,400,100, 30); 963 | f.add(btnMM); 964 | 965 | // function to be executed when Main Menu Button is clicked 966 | btnMM.addActionListener( new ActionListener() { 967 | public void actionPerformed(ActionEvent e) { 968 | frame.remove(f); 969 | frame.repaint(); 970 | frame.validate(); 971 | openClientMenu(frame, client, account); 972 | } 973 | }); 974 | 975 | // Sign Out Button 976 | JButton btn_sign_out = new JButton("Sign Out"); 977 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 978 | btn_sign_out.setForeground(Color.white); 979 | btn_sign_out.setBounds(650,30,100, 30); 980 | f.add(btn_sign_out); 981 | 982 | btn_sign_out.addActionListener(new ActionListener() { 983 | public void actionPerformed(ActionEvent e) { 984 | frame.remove(f); 985 | frame.repaint(); 986 | frame.validate(); 987 | Login_Account user = new Login_Account(); 988 | openSignInForm(frame, user); 989 | } 990 | }); 991 | 992 | // displaying the new panel on frame 993 | f.setLayout(null); 994 | frame.setContentPane(f); 995 | frame.setVisible(true); 996 | } 997 | 998 | 999 | 1000 | 1001 | 1002 | // client screen to change password of his login id 1003 | void open_change_password_form(JFrame frame, Client client, Bank_Account account) 1004 | { 1005 | System.out.println("Control Shifted to Change password form"); 1006 | JPanel f = new JPanel(); 1007 | f.setBackground(Color.white); 1008 | 1009 | remakeScreen(frame, f); 1010 | 1011 | // Change Password 1012 | JLabel lChgPass = new JLabel("Change Password"); 1013 | lChgPass.setFont( lChgPass.getFont().deriveFont(30f) ); 1014 | lChgPass.setBounds(250,50,300, 40); 1015 | f.add(lChgPass); 1016 | 1017 | //-------------------------------------------Creating labels----------------------------------------------- 1018 | JLabel l_curr_pass = new JLabel("Enter Current Password:"); 1019 | l_curr_pass.setBounds(150,100,200, 90); 1020 | f.add(l_curr_pass); 1021 | 1022 | JLabel l_new_pass_1 = new JLabel("Enter the new Password:"); 1023 | l_new_pass_1.setBounds(150, 150, 200, 90); 1024 | f.add(l_new_pass_1); 1025 | 1026 | JLabel l_new_pass_2 = new JLabel("Confirm the new Password:"); 1027 | l_new_pass_2.setBounds(150, 200, 200, 90); 1028 | f.add(l_new_pass_2); 1029 | 1030 | //---------------------------------------------Creating Textfileds------------------------------------------ 1031 | JPasswordField tf_curr_pass = new JPasswordField(); 1032 | tf_curr_pass.setBounds(350, 130 ,200, 25); 1033 | f.add(tf_curr_pass); 1034 | 1035 | JPasswordField tf_new_pass_1 = new JPasswordField(); 1036 | tf_new_pass_1.setBounds(350,180,200, 25); 1037 | f.add(tf_new_pass_1); 1038 | 1039 | JPasswordField tf_new_pass_2 = new JPasswordField(); 1040 | tf_new_pass_2.setBounds(350,230,200, 25); 1041 | f.add(tf_new_pass_2); 1042 | 1043 | //-----------------------------------------------Creating Buttons---------------------------------------- 1044 | JButton btn_change_password = new JButton("Change Password"); 1045 | btn_change_password.setBackground( new Color(0, 204, 153) ); 1046 | btn_change_password.setForeground(Color.white); 1047 | btn_change_password.setBounds(320,280,150, 40); 1048 | f.add(btn_change_password); 1049 | 1050 | // Main Menu Button 1051 | JButton btnMM = new JButton("Main Menu"); 1052 | btnMM.setBackground( new Color(0, 204, 153) ); 1053 | btnMM.setForeground(Color.white); 1054 | btnMM.setBounds(50,400,100, 30); 1055 | f.add(btnMM); 1056 | 1057 | // function to be executed when Main Menu Button is clicked 1058 | btnMM.addActionListener( new ActionListener() { 1059 | public void actionPerformed(ActionEvent e) { 1060 | frame.remove(f); 1061 | frame.repaint(); 1062 | frame.validate(); 1063 | openClientMenu(frame, client, account); 1064 | } 1065 | }); 1066 | 1067 | // function to be executed when Change Password Button is clicked 1068 | btn_change_password.addActionListener(new ActionListener() { 1069 | public void actionPerformed(ActionEvent e) { 1070 | 1071 | int change_pwd_status = client.change_password(tf_curr_pass.getText(), tf_new_pass_1.getText(), tf_new_pass_2.getText(), account.getAccountNum()); 1072 | 1073 | if (change_pwd_status == -1) 1074 | { 1075 | JOptionPane.showMessageDialog(f, "The system was unable to find the login account"); 1076 | frame.remove(f); 1077 | frame.repaint(); 1078 | frame.validate(); 1079 | open_change_password_form(frame, client, account); 1080 | } 1081 | else if ( change_pwd_status == -2 ) 1082 | { 1083 | System.out.println("The current password does not match with the already configured password"); 1084 | JOptionPane.showMessageDialog(f, "The current password does not match with the already configured password"); 1085 | frame.remove(f); 1086 | frame.repaint(); 1087 | frame.validate(); 1088 | open_change_password_form(frame, client, account); 1089 | } 1090 | else if (change_pwd_status == -3) 1091 | { 1092 | System.out.println("The new passwords does not match with one another"); 1093 | JOptionPane.showMessageDialog(f, "The new passwords does not match with one another"); 1094 | frame.remove(f); 1095 | frame.repaint(); 1096 | frame.validate(); 1097 | open_change_password_form(frame, client, account); 1098 | } 1099 | else 1100 | { 1101 | JOptionPane.showMessageDialog(f, "You have successfully changed your password. You will have to Sign in again to continue"); 1102 | frame.remove(f); 1103 | frame.repaint(); 1104 | frame.validate(); 1105 | Login_Account user = new Login_Account(); 1106 | openSignInForm(frame, user); 1107 | } 1108 | } 1109 | }); 1110 | } 1111 | 1112 | 1113 | 1114 | //---------------------------------------------------- 1115 | // Manager Related Screen | 1116 | //---------------------------------------------------- 1117 | 1118 | 1119 | // menu screen for manager 1120 | void openManagerMenu(JFrame frame, Manager manager) { 1121 | JPanel f = new JPanel(); 1122 | f.setBackground(Color.white); 1123 | 1124 | // Sign Out Button 1125 | JButton btn_sign_out = new JButton("Sign Out"); 1126 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1127 | btn_sign_out.setForeground(Color.white); 1128 | btn_sign_out.setBounds(650,30,100, 30); 1129 | f.add(btn_sign_out); 1130 | 1131 | btn_sign_out.addActionListener(new ActionListener() { 1132 | public void actionPerformed(ActionEvent e) { 1133 | frame.remove(f); 1134 | frame.repaint(); 1135 | frame.validate(); 1136 | Login_Account user = new Login_Account(); 1137 | openSignInForm(frame, user); 1138 | } 1139 | }); 1140 | 1141 | // User Name label 1142 | JLabel lUser = new JLabel(manager.getName()); 1143 | lUser.setFont( lUser.getFont().deriveFont(30f) ); 1144 | lUser.setBounds(100,50,300, 40); 1145 | f.add(lUser); 1146 | 1147 | // Designation label 1148 | JLabel lDesg = new JLabel("Manager"); 1149 | //lDesg.setFont( lDesg.getFont().deriveFont(30f) ); 1150 | lDesg.setBounds(100,80,100, 40); 1151 | f.add(lDesg); 1152 | 1153 | // Create Account Button 1154 | JButton btnCreateAcc = new JButton("Create Account"); 1155 | btnCreateAcc.setBounds(100,180,150, 40); 1156 | btnCreateAcc.setBackground( new Color(0, 204, 153) ); 1157 | btnCreateAcc.setForeground(Color.white); 1158 | f.add(btnCreateAcc); 1159 | 1160 | // function to be executed when Create Account Button is clicked 1161 | btnCreateAcc.addActionListener( new ActionListener() { 1162 | public void actionPerformed(ActionEvent e) { 1163 | frame.remove(f); 1164 | frame.repaint(); 1165 | frame.validate(); 1166 | openCreateAccountForm(frame, manager); 1167 | } 1168 | }); 1169 | 1170 | // Block/Unblock Account Button 1171 | JButton btnBlockAcc = new JButton("Block/Unblock Account"); 1172 | btnBlockAcc.setBounds(300,180,200, 40); 1173 | btnBlockAcc.setBackground( new Color(0, 204, 153) ); 1174 | btnBlockAcc.setForeground(Color.white); 1175 | f.add(btnBlockAcc); 1176 | 1177 | 1178 | btnBlockAcc.addActionListener( new ActionListener() { 1179 | public void actionPerformed(ActionEvent e) { 1180 | frame.remove(f); 1181 | frame.repaint(); 1182 | frame.validate(); 1183 | open_block_unblock_account_page(frame, manager); 1184 | } 1185 | }); 1186 | 1187 | 1188 | // Close Account Button 1189 | JButton btnCloseAcc = new JButton("Close Account"); 1190 | btnCloseAcc.setBounds(550,180,150, 40); 1191 | btnCloseAcc.setBackground( new Color(0, 204, 153) ); 1192 | btnCloseAcc.setForeground(Color.white); 1193 | f.add(btnCloseAcc); 1194 | 1195 | btnCloseAcc.addActionListener(new ActionListener() { 1196 | public void actionPerformed(ActionEvent e) { 1197 | open_close_account_page(frame, manager); 1198 | } 1199 | }); 1200 | 1201 | // Search Account Button 1202 | JButton btnSearchAcc = new JButton("Search Account"); 1203 | btnSearchAcc.setBounds(100,250,150, 40); 1204 | btnSearchAcc.setBackground( new Color(0, 204, 153) ); 1205 | btnSearchAcc.setForeground(Color.white); 1206 | f.add(btnSearchAcc); 1207 | 1208 | // function to be executed when Search Account button is clicked 1209 | btnSearchAcc.addActionListener(new ActionListener () { 1210 | public void actionPerformed(ActionEvent e) { 1211 | frame.remove(f); 1212 | frame.repaint(); 1213 | frame.validate(); 1214 | searchAccount(frame, manager); 1215 | } 1216 | }); 1217 | 1218 | 1219 | // Manage Card Button 1220 | JButton btnManageCard = new JButton("Manage Credit/Debit Card"); 1221 | btnManageCard.setBounds(300,250,200, 40); 1222 | btnManageCard.setBackground( new Color(0, 204, 153) ); 1223 | btnManageCard.setForeground(Color.white); 1224 | f.add(btnManageCard); 1225 | 1226 | btnManageCard.addActionListener(new ActionListener () { 1227 | public void actionPerformed(ActionEvent e) { 1228 | open_manage_card_page(frame, manager); 1229 | } 1230 | }); 1231 | 1232 | // Update Client Info Button 1233 | JButton btnUpdateInfo = new JButton("Update Client Info"); 1234 | btnUpdateInfo.setBounds(100,320,150, 40); 1235 | btnUpdateInfo.setBackground( new Color(0, 204, 153) ); 1236 | btnUpdateInfo.setForeground(Color.white); 1237 | f.add(btnUpdateInfo); 1238 | 1239 | // function to be executed when Update Info Button is clicked 1240 | btnUpdateInfo.addActionListener( new ActionListener() { 1241 | public void actionPerformed(ActionEvent e) { 1242 | frame.remove(f); 1243 | frame.repaint(); 1244 | frame.validate(); 1245 | updateClientInfo(frame, manager); 1246 | } 1247 | }); 1248 | 1249 | 1250 | 1251 | f.setLayout(null); 1252 | frame.setContentPane(f); 1253 | frame.setVisible(true); 1254 | } 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | // screen to create a new account 1261 | public void openCreateAccountForm(JFrame frame, Manager manager) { 1262 | JPanel f = new JPanel(); 1263 | f.setBackground(Color.white); 1264 | 1265 | // Create Account Label 1266 | JLabel l_hcreate = new JLabel("Create Account"); 1267 | l_hcreate.setFont( l_hcreate.getFont().deriveFont(30f) ); 1268 | l_hcreate.setBounds(300,40,300, 40); 1269 | f.add(l_hcreate); 1270 | 1271 | // Account Fields Labels 1272 | JLabel l_fName = new JLabel("First Name: "); 1273 | l_fName.setBounds(100,100,100, 40); 1274 | f.add(l_fName); 1275 | JLabel l_lName = new JLabel("Last Name: "); 1276 | l_lName.setBounds(400,100,100, 40); 1277 | f.add(l_lName); 1278 | JLabel l_fatherName = new JLabel("Father Name: "); 1279 | l_fatherName.setBounds(100,150,100, 40); 1280 | f.add(l_fatherName); 1281 | JLabel l_motherName = new JLabel("Mother Name: "); 1282 | l_motherName.setBounds(400,150,100, 40); 1283 | f.add(l_motherName); 1284 | JLabel l_cnic = new JLabel("CNIC: "); 1285 | l_cnic.setBounds(100,200,100, 40); 1286 | f.add(l_cnic); 1287 | JLabel l_dob = new JLabel("Date of Birth: "); 1288 | l_dob.setBounds(400,200,100, 40); 1289 | f.add(l_dob); 1290 | JLabel l_phone = new JLabel("Phone: "); 1291 | l_phone.setBounds(100,250,100, 40); 1292 | f.add(l_phone); 1293 | JLabel l_email = new JLabel("Email: "); 1294 | l_email.setBounds(400,250,100, 40); 1295 | f.add(l_email); 1296 | JLabel l_address = new JLabel("Address: "); 1297 | l_address.setBounds(100,300,100, 40); 1298 | f.add(l_address); 1299 | JLabel l_acc_type = new JLabel("Account Type: "); 1300 | l_acc_type.setBounds(400,300,100, 40); 1301 | f.add(l_acc_type); 1302 | 1303 | // Account Text Fields 1304 | JTextField tf_fName = new JTextField(); 1305 | tf_fName.setBounds(200,100,180, 25); 1306 | f.add(tf_fName); 1307 | JTextField tf_lName = new JTextField(); 1308 | tf_lName.setBounds(500,100,180, 25); 1309 | f.add(tf_lName); 1310 | JTextField tf_fatherName = new JTextField(); 1311 | tf_fatherName.setBounds(200,150,180, 25); 1312 | f.add(tf_fatherName); 1313 | JTextField tf_motherName = new JTextField(); 1314 | tf_motherName.setBounds(500,150,180, 25); 1315 | f.add(tf_motherName); 1316 | JTextField tf_cnic = new JTextField(); 1317 | tf_cnic.setBounds(200,200,180, 25); 1318 | f.add(tf_cnic); 1319 | JTextField tf_dob = new JTextField(); 1320 | tf_dob.setBounds(500,200,180, 25); 1321 | f.add(tf_dob); 1322 | JTextField tf_phone = new JTextField(); 1323 | tf_phone.setBounds(200,250,180, 25); 1324 | f.add(tf_phone); 1325 | JTextField tf_email = new JTextField(); 1326 | tf_email.setBounds(500,250,180, 25); 1327 | f.add(tf_email); 1328 | JTextField tf_address = new JTextField(); 1329 | tf_address.setBounds(200,300,180, 25); 1330 | f.add(tf_address); 1331 | 1332 | // Account Type 1333 | String[] types = {"Current", "Saving" }; 1334 | JComboBox jcb_types = new JComboBox(types); 1335 | jcb_types.setBounds(500,300,180, 25); 1336 | f.add(jcb_types); 1337 | 1338 | // Create Button 1339 | JButton btn_create = new JButton("Create"); 1340 | btn_create.setBackground( new Color(0, 204, 153) ); 1341 | btn_create.setForeground(Color.white); 1342 | btn_create.setBounds(350,365,100, 40); 1343 | f.add(btn_create); 1344 | 1345 | // function to be executed when Create Button is clicked 1346 | btn_create.addActionListener( new ActionListener() { 1347 | public void actionPerformed(ActionEvent e) { 1348 | Client newClient = new Client( "", 1349 | tf_fName.getText(), tf_lName.getText(), tf_fatherName.getText(), tf_motherName.getText(), 1350 | tf_cnic.getText(), tf_dob.getText(), tf_phone.getText(), tf_email.getText(), 1351 | tf_address.getText() 1352 | ); 1353 | int res = manager.createAccount(newClient, jcb_types.getSelectedItem().toString()); 1354 | if( res == 1 ) { 1355 | String id_ = manager.getAccNum( tf_cnic.getText() ); 1356 | String msg = "Account created"; 1357 | if( id_.compareTo("") != 0 ) 1358 | msg += " with Account Number: "+id_; 1359 | JOptionPane.showMessageDialog(f, msg); 1360 | frame.remove(f); 1361 | frame.repaint(); 1362 | frame.validate(); 1363 | openManagerMenu(frame, manager); 1364 | } 1365 | else if( res == 2 ) 1366 | JOptionPane.showMessageDialog(f, "Another account with this CNIC number exists"); 1367 | else 1368 | JOptionPane.showMessageDialog(f, "Account creation failed"); 1369 | } 1370 | }); 1371 | 1372 | // Main Menu Button 1373 | JButton btn_mm = new JButton("Main Menu"); 1374 | btn_mm.setBackground( new Color(0, 204, 153) ); 1375 | btn_mm.setForeground(Color.white); 1376 | btn_mm.setBounds(50,400,100, 30); 1377 | f.add(btn_mm); 1378 | 1379 | // function to be executed when Main Menu Button is clicked 1380 | btn_mm.addActionListener( new ActionListener() { 1381 | public void actionPerformed(ActionEvent e) { 1382 | frame.remove(f); 1383 | frame.repaint(); 1384 | frame.validate(); 1385 | openManagerMenu(frame, manager); 1386 | } 1387 | }); 1388 | 1389 | // Sign Out Button 1390 | JButton btn_sign_out = new JButton("Sign Out"); 1391 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1392 | btn_sign_out.setForeground(Color.white); 1393 | btn_sign_out.setBounds(650,30,100, 30); 1394 | f.add(btn_sign_out); 1395 | 1396 | // function to be executed when Sign Out Button is clicked 1397 | btn_sign_out.addActionListener(new ActionListener() { 1398 | public void actionPerformed(ActionEvent e) { 1399 | frame.remove(f); 1400 | frame.repaint(); 1401 | frame.validate(); 1402 | Login_Account user = new Login_Account(); 1403 | openSignInForm(frame, user); 1404 | } 1405 | }); 1406 | 1407 | f.setLayout(null); 1408 | frame.setContentPane(f); 1409 | frame.setVisible(true); 1410 | } 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | // manage card page 1417 | void open_manage_card_page(JFrame frame, Manager manager) 1418 | { 1419 | JPanel f = new JPanel(); 1420 | f.setBackground(Color.white); 1421 | remakeScreen(frame, f); 1422 | 1423 | // Manage Credit/Debit Card Label 1424 | JLabel lcard = new JLabel("Manage Credit/Debit Card"); 1425 | lcard.setFont( lcard.getFont().deriveFont(30f) ); 1426 | lcard.setBounds(200,40,400, 40); 1427 | f.add(lcard); 1428 | 1429 | // Account Holder Name 1430 | JLabel l_acc_num = new JLabel("Enter Account Number"); 1431 | l_acc_num.setBounds(400, 90, 150, 90); 1432 | f.add(l_acc_num); 1433 | JTextField tf_acc_num = new JTextField(); 1434 | tf_acc_num.setBounds(400, 150 ,200, 25); 1435 | f.add(tf_acc_num); 1436 | 1437 | // Account Type 1438 | JLabel l_card_no = new JLabel("Enter Card Number"); 1439 | l_card_no.setBounds(400, 180, 150, 90); 1440 | f.add(l_card_no); 1441 | JTextField tf_card_no = new JTextField(); 1442 | tf_card_no.setBounds(400, 240 ,200, 25); 1443 | f.add(tf_card_no); 1444 | 1445 | // Account Opening Date 1446 | JLabel l_cnic = new JLabel("Enter CNIC of account holder"); 1447 | l_cnic.setBounds(400, 270, 200, 90); 1448 | f.add(l_cnic); 1449 | JTextField tf_cnic = new JTextField(); 1450 | tf_cnic.setBounds(400, 330 ,200, 25); 1451 | f.add(tf_cnic); 1452 | 1453 | //-----------------------------------------------Buttons---------------------------------------------------- 1454 | JButton btn_block_card = new JButton("Block Credit/Debit Card"); 1455 | btn_block_card.setBackground( new Color(0, 204, 153) ); 1456 | btn_block_card.setForeground(Color.white); 1457 | btn_block_card.setBounds(100,120,200, 35); 1458 | f.add(btn_block_card); 1459 | 1460 | JButton btn_unblock_card = new JButton("Unblock Credit/Debit Card"); 1461 | btn_unblock_card.setBackground( new Color(0, 204, 153) ); 1462 | btn_unblock_card.setForeground(Color.white); 1463 | btn_unblock_card.setBounds(100,170,200,35); 1464 | f.add(btn_unblock_card); 1465 | 1466 | // Sign Out Button 1467 | JButton btn_sign_out = new JButton("Sign Out"); 1468 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1469 | btn_sign_out.setForeground(Color.white); 1470 | btn_sign_out.setBounds(650,30,100, 30); 1471 | f.add(btn_sign_out); 1472 | 1473 | // function to be executed when Sign Out Button is clicked 1474 | btn_sign_out.addActionListener(new ActionListener() { 1475 | public void actionPerformed(ActionEvent e) { 1476 | frame.remove(f); 1477 | frame.repaint(); 1478 | frame.validate(); 1479 | Login_Account user = new Login_Account(); 1480 | openSignInForm(frame, user); 1481 | } 1482 | }); 1483 | 1484 | // Main Menu Button 1485 | JButton btn_mm = new JButton("Main Menu"); 1486 | btn_mm.setBackground( new Color(0, 204, 153) ); 1487 | btn_mm.setForeground(Color.white); 1488 | btn_mm.setBounds(50,400,100, 30); 1489 | f.add(btn_mm); 1490 | 1491 | // function to be executed when Main Menu Button is clicked 1492 | btn_mm.addActionListener( new ActionListener() { 1493 | public void actionPerformed(ActionEvent e) { 1494 | frame.remove(f); 1495 | frame.repaint(); 1496 | frame.validate(); 1497 | openManagerMenu(frame, manager); 1498 | } 1499 | }); 1500 | 1501 | // function to be executed when Block Card Button is clicked 1502 | btn_block_card.addActionListener(new ActionListener () { 1503 | public void actionPerformed(ActionEvent e) { 1504 | 1505 | 1506 | int block_status = manager.block_card(Integer.parseInt(tf_acc_num.getText()), tf_cnic.getText(), tf_card_no.getText()); 1507 | 1508 | if (block_status == -1) 1509 | { 1510 | JOptionPane.showMessageDialog(f, "No account found with these details"); 1511 | frame.remove(f); 1512 | frame.repaint(); 1513 | frame.validate(); 1514 | open_manage_card_page(frame, manager); 1515 | } 1516 | else if (block_status == -2) 1517 | { 1518 | JOptionPane.showMessageDialog(f, "No card found with these details"); 1519 | frame.remove(f); 1520 | frame.repaint(); 1521 | frame.validate(); 1522 | open_manage_card_page(frame, manager); 1523 | } 1524 | else if (block_status == -3) 1525 | { 1526 | JOptionPane.showMessageDialog(f, "This card is already blocked"); 1527 | frame.remove(f); 1528 | frame.repaint(); 1529 | frame.validate(); 1530 | open_manage_card_page(frame, manager); 1531 | } 1532 | else 1533 | { 1534 | JOptionPane.showMessageDialog(f, "The selected card has been successfully blocked"); 1535 | frame.remove(f); 1536 | frame.repaint(); 1537 | frame.validate(); 1538 | openManagerMenu(frame, manager); 1539 | } 1540 | } 1541 | }); 1542 | 1543 | 1544 | // function to be executed when Unblock Card Button is clicked 1545 | btn_unblock_card.addActionListener(new ActionListener () { 1546 | public void actionPerformed(ActionEvent e) { 1547 | 1548 | int unblock_status = manager.unblock_card(Integer.parseInt(tf_acc_num.getText()), tf_cnic.getText(), tf_card_no.getText()); 1549 | if (unblock_status == -1) 1550 | { 1551 | JOptionPane.showMessageDialog(f, "No account found with these details"); 1552 | frame.remove(f); 1553 | frame.repaint(); 1554 | frame.validate(); 1555 | open_manage_card_page(frame, manager); 1556 | } 1557 | else if (unblock_status == -2) 1558 | { 1559 | JOptionPane.showMessageDialog(f, "No card found with these details"); 1560 | frame.remove(f); 1561 | frame.repaint(); 1562 | frame.validate(); 1563 | open_manage_card_page(frame, manager); 1564 | } 1565 | else if (unblock_status == -3) 1566 | { 1567 | JOptionPane.showMessageDialog(f, "This card is already active and working"); 1568 | frame.remove(f); 1569 | frame.repaint(); 1570 | frame.validate(); 1571 | open_manage_card_page(frame, manager); 1572 | } 1573 | else 1574 | { 1575 | JOptionPane.showMessageDialog(f, "The selected card has been successfully unblocked"); 1576 | frame.remove(f); 1577 | frame.repaint(); 1578 | frame.validate(); 1579 | openManagerMenu(frame, manager); 1580 | } 1581 | } 1582 | }); 1583 | } 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | // block unblock account screen 1590 | void open_block_unblock_account_page(JFrame frame, Manager manager) 1591 | { 1592 | //--------------------------------Clearing screen for new page--------------------------------------- 1593 | JPanel f = new JPanel(); 1594 | f.setBackground(Color.white); 1595 | remakeScreen(frame, f); 1596 | 1597 | // Block Unblock Account Label 1598 | JLabel lBUAcc = new JLabel("Block/Unblock Account"); 1599 | lBUAcc.setFont( lBUAcc.getFont().deriveFont(30f) ); 1600 | lBUAcc.setBounds(200,40,400, 40); 1601 | f.add(lBUAcc); 1602 | 1603 | //----------------------------------Creating Labels----------------------------------------------------- 1604 | JLabel l_account_no = new JLabel("Enter Account No:"); 1605 | l_account_no.setBounds(200,110,150, 90); 1606 | f.add(l_account_no); 1607 | 1608 | JLabel l_cnic = new JLabel("Enter CNIC:"); 1609 | l_cnic.setBounds(200, 170, 100, 90); 1610 | f.add(l_cnic); 1611 | 1612 | //-----------------------------------Creating Textfields----------------------------------------------- 1613 | JTextField tf_account_no = new JTextField(); 1614 | tf_account_no.setBounds(400, 140 ,200, 25); 1615 | f.add(tf_account_no); 1616 | 1617 | JTextField tf_cnic = new JTextField(); 1618 | tf_cnic.setBounds(400,200,200, 25); 1619 | f.add(tf_cnic); 1620 | 1621 | //------------------------------------Creating buttons--------------------------------------------------- 1622 | JButton btn_block_account = new JButton("Block Account"); 1623 | btn_block_account.setBackground( new Color(0, 204, 153) ); 1624 | btn_block_account.setForeground(Color.white); 1625 | btn_block_account.setBounds(300,270,150, 40); 1626 | f.add(btn_block_account); 1627 | 1628 | JButton btn_unblock_account = new JButton("UnBlock Account"); 1629 | btn_unblock_account.setBackground( new Color(0, 204, 153) ); 1630 | btn_unblock_account.setForeground(Color.white); 1631 | btn_unblock_account.setBounds(300,320,150,40); 1632 | f.add(btn_unblock_account); 1633 | 1634 | // function to be executed when Block Account Button is clicked 1635 | btn_block_account.addActionListener(new ActionListener() { 1636 | public void actionPerformed(ActionEvent e) { 1637 | //System.out.println("Request received of blocking account with acc num:"+acc_num+" and cnic:"+cnic); 1638 | 1639 | int block_status = manager.block_account( Integer.parseInt(tf_account_no.getText()), tf_cnic.getText() ); 1640 | 1641 | if ( block_status == -1 ) 1642 | { 1643 | JOptionPane.showMessageDialog(f, "Your entered credentials do not match with any account"); 1644 | } 1645 | else if (block_status == -2) 1646 | { 1647 | JOptionPane.showMessageDialog(f, "There is no active account with these details"); 1648 | } 1649 | else if (block_status == -3) 1650 | { 1651 | JOptionPane.showMessageDialog(f, "Your entered account is already blocked"); 1652 | } 1653 | else 1654 | { 1655 | JOptionPane.showMessageDialog(f, "The selected account has been successfully blocked"); 1656 | frame.remove(f); 1657 | frame.repaint(); 1658 | frame.validate(); 1659 | openManagerMenu(frame, manager); 1660 | } 1661 | } 1662 | }); 1663 | 1664 | // function to be executed when Unblock Account Button is clicked 1665 | btn_unblock_account.addActionListener(new ActionListener() { 1666 | public void actionPerformed(ActionEvent e) { 1667 | 1668 | int unblock_status = manager.unblock_account( Integer.parseInt(tf_account_no.getText()), tf_cnic.getText() ); 1669 | 1670 | if ( unblock_status == -1) 1671 | { 1672 | JOptionPane.showMessageDialog(f, "Your entered credentials do not match with any account"); 1673 | } 1674 | else if ( unblock_status == -2) 1675 | { 1676 | JOptionPane.showMessageDialog(f, "There is no active account with these details"); 1677 | } 1678 | else if (unblock_status == -3) 1679 | { 1680 | JOptionPane.showMessageDialog(f, "Your entered account is already active and working"); 1681 | } 1682 | else 1683 | { 1684 | JOptionPane.showMessageDialog(f, "The selected account has been successfully unblocked"); 1685 | frame.remove(f); 1686 | frame.repaint(); 1687 | frame.validate(); 1688 | openManagerMenu(frame, manager); 1689 | } 1690 | } 1691 | }); 1692 | 1693 | // Main Menu Button 1694 | JButton btn_mm = new JButton("Main Menu"); 1695 | btn_mm.setBackground( new Color(0, 204, 153) ); 1696 | btn_mm.setForeground(Color.white); 1697 | btn_mm.setBounds(50,400,100, 30); 1698 | f.add(btn_mm); 1699 | 1700 | // function to be executed when Main Menu Button is clicked 1701 | btn_mm.addActionListener( new ActionListener() { 1702 | public void actionPerformed(ActionEvent e) { 1703 | frame.remove(f); 1704 | frame.repaint(); 1705 | frame.validate(); 1706 | openManagerMenu(frame, manager); 1707 | } 1708 | }); 1709 | 1710 | // Sign Out Button 1711 | JButton btn_sign_out = new JButton("Sign Out"); 1712 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1713 | btn_sign_out.setForeground(Color.white); 1714 | btn_sign_out.setBounds(650,30,100, 30); 1715 | f.add(btn_sign_out); 1716 | 1717 | // function to be executed when Sign Out Button is clicked 1718 | btn_sign_out.addActionListener(new ActionListener() { 1719 | public void actionPerformed(ActionEvent e) { 1720 | frame.remove(f); 1721 | frame.repaint(); 1722 | frame.validate(); 1723 | Login_Account user = new Login_Account(); 1724 | openSignInForm(frame, user); 1725 | } 1726 | }); 1727 | } 1728 | 1729 | 1730 | // close account screen 1731 | void open_close_account_page(JFrame frame, Manager manager) 1732 | { 1733 | //--------------------------------Clearing screen for new page--------------------------------------- 1734 | JPanel f = new JPanel(); 1735 | f.setBackground(Color.white); 1736 | remakeScreen(frame, f); 1737 | 1738 | // Close Account Label 1739 | JLabel lCloseAcc = new JLabel("Close Account"); 1740 | lCloseAcc.setFont( lCloseAcc.getFont().deriveFont(30f) ); 1741 | lCloseAcc.setBounds(300,40,400, 40); 1742 | f.add(lCloseAcc); 1743 | 1744 | //----------------------------------Creating Labels----------------------------------------------------- 1745 | JLabel l_account_no = new JLabel("Enter Account No:"); 1746 | l_account_no.setBounds(220,110,150, 90); 1747 | f.add(l_account_no); 1748 | 1749 | JLabel l_cnic = new JLabel("Enter CNIC:"); 1750 | l_cnic.setBounds(220, 170, 100, 90); 1751 | f.add(l_cnic); 1752 | 1753 | //-----------------------------------Creating Textfields----------------------------------------------- 1754 | JTextField tf_account_no = new JTextField(); 1755 | tf_account_no.setBounds(400, 140 ,200, 25); 1756 | f.add(tf_account_no); 1757 | 1758 | JTextField tf_cnic = new JTextField(); 1759 | tf_cnic.setBounds(400,200,200, 25); 1760 | f.add(tf_cnic); 1761 | 1762 | //------------------------------------Creating buttons--------------------------------------------------- 1763 | JButton btn_close_account = new JButton("Close Account"); 1764 | btn_close_account.setBackground( new Color(0, 204, 153) ); 1765 | btn_close_account.setForeground(Color.white); 1766 | btn_close_account.setBounds(300,280,150, 40); 1767 | f.add(btn_close_account); 1768 | 1769 | // function to be executed when close account button is clicked 1770 | btn_close_account.addActionListener(new ActionListener() { 1771 | public void actionPerformed(ActionEvent e) { 1772 | 1773 | int close_status = manager.close_account(tf_account_no.getText(), tf_cnic.getText()); 1774 | 1775 | if ( close_status == 0 ) 1776 | { 1777 | JOptionPane.showMessageDialog(f, "Your account has been successfully closed"); 1778 | openManagerMenu(frame, manager); 1779 | } 1780 | else 1781 | { 1782 | JOptionPane.showMessageDialog(f, "Your entered deatils do not match with any account"); 1783 | openManagerMenu(frame, manager); 1784 | } 1785 | } 1786 | }); 1787 | 1788 | // Main Menu Button 1789 | JButton btn_mm = new JButton("Main Menu"); 1790 | btn_mm.setBackground( new Color(0, 204, 153) ); 1791 | btn_mm.setForeground(Color.white); 1792 | btn_mm.setBounds(50,400,100, 30); 1793 | f.add(btn_mm); 1794 | 1795 | // function to be executed when Main Menu Button is clicked 1796 | btn_mm.addActionListener( new ActionListener() { 1797 | public void actionPerformed(ActionEvent e) { 1798 | frame.remove(f); 1799 | frame.repaint(); 1800 | frame.validate(); 1801 | openManagerMenu(frame, manager); 1802 | } 1803 | }); 1804 | 1805 | // Sign Out Button 1806 | JButton btn_sign_out = new JButton("Sign Out"); 1807 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1808 | btn_sign_out.setForeground(Color.white); 1809 | btn_sign_out.setBounds(650,30,100, 30); 1810 | f.add(btn_sign_out); 1811 | 1812 | // function to be executed when Sign Out Button is clicked 1813 | btn_sign_out.addActionListener(new ActionListener() { 1814 | public void actionPerformed(ActionEvent e) { 1815 | frame.remove(f); 1816 | frame.repaint(); 1817 | frame.validate(); 1818 | Login_Account user = new Login_Account(); 1819 | openSignInForm(frame, user); 1820 | } 1821 | }); 1822 | } 1823 | 1824 | 1825 | 1826 | 1827 | 1828 | 1829 | // In this screen manager will enter the client's account number and cnic number for search 1830 | void searchAccount(JFrame frame, Manager manager) { 1831 | JPanel f = new JPanel(); 1832 | f.setBackground(Color.white); 1833 | 1834 | // Search Account Label 1835 | JLabel lSearch = new JLabel("Search Account"); 1836 | lSearch.setFont( lSearch.getFont().deriveFont(30f) ); 1837 | lSearch.setBounds(150,50,250, 40); 1838 | f.add(lSearch); 1839 | 1840 | // Account Number Label 1841 | JLabel lAccNum = new JLabel("Enter account number:"); 1842 | lAccNum.setBounds(150,100,150, 40); 1843 | f.add(lAccNum); 1844 | 1845 | // Account Number Text Field 1846 | JTextField tfAccNum = new JTextField(); 1847 | tfAccNum.setBounds(150,140,180, 25); 1848 | f.add(tfAccNum); 1849 | 1850 | // Client Info Fields 1851 | // Client Name Label 1852 | JLabel lCName = new JLabel("Name: "); 1853 | lCName.setBounds(150,170,250, 40); 1854 | lCName.setVisible(false); 1855 | f.add(lCName); 1856 | 1857 | // Client CNIC 1858 | JLabel lCCNIC = new JLabel("CNIC: "); 1859 | lCCNIC.setBounds(150,200,250, 40); 1860 | lCCNIC.setVisible(false); 1861 | f.add(lCCNIC); 1862 | 1863 | // Client Account Number 1864 | JLabel lCAccNum = new JLabel("Account No: "); 1865 | lCAccNum.setBounds(150,230,250, 40); 1866 | lCAccNum.setVisible(false); 1867 | f.add(lCAccNum); 1868 | 1869 | // Client Account Type 1870 | JLabel lCAccType = new JLabel("Account Type: "); 1871 | lCAccType.setBounds(150,260,250, 40); 1872 | lCAccType.setVisible(false); 1873 | f.add(lCAccType); 1874 | 1875 | // Client Account Balance 1876 | JLabel lCAccBalance = new JLabel("Balance: "); 1877 | lCAccBalance.setBounds(150,290,250, 40); 1878 | lCAccBalance.setVisible(false); 1879 | f.add(lCAccBalance); 1880 | 1881 | // Client Account Status 1882 | JLabel lCAccStatus = new JLabel("Status: "); 1883 | lCAccStatus.setBounds(150,320,250, 40); 1884 | lCAccStatus.setVisible(false); 1885 | f.add(lCAccStatus); 1886 | 1887 | // Client Account Opening Date 1888 | JLabel lCAccODate = new JLabel("Opening Date: "); 1889 | lCAccODate.setBounds(150,350,250, 40); 1890 | lCAccODate.setVisible(false); 1891 | f.add(lCAccODate); 1892 | 1893 | 1894 | // Search Account Button 1895 | JButton btnSearch = new JButton("Search"); 1896 | btnSearch.setBackground( new Color(0, 204, 153) ); 1897 | btnSearch.setForeground(Color.white); 1898 | btnSearch.setBounds(350,130,110, 40); 1899 | f.add(btnSearch); 1900 | 1901 | // function to execute with clicked on Search Button 1902 | btnSearch.addActionListener( new ActionListener() { 1903 | public void actionPerformed(ActionEvent e) { 1904 | Bank_Account account = manager.getAccountInfo( tfAccNum.getText() ); 1905 | Client client = manager.getClientInfo( tfAccNum.getText() ); 1906 | 1907 | // check if either account or client was not found 1908 | if( (account.getAccountNum().compareTo("") == 0) || (client.getCNIC().compareTo("") == 0 ) ) { 1909 | 1910 | lCName.setVisible(false); 1911 | lCCNIC.setVisible(false); 1912 | lCAccNum.setVisible(false); 1913 | lCAccType.setVisible(false); 1914 | lCAccBalance.setVisible(false); 1915 | lCAccStatus.setVisible(false); 1916 | lCAccODate.setVisible(false); 1917 | 1918 | // display a message box that account was not found 1919 | if(account.getAccountNum().compareTo("") == 0) { 1920 | JOptionPane.showMessageDialog(f, "Account not found"); 1921 | } 1922 | 1923 | // display a message box that client was not found 1924 | else if (client.getCNIC().compareTo("") == 0 ) { 1925 | JOptionPane.showMessageDialog(f, "Client not found"); 1926 | } 1927 | account = null; 1928 | client = null; 1929 | } 1930 | 1931 | // Both client and his account was found 1932 | else { 1933 | 1934 | lCName.setText("Name: "+client.getFName()+" "+client.getLName() ); 1935 | lCCNIC.setText("CNIC: "+client.getCNIC() ); 1936 | lCAccNum.setText("Account No: "+account.getAccountNum() ); 1937 | lCAccType.setText("Account Type: "+account.getType() ); 1938 | lCAccBalance.setText("Balance: "+account.getBalance() ); 1939 | String temp = "Open"; 1940 | if( Integer.valueOf( account.getStatus() ) == 0 ) 1941 | temp = "Close"; 1942 | else if( Integer.valueOf( account.getStatus() ) == 2 ) 1943 | temp = "Block"; 1944 | lCAccStatus.setText("Status: "+ temp ); 1945 | lCAccODate.setText("Opening Date: "+account.getOpeningDate() ); 1946 | 1947 | lCName.setVisible(true); 1948 | lCCNIC.setVisible(true); 1949 | lCAccNum.setVisible(true); 1950 | lCAccType.setVisible(true); 1951 | lCAccBalance.setVisible(true); 1952 | lCAccStatus.setVisible(true); 1953 | lCAccODate.setVisible(true); 1954 | } 1955 | } 1956 | }); 1957 | 1958 | // Main Menu Button 1959 | JButton btn_mm = new JButton("Main Menu"); 1960 | btn_mm.setBackground( new Color(0, 204, 153) ); 1961 | btn_mm.setForeground(Color.white); 1962 | btn_mm.setBounds(50,400,100, 30); 1963 | f.add(btn_mm); 1964 | 1965 | // function to be executed when Main Menu Button is clicked 1966 | btn_mm.addActionListener( new ActionListener() { 1967 | public void actionPerformed(ActionEvent e) { 1968 | frame.remove(f); 1969 | frame.repaint(); 1970 | frame.validate(); 1971 | openManagerMenu(frame, manager); 1972 | } 1973 | }); 1974 | 1975 | // Sign Out Button 1976 | JButton btn_sign_out = new JButton("Sign Out"); 1977 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 1978 | btn_sign_out.setForeground(Color.white); 1979 | btn_sign_out.setBounds(650,30,100, 30); 1980 | f.add(btn_sign_out); 1981 | 1982 | // function to be executed when Sign Out Button is clicked 1983 | btn_sign_out.addActionListener(new ActionListener() { 1984 | public void actionPerformed(ActionEvent e) { 1985 | frame.remove(f); 1986 | frame.repaint(); 1987 | frame.validate(); 1988 | Login_Account user = new Login_Account(); 1989 | openSignInForm(frame, user); 1990 | } 1991 | }); 1992 | 1993 | // displaying the new panel on frame 1994 | f.setLayout(null); 1995 | frame.setContentPane(f); 1996 | frame.setVisible(true); 1997 | } 1998 | 1999 | 2000 | 2001 | 2002 | 2003 | // In this screen manager will enter the client's account number and cnic number for search 2004 | void updateClientInfo(JFrame frame, Manager manager) { 2005 | JPanel f = new JPanel(); 2006 | f.setBackground(Color.white); 2007 | 2008 | // Update Client Info Label 2009 | JLabel lUCInfo = new JLabel("Update Client Info"); 2010 | lUCInfo.setFont( lUCInfo.getFont().deriveFont(30f) ); 2011 | lUCInfo.setBounds(150,50,300, 40); 2012 | f.add(lUCInfo); 2013 | 2014 | // Account Number Label 2015 | JLabel lAccNum = new JLabel("Enter account number:"); 2016 | lAccNum.setBounds(150,100,150, 40); 2017 | f.add(lAccNum); 2018 | 2019 | // Account Number Text Field 2020 | JTextField tfAccNum = new JTextField(); 2021 | tfAccNum.setBounds(150,140,180, 25); 2022 | f.add(tfAccNum); 2023 | 2024 | // Client Info Fields 2025 | // Client Name Label 2026 | JLabel lCName = new JLabel("Name: "); 2027 | lCName.setBounds(150,170,250, 40); 2028 | lCName.setVisible(false); 2029 | f.add(lCName); 2030 | JLabel lCid = new JLabel(""); 2031 | lCid.setBounds(450,170,100, 40); 2032 | lCid.setVisible(false); 2033 | f.add(lCid); 2034 | 2035 | // Client CNIC 2036 | JLabel lCCNIC = new JLabel("CNIC: "); 2037 | lCCNIC.setBounds(150,200,250, 40); 2038 | lCCNIC.setVisible(false); 2039 | f.add(lCCNIC); 2040 | 2041 | // Client Phone 2042 | JLabel lCPhone = new JLabel("Phone No: "); 2043 | lCPhone.setBounds(150,230,250, 40); 2044 | lCPhone.setVisible(false); 2045 | f.add(lCPhone); 2046 | JTextField tfPhone = new JTextField(); 2047 | tfPhone.setBounds(250,240,180, 25); 2048 | tfPhone.setVisible(false); 2049 | f.add(tfPhone); 2050 | 2051 | // Client Email 2052 | JLabel lCEmail = new JLabel("Account Type: "); 2053 | lCEmail.setBounds(150,260,250, 40); 2054 | lCEmail.setVisible(false); 2055 | f.add(lCEmail); 2056 | JTextField tfEmail = new JTextField(); 2057 | tfEmail.setBounds(250,270,180, 25); 2058 | tfEmail.setVisible(false); 2059 | f.add(tfEmail); 2060 | 2061 | // Client Address 2062 | JLabel lCAddress = new JLabel("Address: "); 2063 | lCAddress.setBounds(150,290,250, 40); 2064 | lCAddress.setVisible(false); 2065 | f.add(lCAddress); 2066 | JTextField tfAddress = new JTextField(); 2067 | tfAddress.setBounds(250,300,180, 25); 2068 | tfAddress.setVisible(false); 2069 | f.add(tfAddress); 2070 | 2071 | // Search Account Button 2072 | JButton btnSearch = new JButton("Search"); 2073 | btnSearch.setBackground( new Color(0, 204, 153) ); 2074 | btnSearch.setForeground(Color.white); 2075 | btnSearch.setBounds(350,130,110, 40); 2076 | f.add(btnSearch); 2077 | 2078 | // Update Button 2079 | JButton btnUpdate = new JButton("Update"); 2080 | btnUpdate.setBackground( new Color(0, 204, 153) ); 2081 | btnUpdate.setForeground(Color.white); 2082 | btnUpdate.setBounds(150,330,110, 40); 2083 | btnUpdate.setVisible(false); 2084 | f.add(btnUpdate); 2085 | 2086 | // function to execute with clicked on Search Button 2087 | btnSearch.addActionListener( new ActionListener() { 2088 | public void actionPerformed(ActionEvent e) { 2089 | Bank_Account account = manager.getAccountInfo( tfAccNum.getText() ); 2090 | Client client = manager.getClientInfo( tfAccNum.getText() ); 2091 | 2092 | // check if either account or client was not found 2093 | if( (account.getAccountNum().compareTo("") == 0) || (client.getCNIC().compareTo("") == 0 ) ) { 2094 | 2095 | lCName.setVisible(false); 2096 | lCCNIC.setVisible(false); 2097 | lCPhone.setVisible(false); 2098 | lCEmail.setVisible(false); 2099 | lCAddress.setVisible(false); 2100 | tfPhone.setVisible(false); 2101 | tfEmail.setVisible(false); 2102 | tfAddress.setVisible(false); 2103 | btnUpdate.setVisible(false); 2104 | 2105 | // display a message box that account was not found 2106 | if(account.getAccountNum().compareTo("") == 0) { 2107 | JOptionPane.showMessageDialog(f, "Account not found"); 2108 | } 2109 | 2110 | // display a message box that client was not found 2111 | else if (client.getCNIC().compareTo("") == 0 ) { 2112 | JOptionPane.showMessageDialog(f, "Client not found"); 2113 | } 2114 | account = null; 2115 | client = null; 2116 | } 2117 | 2118 | // Both client and his account was found 2119 | else { 2120 | 2121 | lCid.setText( client.getClientID() ); 2122 | lCName.setText("Name: "+client.getFName()+" "+client.getLName() ); 2123 | lCCNIC.setText("CNIC: "+client.getCNIC() ); 2124 | tfPhone.setText( client.getPhone() ); 2125 | tfEmail.setText( client.getEmail() ); 2126 | tfAddress.setText( client.getAddress() ); 2127 | 2128 | lCName.setVisible(true); 2129 | lCCNIC.setVisible(true); 2130 | lCPhone.setVisible(true); 2131 | lCEmail.setVisible(true); 2132 | lCAddress.setVisible(true); 2133 | tfPhone.setVisible(true); 2134 | tfEmail.setVisible(true); 2135 | tfAddress.setVisible(true); 2136 | btnUpdate.setVisible(true); 2137 | } 2138 | } 2139 | }); 2140 | 2141 | // this function is executed when Update Button is clicked 2142 | btnUpdate.addActionListener(new ActionListener() { 2143 | public void actionPerformed(ActionEvent e) { 2144 | 2145 | manager.updateClientInfo( lCid.getText(), tfPhone.getText(), tfEmail.getText(), tfAddress.getText() ); 2146 | 2147 | JOptionPane.showMessageDialog(f, "Info Updated"); 2148 | 2149 | frame.remove(f); 2150 | frame.repaint(); 2151 | frame.validate(); 2152 | openManagerMenu(frame, manager); 2153 | } 2154 | }); 2155 | 2156 | // Main Menu Button 2157 | JButton btn_mm = new JButton("Main Menu"); 2158 | btn_mm.setBackground( new Color(0, 204, 153) ); 2159 | btn_mm.setForeground(Color.white); 2160 | btn_mm.setBounds(50,400,100, 30); 2161 | f.add(btn_mm); 2162 | 2163 | // function to be executed when Main Menu Button is clicked 2164 | btn_mm.addActionListener( new ActionListener() { 2165 | public void actionPerformed(ActionEvent e) { 2166 | frame.remove(f); 2167 | frame.repaint(); 2168 | frame.validate(); 2169 | openManagerMenu(frame, manager); 2170 | } 2171 | }); 2172 | 2173 | // Sign Out Button 2174 | JButton btn_sign_out = new JButton("Sign Out"); 2175 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2176 | btn_sign_out.setForeground(Color.white); 2177 | btn_sign_out.setBounds(650,30,100, 30); 2178 | f.add(btn_sign_out); 2179 | 2180 | // function to be executed when Sign Out Button is clicked 2181 | btn_sign_out.addActionListener(new ActionListener() { 2182 | public void actionPerformed(ActionEvent e) { 2183 | frame.remove(f); 2184 | frame.repaint(); 2185 | frame.validate(); 2186 | Login_Account user = new Login_Account(); 2187 | openSignInForm(frame, user); 2188 | } 2189 | }); 2190 | 2191 | // displaying the new panel on frame 2192 | f.setLayout(null); 2193 | frame.setContentPane(f); 2194 | frame.setVisible(true); 2195 | } 2196 | 2197 | 2198 | 2199 | //-------------------------------------------------------- 2200 | // Accountant Related Screens | 2201 | //-------------------------------------------------------- 2202 | 2203 | 2204 | // Accountant Menu 2205 | void openAccountantMenu(JFrame frame, Accountant accountant) { 2206 | JPanel f = new JPanel(); 2207 | f.setBackground(Color.white); 2208 | 2209 | // User Name label 2210 | JLabel lUser = new JLabel( accountant.getName() ); 2211 | lUser.setFont( lUser.getFont().deriveFont(30f) ); 2212 | lUser.setBounds(100,50,300, 40); 2213 | f.add(lUser); 2214 | 2215 | // Designation label 2216 | JLabel lDesg = new JLabel("Accountant"); 2217 | //lDesg.setFont( lDesg.getFont().deriveFont(30f) ); 2218 | lDesg.setBounds(100,80,100, 40); 2219 | f.add(lDesg); 2220 | 2221 | // Deposit Cash button 2222 | JButton btnDeposit = new JButton("Deposit Cash"); 2223 | btnDeposit.setBackground( new Color(0, 204, 153) ); 2224 | btnDeposit.setForeground(Color.white); 2225 | btnDeposit.setBounds(100,180,110, 40); 2226 | f.add(btnDeposit); 2227 | 2228 | // Withdraw Cash button 2229 | JButton btnWithdraw = new JButton("Withdraw Cash"); 2230 | btnWithdraw.setBackground( new Color(0, 204, 153) ); 2231 | btnWithdraw.setForeground(Color.white); 2232 | btnWithdraw.setBounds(300,180,150, 40); 2233 | f.add(btnWithdraw); 2234 | 2235 | // Cheque Deposit button 2236 | JButton btnChequeDeposit = new JButton("Cheque Deposit"); 2237 | btnChequeDeposit.setBackground( new Color(0, 204, 153) ); 2238 | btnChequeDeposit.setForeground(Color.white); 2239 | btnChequeDeposit.setBounds(530,180,150, 40); 2240 | f.add(btnChequeDeposit); 2241 | 2242 | // E-Statement button 2243 | JButton btnEStatement = new JButton("Issue E-Statement"); 2244 | btnEStatement.setBackground( new Color(0, 204, 153) ); 2245 | btnEStatement.setForeground(Color.white); 2246 | btnEStatement.setBounds(300,250,150, 40); 2247 | f.add(btnEStatement); 2248 | 2249 | // function to be executed when Deposit button is clicked 2250 | btnDeposit.addActionListener( new ActionListener() { 2251 | public void actionPerformed(ActionEvent e) { 2252 | frame.remove(f); 2253 | frame.repaint(); 2254 | frame.validate(); 2255 | searchForm(frame, accountant, 1); 2256 | } 2257 | }); 2258 | 2259 | // function to be executed when Withdraw Button is clicked 2260 | btnWithdraw.addActionListener( new ActionListener() { 2261 | public void actionPerformed(ActionEvent e) { 2262 | frame.remove(f); 2263 | frame.repaint(); 2264 | frame.validate(); 2265 | searchForm(frame, accountant, 2); 2266 | } 2267 | }); 2268 | 2269 | // function to be executed when Cheque Deposit Button is clicked 2270 | btnChequeDeposit.addActionListener( new ActionListener() { 2271 | public void actionPerformed(ActionEvent e) { 2272 | frame.remove(f); 2273 | frame.repaint(); 2274 | frame.validate(); 2275 | chequeDeposit(frame, accountant); 2276 | } 2277 | }); 2278 | 2279 | 2280 | // function to be executed when EStatement Button is clicked 2281 | btnEStatement.addActionListener( new ActionListener() { 2282 | public void actionPerformed(ActionEvent e) { 2283 | frame.remove(f); 2284 | frame.repaint(); 2285 | frame.validate(); 2286 | searchForm(frame, accountant, 3); 2287 | } 2288 | }); 2289 | 2290 | // Sign Out Button 2291 | JButton btn_sign_out = new JButton("Sign Out"); 2292 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2293 | btn_sign_out.setForeground(Color.white); 2294 | btn_sign_out.setBounds(650,30,100, 30); 2295 | f.add(btn_sign_out); 2296 | 2297 | // function to be executed when Sign Out Button is clicked 2298 | btn_sign_out.addActionListener(new ActionListener() { 2299 | public void actionPerformed(ActionEvent e) { 2300 | frame.remove(f); 2301 | frame.repaint(); 2302 | frame.validate(); 2303 | Login_Account user = new Login_Account(); 2304 | openSignInForm(frame, user); 2305 | } 2306 | }); 2307 | 2308 | f.setLayout(null); 2309 | frame.setContentPane(f); 2310 | frame.setVisible(true); 2311 | } 2312 | 2313 | 2314 | 2315 | 2316 | 2317 | 2318 | // In this screen accountant will enter the client's account number and cnic number 2319 | // to search him to deposit money 2320 | void searchForm(JFrame frame, Accountant accountant, int case_) { 2321 | JPanel f = new JPanel(); 2322 | f.setBackground(Color.white); 2323 | 2324 | // Deposit Cash Label 2325 | JLabel lheading = new JLabel("Deposit Cash"); 2326 | lheading.setFont( lheading.getFont().deriveFont(30f) ); 2327 | lheading.setBounds(150,50,250, 40); 2328 | f.add(lheading); 2329 | if( case_ == 2 ) 2330 | lheading.setText("Withdraw Cash"); 2331 | else if( case_ == 3 ) 2332 | lheading.setText("E-Statement"); 2333 | 2334 | // Account Number Label 2335 | JLabel lAccNum = new JLabel("Enter account number:"); 2336 | lAccNum.setBounds(150,100,150, 40); 2337 | f.add(lAccNum); 2338 | 2339 | // Account Number Text Field 2340 | JTextField tfAccNum = new JTextField(); 2341 | tfAccNum.setBounds(150,140,180, 25); 2342 | f.add(tfAccNum); 2343 | 2344 | // CNIC Number Label 2345 | JLabel lCnic = new JLabel("Enter CNIC number:"); 2346 | lCnic.setBounds(150,180,150, 40); 2347 | f.add(lCnic); 2348 | 2349 | // CNIC Number Text Field 2350 | JTextField tfCnic = new JTextField(); 2351 | tfCnic.setBounds(150,220,180, 25); 2352 | f.add(tfCnic); 2353 | 2354 | // Search Account Button 2355 | JButton btnSearch = new JButton("Search"); 2356 | btnSearch.setBackground( new Color(0, 204, 153) ); 2357 | btnSearch.setForeground(Color.white); 2358 | btnSearch.setBounds(150,270,110, 40); 2359 | f.add(btnSearch); 2360 | 2361 | // function to execute with clicked on Search Button 2362 | btnSearch.addActionListener( new ActionListener() { 2363 | public void actionPerformed(ActionEvent e) { 2364 | Bank_Account account = accountant.searchAccount1( tfAccNum.getText(), tfCnic.getText() ); 2365 | Client client = accountant.searchClient1( tfAccNum.getText(), tfCnic.getText() ); 2366 | 2367 | // check if either account or client was not found 2368 | if( (account.getAccountNum().compareTo("") == 0) || (client.getCNIC().compareTo("") == 0 ) ) { 2369 | 2370 | // display a message box that account was not found 2371 | if(account.getAccountNum().compareTo("") == 0) { 2372 | JOptionPane.showMessageDialog(f, "Account not found"); 2373 | } 2374 | 2375 | // display a message box that client was not found 2376 | else if (client.getCNIC().compareTo("") == 0 ) { 2377 | JOptionPane.showMessageDialog(f, "Client not found"); 2378 | } 2379 | account = null; 2380 | client = null; 2381 | } 2382 | 2383 | // Both client and his account was found 2384 | else { 2385 | if( Integer.valueOf( account.getStatus() ) == 0 ) { 2386 | JOptionPane.showMessageDialog(f, "Account is closed"); 2387 | } 2388 | else if( Integer.valueOf( account.getStatus() ) == 2 ) { 2389 | JOptionPane.showMessageDialog(f, "Account is blocked"); 2390 | } 2391 | else { 2392 | frame.remove(f); 2393 | frame.repaint(); 2394 | frame.validate(); 2395 | if( case_ == 1 ) 2396 | depositCash(frame, accountant, client, account); 2397 | else if( case_ == 2 ) 2398 | withdrawCash(frame, accountant, client, account); 2399 | else if( case_ == 3 ) 2400 | eStatement(frame, accountant, client, account); 2401 | } 2402 | } 2403 | 2404 | } 2405 | }); 2406 | 2407 | // Main Menu Button 2408 | JButton btn_mm = new JButton("Main Menu"); 2409 | btn_mm.setBackground( new Color(0, 204, 153) ); 2410 | btn_mm.setForeground(Color.white); 2411 | btn_mm.setBounds(50,400,100, 30); 2412 | f.add(btn_mm); 2413 | 2414 | // function to be executed when Main Menu Button is clicked 2415 | btn_mm.addActionListener( new ActionListener() { 2416 | public void actionPerformed(ActionEvent e) { 2417 | frame.remove(f); 2418 | frame.repaint(); 2419 | frame.validate(); 2420 | openAccountantMenu(frame, accountant); 2421 | } 2422 | }); 2423 | 2424 | // Sign Out Button 2425 | JButton btn_sign_out = new JButton("Sign Out"); 2426 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2427 | btn_sign_out.setForeground(Color.white); 2428 | btn_sign_out.setBounds(650,30,100, 30); 2429 | f.add(btn_sign_out); 2430 | 2431 | // function to be executed when Sign Out Button is clicked 2432 | btn_sign_out.addActionListener(new ActionListener() { 2433 | public void actionPerformed(ActionEvent e) { 2434 | frame.remove(f); 2435 | frame.repaint(); 2436 | frame.validate(); 2437 | Login_Account user = new Login_Account(); 2438 | openSignInForm(frame, user); 2439 | } 2440 | }); 2441 | 2442 | // displaying the new panel on frame 2443 | f.setLayout(null); 2444 | frame.setContentPane(f); 2445 | frame.setVisible(true); 2446 | } 2447 | 2448 | 2449 | 2450 | 2451 | 2452 | // deposit case screen 2453 | void depositCash(JFrame frame, Accountant accountant, Client client, Bank_Account account) { 2454 | JPanel f = new JPanel(); 2455 | f.setBackground(Color.white); 2456 | 2457 | // Deposit Cash Label 2458 | JLabel lDeposit = new JLabel("Deposit Cash"); 2459 | lDeposit.setFont( lDeposit.getFont().deriveFont(30f) ); 2460 | lDeposit.setBounds(150,50,250, 40); 2461 | f.add(lDeposit); 2462 | 2463 | // Name Label 2464 | JLabel lName = new JLabel( "Client Name: " + client.getFName() + " " + client.getLName() ); 2465 | lName.setBounds(150,100,350, 40); 2466 | f.add(lName); 2467 | 2468 | // CNIC Label 2469 | JLabel lCnic = new JLabel( "CNIC: " + client.getCNIC() ); 2470 | lCnic.setBounds(150,130,150, 40); 2471 | f.add(lCnic); 2472 | 2473 | // Account Number Label 2474 | JLabel lAccNum = new JLabel( "Account Number: " + account.getAccountNum() ); 2475 | lAccNum.setBounds(150,160,150, 40); 2476 | f.add(lAccNum); 2477 | 2478 | // Name Label 2479 | JLabel lType = new JLabel( "Account Type" + account.getType() ); 2480 | lType.setBounds(150,190,150, 40); 2481 | f.add(lType); 2482 | 2483 | // Amount Label 2484 | JLabel lAmount = new JLabel("Enter amount:"); 2485 | lAmount.setBounds(150,240,150, 40); 2486 | f.add(lAmount); 2487 | 2488 | // Amount Text Field 2489 | JTextField tfAmount = new JTextField(); 2490 | tfAmount.setBounds(150,280,180, 25); 2491 | f.add(tfAmount); 2492 | 2493 | // Deposit Button 2494 | JButton btnDeposit = new JButton("Deposit"); 2495 | btnDeposit.setBackground( new Color(0, 204, 153) ); 2496 | btnDeposit.setForeground(Color.white); 2497 | btnDeposit.setBounds(150,320,100, 30); 2498 | f.add(btnDeposit); 2499 | 2500 | // function to be executed when Deposit Button is clicked 2501 | btnDeposit.addActionListener( new ActionListener() { 2502 | public void actionPerformed(ActionEvent e) { 2503 | 2504 | // check if amount is greater than 0 2505 | if( tfAmount.getText().compareTo("") != 0 ) { 2506 | if( Integer.valueOf( tfAmount.getText()) > 0 ) { 2507 | // add amount to account 2508 | int r = account.addAmount( Integer.valueOf( tfAmount.getText()) ); 2509 | if( r == 1 ) { 2510 | // show deposit successful message 2511 | JOptionPane.showMessageDialog(f, "Amount deposited successfully"); 2512 | } 2513 | else { 2514 | JOptionPane.showMessageDialog(f, "Amount deposit failed"); 2515 | } 2516 | 2517 | // go back to menu of accountant 2518 | frame.remove(f); 2519 | frame.repaint(); 2520 | frame.validate(); 2521 | openAccountantMenu(frame, accountant); 2522 | } 2523 | // invalid amount 2524 | else { 2525 | JOptionPane.showMessageDialog(f, "Invalid Amount"); 2526 | } 2527 | } 2528 | // invalid amount 2529 | else { 2530 | JOptionPane.showMessageDialog(f, "Invalid Amount"); 2531 | } 2532 | } 2533 | }); 2534 | 2535 | // Main Menu Button 2536 | JButton btn_mm = new JButton("Main Menu"); 2537 | btn_mm.setBackground( new Color(0, 204, 153) ); 2538 | btn_mm.setForeground(Color.white); 2539 | btn_mm.setBounds(50,400,100, 30); 2540 | f.add(btn_mm); 2541 | 2542 | // function to be executed when Main Menu Button is clicked 2543 | btn_mm.addActionListener( new ActionListener() { 2544 | public void actionPerformed(ActionEvent e) { 2545 | frame.remove(f); 2546 | frame.repaint(); 2547 | frame.validate(); 2548 | openAccountantMenu(frame, accountant); 2549 | } 2550 | }); 2551 | 2552 | // Sign Out Button 2553 | JButton btn_sign_out = new JButton("Sign Out"); 2554 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2555 | btn_sign_out.setForeground(Color.white); 2556 | btn_sign_out.setBounds(650,30,100, 30); 2557 | f.add(btn_sign_out); 2558 | 2559 | // function to be executed when Sign Out Button is clicked 2560 | btn_sign_out.addActionListener(new ActionListener() { 2561 | public void actionPerformed(ActionEvent e) { 2562 | frame.remove(f); 2563 | frame.repaint(); 2564 | frame.validate(); 2565 | Login_Account user = new Login_Account(); 2566 | openSignInForm(frame, user); 2567 | } 2568 | }); 2569 | 2570 | // displaying the new panel on frame 2571 | f.setLayout(null); 2572 | frame.setContentPane(f); 2573 | frame.setVisible(true); 2574 | } 2575 | 2576 | 2577 | 2578 | 2579 | 2580 | // withdraw cash screen 2581 | void withdrawCash(JFrame frame, Accountant accountant, Client client, Bank_Account account) { 2582 | JPanel f = new JPanel(); 2583 | f.setBackground(Color.white); 2584 | 2585 | // Deposit Cash Label 2586 | JLabel lWithdraw = new JLabel("Withdraw Cash"); 2587 | lWithdraw.setFont( lWithdraw.getFont().deriveFont(30f) ); 2588 | lWithdraw.setBounds(150,50,250, 40); 2589 | f.add(lWithdraw); 2590 | 2591 | // Name Label 2592 | JLabel lName = new JLabel( "Client Name: " + client.getFName() + " " + client.getLName() ); 2593 | lName.setBounds(150,100,150, 40); 2594 | f.add(lName); 2595 | 2596 | // CNIC Label 2597 | JLabel lCnic = new JLabel( "CNIC: " + client.getCNIC() ); 2598 | lCnic.setBounds(150,130,150, 40); 2599 | f.add(lCnic); 2600 | 2601 | // Account Number Label 2602 | JLabel lAccNum = new JLabel( "Account Number: " + account.getAccountNum() ); 2603 | lAccNum.setBounds(150,160,150, 40); 2604 | f.add(lAccNum); 2605 | 2606 | // Name Label 2607 | JLabel lType = new JLabel( "Account Type" + account.getType() ); 2608 | lType.setBounds(150,190,150, 40); 2609 | f.add(lType); 2610 | 2611 | // Amount Label 2612 | JLabel lAmount = new JLabel("Enter amount:"); 2613 | lAmount.setBounds(150,240,150, 40); 2614 | f.add(lAmount); 2615 | 2616 | // Amount Text Field 2617 | JTextField tfAmount = new JTextField(); 2618 | tfAmount.setBounds(150,280,180, 25); 2619 | f.add(tfAmount); 2620 | 2621 | // Withdraw Button 2622 | JButton btnWithdraw = new JButton("Withdraw"); 2623 | btnWithdraw.setBackground( new Color(0, 204, 153) ); 2624 | btnWithdraw.setForeground(Color.white); 2625 | btnWithdraw.setBounds(150,320,100, 30); 2626 | f.add(btnWithdraw); 2627 | 2628 | // function to be executed with Withdraw Button is clicked 2629 | btnWithdraw.addActionListener( new ActionListener() { 2630 | public void actionPerformed(ActionEvent e) { 2631 | 2632 | // check if amount is greater than 0 2633 | if( tfAmount.getText().compareTo("") != 0 ) { 2634 | if( Integer.valueOf( tfAmount.getText()) > 0 ) { 2635 | // subtract amount from account 2636 | int r = account.removeAmount( Integer.valueOf( tfAmount.getText()) ); 2637 | if( r == 2 ) { 2638 | // show low balance message 2639 | JOptionPane.showMessageDialog(f, "Not enough balance in account"); 2640 | } 2641 | else { 2642 | if( r == 1 ) { 2643 | // show withdrawal success message 2644 | JOptionPane.showMessageDialog(f, "Amount withdrawal successful"); 2645 | } 2646 | else 2647 | JOptionPane.showMessageDialog(f, "Amount withdrawal failed"); 2648 | 2649 | // go back to menu of accountant 2650 | frame.remove(f); 2651 | frame.repaint(); 2652 | frame.validate(); 2653 | openAccountantMenu(frame, accountant); 2654 | } 2655 | } 2656 | // invalid amount 2657 | else { 2658 | JOptionPane.showMessageDialog(f, "Invalid Amount"); 2659 | } 2660 | } 2661 | // invalid amount 2662 | else { 2663 | JOptionPane.showMessageDialog(f, "Invalid Amount"); 2664 | } 2665 | } 2666 | }); 2667 | 2668 | // Main Menu Button 2669 | JButton btn_mm = new JButton("Main Menu"); 2670 | btn_mm.setBackground( new Color(0, 204, 153) ); 2671 | btn_mm.setForeground(Color.white); 2672 | btn_mm.setBounds(50,400,100, 30); 2673 | f.add(btn_mm); 2674 | 2675 | // function to be executed when Main Menu Button is clicked 2676 | btn_mm.addActionListener( new ActionListener() { 2677 | public void actionPerformed(ActionEvent e) { 2678 | frame.remove(f); 2679 | frame.repaint(); 2680 | frame.validate(); 2681 | openAccountantMenu(frame, accountant); 2682 | } 2683 | }); 2684 | 2685 | // Sign Out Button 2686 | JButton btn_sign_out = new JButton("Sign Out"); 2687 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2688 | btn_sign_out.setForeground(Color.white); 2689 | btn_sign_out.setBounds(650,30,100, 30); 2690 | f.add(btn_sign_out); 2691 | 2692 | // function to be executed when Sign Out Button is clicked 2693 | btn_sign_out.addActionListener(new ActionListener() { 2694 | public void actionPerformed(ActionEvent e) { 2695 | frame.remove(f); 2696 | frame.repaint(); 2697 | frame.validate(); 2698 | Login_Account user = new Login_Account(); 2699 | openSignInForm(frame, user); 2700 | } 2701 | }); 2702 | 2703 | // displaying the new panel on frame 2704 | f.setLayout(null); 2705 | frame.setContentPane(f); 2706 | frame.setVisible(true); 2707 | } 2708 | 2709 | 2710 | 2711 | 2712 | 2713 | // view e-statement screen 2714 | void eStatement(JFrame frame, Accountant accountant, Client client, Bank_Account account) { 2715 | JPanel f = new JPanel(); 2716 | f.setBackground(Color.white); 2717 | 2718 | // E-Statement Label 2719 | JLabel lEStatement = new JLabel("E-Statement"); 2720 | lEStatement.setFont( lEStatement.getFont().deriveFont(30f) ); 2721 | lEStatement.setBounds(50,30,250, 40); 2722 | f.add(lEStatement); 2723 | 2724 | // Name Label 2725 | JLabel lName = new JLabel( "Client Name: " + client.getFName() + " " + client.getLName() ); 2726 | lName.setBounds(50,70,150, 40); 2727 | f.add(lName); 2728 | 2729 | // CNIC Label 2730 | JLabel lCnic = new JLabel( "CNIC: " + client.getCNIC() ); 2731 | lCnic.setBounds(50,90,150, 40); 2732 | f.add(lCnic); 2733 | 2734 | // Account Number Label 2735 | JLabel lAccNum = new JLabel( "Account Number: " + account.getAccountNum() ); 2736 | lAccNum.setBounds(450,70,150, 40); 2737 | f.add(lAccNum); 2738 | 2739 | // Name Label 2740 | JLabel lType = new JLabel( "Account Type: " + account.getType() ); 2741 | lType.setBounds(450,90,150, 40); 2742 | f.add(lType); 2743 | 2744 | // From Date Label 2745 | JLabel lFrom = new JLabel("From ( DD : MM : YY )"); 2746 | lFrom.setBounds(50,120,150, 40); 2747 | f.add(lFrom); 2748 | 2749 | // To Date Label 2750 | JLabel lTo = new JLabel("To ( DD : MM : YY )"); 2751 | lTo.setBounds(450,120,150, 40); 2752 | f.add(lTo); 2753 | 2754 | // Day, Month and Year for From Date 2755 | SpinnerModel fromDayValues = new SpinnerNumberModel(21, 1, 31, 1); 2756 | JSpinner fromDaySpinner = new JSpinner(fromDayValues); 2757 | fromDaySpinner.setBounds(50,150,40,25); 2758 | f.add(fromDaySpinner); 2759 | SpinnerModel fromMonthValues = new SpinnerNumberModel(12, 1, 12, 1); 2760 | JSpinner fromMonthSpinner = new JSpinner(fromMonthValues); 2761 | fromMonthSpinner.setBounds(100,150,40,25); 2762 | f.add(fromMonthSpinner); 2763 | SpinnerModel fromYearValues = new SpinnerNumberModel(2020, 2018, 2021, 1); 2764 | JSpinner fromYearSpinner = new JSpinner(fromYearValues); 2765 | fromYearSpinner.setBounds(150,150,55,25); 2766 | f.add(fromYearSpinner); 2767 | 2768 | // Day, Month and Year for From Date 2769 | SpinnerModel toDayValues = new SpinnerNumberModel(30, 1, 31, 1); 2770 | JSpinner toDaySpinner = new JSpinner(toDayValues); 2771 | toDaySpinner.setBounds(450,150,40,25); 2772 | f.add(toDaySpinner); 2773 | SpinnerModel toMonthValues = new SpinnerNumberModel(12, 1, 12, 1); 2774 | JSpinner toMonthSpinner = new JSpinner( toMonthValues); 2775 | toMonthSpinner.setBounds(500,150,40,25); 2776 | f.add(toMonthSpinner); 2777 | SpinnerModel toYearValues = new SpinnerNumberModel(2020, 2018, 2021, 1); 2778 | JSpinner toYearSpinner = new JSpinner(toYearValues); 2779 | toYearSpinner.setBounds(550,150,55,25); 2780 | f.add(toYearSpinner); 2781 | 2782 | JButton btnEStatement = new JButton("Get E-Statement"); 2783 | btnEStatement.setBackground( new Color(0, 204, 153) ); 2784 | btnEStatement.setForeground(Color.white); 2785 | btnEStatement.setBounds(50,200,150, 30); 2786 | f.add(btnEStatement); 2787 | 2788 | JButton btnDownload = new JButton("Download"); 2789 | btnDownload.setBackground( new Color(0, 204, 153) ); 2790 | btnDownload.setForeground(Color.white); 2791 | btnDownload.setBounds(450,200,100, 30); 2792 | f.add(btnDownload); 2793 | btnDownload.setEnabled(false); 2794 | 2795 | // table for transaction history records 2796 | DefaultTableModel tableModel = new DefaultTableModel(); 2797 | JTable table=new JTable(tableModel); 2798 | tableModel.addColumn("Serial No"); 2799 | tableModel.addColumn("Amount"); 2800 | tableModel.addColumn("Type"); 2801 | tableModel.addColumn("Date"); 2802 | tableModel.addColumn("Time"); 2803 | tableModel.addColumn("Account Number"); 2804 | tableModel.addColumn("Reciever Account Number"); 2805 | tableModel.addColumn("Cheque No"); 2806 | table.setEnabled(false); 2807 | JScrollPane sp=new JScrollPane(table); 2808 | sp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); 2809 | sp.setBounds(50,250,700,150); 2810 | f.add(sp); 2811 | sp.setVisible(false); 2812 | 2813 | // dunction to be executed when Get EStatement Button is clicked 2814 | btnEStatement.addActionListener( new ActionListener() { 2815 | public void actionPerformed(ActionEvent e) { 2816 | tableModel.setRowCount(0); 2817 | 2818 | String From = String.valueOf(fromYearSpinner.getValue()) +"-"+ String.valueOf(fromMonthSpinner.getValue()) +"-"+ String.valueOf(fromDaySpinner.getValue()); 2819 | String To = String.valueOf(toYearSpinner.getValue()) +"-"+ String.valueOf(toMonthSpinner.getValue()) +"-"+ String.valueOf(toDaySpinner.getValue()); 2820 | 2821 | List list = accountant.getTransactions( account.getAccountNum(), From, To); 2822 | if( list.size() > 0 ) { 2823 | for( Transaction_History th: list) { 2824 | tableModel.addRow(new Object[] { th.getSerialNo(), th.getAmount(), th.getType(), th.getDate(), th.getTime(), th.getAccountNumber(), th.getRecvAccNum(), th.getChequeNum() }); 2825 | } 2826 | tableModel.fireTableDataChanged(); 2827 | sp.setVisible(true); 2828 | //btnEStatement.setEnabled(false); 2829 | btnDownload.setEnabled(true); 2830 | } 2831 | else { 2832 | btnDownload.setEnabled(false); 2833 | } 2834 | } 2835 | }); 2836 | 2837 | // function to be executed when Download Button is clicked 2838 | btnDownload.addActionListener( new ActionListener() { 2839 | public void actionPerformed(ActionEvent e) { 2840 | String From = String.valueOf(fromYearSpinner.getValue()) +"-"+ String.valueOf(fromMonthSpinner.getValue()) +"-"+ String.valueOf(fromDaySpinner.getValue()); 2841 | String To = String.valueOf(toYearSpinner.getValue()) +"-"+ String.valueOf(toMonthSpinner.getValue()) +"-"+ String.valueOf(toDaySpinner.getValue()); 2842 | 2843 | DB_Handler db = new DB_Handler(); 2844 | int r = db.createPDF(client, account, From, To); 2845 | if( r == 1 ) 2846 | JOptionPane.showMessageDialog(f, "E-Statement is downloaded"); 2847 | else 2848 | JOptionPane.showMessageDialog(f, "Error in downloading the e-statement"); 2849 | frame.remove(f); 2850 | frame.repaint(); 2851 | frame.validate(); 2852 | openAccountantMenu(frame, accountant); 2853 | } 2854 | }); 2855 | 2856 | // Main Menu Button 2857 | JButton btn_mm = new JButton("Main Menu"); 2858 | btn_mm.setBackground( new Color(0, 204, 153) ); 2859 | btn_mm.setForeground(Color.white); 2860 | btn_mm.setBounds(50,400,100, 30); 2861 | f.add(btn_mm); 2862 | 2863 | // function to be executed when Main Menu Button is clicked 2864 | btn_mm.addActionListener( new ActionListener() { 2865 | public void actionPerformed(ActionEvent e) { 2866 | frame.remove(f); 2867 | frame.repaint(); 2868 | frame.validate(); 2869 | openAccountantMenu(frame, accountant); 2870 | } 2871 | }); 2872 | 2873 | // Sign Out Button 2874 | JButton btn_sign_out = new JButton("Sign Out"); 2875 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2876 | btn_sign_out.setForeground(Color.white); 2877 | btn_sign_out.setBounds(650,30,100, 30); 2878 | f.add(btn_sign_out); 2879 | 2880 | // function to be executed when Sign Out Button is clicked 2881 | btn_sign_out.addActionListener(new ActionListener() { 2882 | public void actionPerformed(ActionEvent e) { 2883 | frame.remove(f); 2884 | frame.repaint(); 2885 | frame.validate(); 2886 | Login_Account user = new Login_Account(); 2887 | openSignInForm(frame, user); 2888 | } 2889 | }); 2890 | 2891 | // displaying the new panel on frame 2892 | f.setLayout(null); 2893 | frame.setContentPane(f); 2894 | frame.setVisible(true); 2895 | } 2896 | 2897 | 2898 | 2899 | 2900 | 2901 | // cheque deposit screen 2902 | void chequeDeposit(JFrame frame, Accountant accountant) { 2903 | JPanel f = new JPanel(); 2904 | f.setBackground(Color.white); 2905 | 2906 | // Cheque Deposit Label 2907 | JLabel lCheque = new JLabel("Cheque Deposit"); 2908 | lCheque.setFont( lCheque.getFont().deriveFont(30f) ); 2909 | lCheque.setBounds(150,50,250, 40); 2910 | f.add(lCheque); 2911 | 2912 | // Account Number Label 2913 | JLabel lAccNum = new JLabel("Enter account number:"); 2914 | lAccNum.setBounds(150,100,150, 40); 2915 | f.add(lAccNum); 2916 | 2917 | // Account Number Text Field 2918 | JTextField tfAccNum = new JTextField(); 2919 | tfAccNum.setBounds(150,130,180, 25); 2920 | f.add(tfAccNum); 2921 | 2922 | // Amount Label 2923 | JLabel lAmount = new JLabel("Enter Amount:"); 2924 | lAmount.setBounds(150,160,150, 40); 2925 | f.add(lAmount); 2926 | 2927 | // Amount Text Field 2928 | JTextField tfAmount = new JTextField(); 2929 | tfAmount.setBounds(150,190,180, 25); 2930 | f.add(tfAmount); 2931 | 2932 | // Cheque Number Label 2933 | JLabel lChequeNum = new JLabel("Enter Cheque number:"); 2934 | lChequeNum.setBounds(150,220,150, 40); 2935 | f.add(lChequeNum); 2936 | 2937 | // Cheque Number Text Field 2938 | JTextField tfChequeNum = new JTextField(); 2939 | tfChequeNum.setBounds(150,250,180, 25); 2940 | f.add(tfChequeNum); 2941 | 2942 | // Deposit Button 2943 | JButton btnDeposit = new JButton("Deposit"); 2944 | btnDeposit.setBackground( new Color(0, 204, 153) ); 2945 | btnDeposit.setForeground(Color.white); 2946 | btnDeposit.setBounds(150,320,110, 40); 2947 | f.add(btnDeposit); 2948 | 2949 | // function to be executed when Withdraw Button is clicked 2950 | btnDeposit.addActionListener( new ActionListener() { 2951 | public void actionPerformed(ActionEvent e) { 2952 | if( Integer.valueOf( tfAmount.getText() ) > 0 ) { 2953 | int z = accountant.chequeDeposit( tfAccNum.getText(), tfChequeNum.getText(), Integer.valueOf( tfAmount.getText() ) ); 2954 | if( z == 2) 2955 | JOptionPane.showMessageDialog(f, "Account not found"); 2956 | else if( z == 3) 2957 | JOptionPane.showMessageDialog(f, "Account is blocked"); 2958 | else if( z == 4) 2959 | JOptionPane.showMessageDialog(f, "Account is closed"); 2960 | else 2961 | { 2962 | if( z == 1 ) 2963 | JOptionPane.showMessageDialog(f, "Cheque Deposit Successful"); 2964 | else 2965 | JOptionPane.showMessageDialog(f, "Cheque Deposit Failed"); 2966 | frame.remove(f); 2967 | frame.repaint(); 2968 | frame.validate(); 2969 | openAccountantMenu(frame, accountant); 2970 | } 2971 | } 2972 | else 2973 | JOptionPane.showMessageDialog(f, "Invalid Amount"); 2974 | } 2975 | }); 2976 | 2977 | // Main Menu Button 2978 | JButton btn_mm = new JButton("Main Menu"); 2979 | btn_mm.setBackground( new Color(0, 204, 153) ); 2980 | btn_mm.setForeground(Color.white); 2981 | btn_mm.setBounds(50,400,100, 30); 2982 | f.add(btn_mm); 2983 | 2984 | // function to be executed when Main Menu Button is clicked 2985 | btn_mm.addActionListener( new ActionListener() { 2986 | public void actionPerformed(ActionEvent e) { 2987 | frame.remove(f); 2988 | frame.repaint(); 2989 | frame.validate(); 2990 | openAccountantMenu(frame, accountant); 2991 | } 2992 | }); 2993 | 2994 | // Sign Out Button 2995 | JButton btn_sign_out = new JButton("Sign Out"); 2996 | btn_sign_out.setBackground( new Color(0, 204, 153) ); 2997 | btn_sign_out.setForeground(Color.white); 2998 | btn_sign_out.setBounds(650,30,100, 30); 2999 | f.add(btn_sign_out); 3000 | 3001 | // function to be executed when Sign Out Button is clicked 3002 | btn_sign_out.addActionListener(new ActionListener() { 3003 | public void actionPerformed(ActionEvent e) { 3004 | frame.remove(f); 3005 | frame.repaint(); 3006 | frame.validate(); 3007 | Login_Account user = new Login_Account(); 3008 | openSignInForm(frame, user); 3009 | } 3010 | }); 3011 | 3012 | // displaying the new panel on frame 3013 | f.setLayout(null); 3014 | frame.setContentPane(f); 3015 | frame.setVisible(true); 3016 | } 3017 | 3018 | 3019 | 3020 | // end of class 3021 | } 3022 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Login_Account.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | public class Login_Account { 4 | private String login_id; 5 | private String username; 6 | private String password; 7 | private String type; 8 | 9 | public Login_Account() { 10 | this.login_id = ""; 11 | this.username = ""; 12 | this.password = ""; 13 | this.type = ""; 14 | } 15 | 16 | public Login_Account(String login_id, String username, String password, String type) { 17 | this.login_id = login_id; 18 | this.username = username; 19 | this.password = password; 20 | this.type = type; 21 | } 22 | 23 | public String getLoginId() { 24 | return this.login_id; 25 | } 26 | 27 | public String getUsername() { 28 | return this.username; 29 | } 30 | 31 | public String getType() { 32 | String type_ = ""; 33 | if( type.compareTo("C") == 0 ) 34 | type_ = "Client"; 35 | else if( type.compareTo("M") == 0 ) 36 | type_ = "Manager"; 37 | else if( type.compareTo("A") == 0 ) 38 | type_ = "Accountant"; 39 | return type_; 40 | } 41 | 42 | int verify_account(String acc_num, String cnic) 43 | { 44 | DB_Handler db = new DB_Handler(); 45 | int temp_client_id = db.get_client_id(Integer.parseInt( acc_num )); 46 | System.out.println("The client id is: " + temp_client_id); 47 | 48 | if (temp_client_id == -1) 49 | { 50 | return -1; 51 | } 52 | else if (db.login_exists(temp_client_id) == false) 53 | { 54 | return -2; 55 | } 56 | else if (db.verify_cnic(temp_client_id, cnic)) 57 | { 58 | return -3; 59 | } 60 | return 0; 61 | } 62 | 63 | int signup(String username, String pass_1, String pass_2, String acc_num) 64 | { 65 | DB_Handler db = new DB_Handler(); 66 | int client_id = db.get_client_id(Integer.parseInt(acc_num)); 67 | 68 | if (pass_1.equals(pass_2) == false) 69 | { 70 | return -1; 71 | } 72 | else 73 | { 74 | System.out.println("Two passwords have successfully matched"); 75 | int temp_login = db.create_login(username, pass_1); 76 | if (temp_login == -1) 77 | { 78 | return -2; 79 | } 80 | db.set_login_id(temp_login, client_id); 81 | return 0; 82 | } 83 | } 84 | 85 | public String getName() { 86 | DB_Handler db = new DB_Handler(); 87 | return db.getName( this.login_id ); 88 | } 89 | 90 | // end of class 91 | } 92 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Manager.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | import java.util.List; 4 | 5 | public class Manager { 6 | 7 | private String name; 8 | 9 | Manager() { 10 | name = ""; 11 | } 12 | 13 | Manager(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return this.name; 19 | } 20 | 21 | // other functions here 22 | public int createAccount(Client newClient, String type) { 23 | DB_Handler db = new DB_Handler(); 24 | return db.DB_CreateAccount(newClient, type ); 25 | } 26 | 27 | int block_account(int acc_num, String cnic) 28 | { 29 | DB_Handler db = new DB_Handler(); 30 | int temp_client = db.get_client_id(acc_num); 31 | int temp_acc_type = db.get_account_status(acc_num); 32 | System.out.println("Corresponding client_id:"+temp_client+" acc_type:"+temp_acc_type); 33 | 34 | if ( cnic.equals(db.get_cnic(temp_client)) == false) 35 | { 36 | return -1; //-1 means that the cnic and account number are of different accounts 37 | } 38 | else if (temp_acc_type == 0 || temp_acc_type == -1) 39 | { 40 | return -2; //-2 means there is no active account with these details 41 | } 42 | else if (temp_acc_type == 2) 43 | { 44 | return -3; //-3 means that the card is blocked 45 | } 46 | else 47 | { 48 | db.block_account(acc_num); 49 | } 50 | return 0; 51 | } 52 | 53 | int unblock_account(int acc_num, String cnic) 54 | { 55 | DB_Handler db = new DB_Handler(); 56 | int temp_client = db.get_client_id(acc_num); 57 | int temp_acc_type = db.get_account_status(acc_num); 58 | System.out.println("Corresponding client_id:"+temp_client+" acc_type:"+temp_acc_type); 59 | 60 | if ( cnic.equals(db.get_cnic(temp_client)) == false) 61 | { 62 | return -1; //-1 means that the cnic and account number are of different accounts 63 | } 64 | else if (temp_acc_type == 0 || temp_acc_type == -1) 65 | { 66 | return -2; //-2 means there is no active account with these details 67 | } 68 | else if (temp_acc_type == 1) 69 | { 70 | return -3; //-3 means that the card is blocked 71 | } 72 | else 73 | { 74 | db.unblock_account(acc_num); 75 | } 76 | return 0; 77 | } 78 | 79 | int block_card(int acc_num, String cnic, String card_no) 80 | { 81 | DB_Handler db = new DB_Handler(); 82 | 83 | int temp_client_id = db.get_client_id(acc_num); 84 | String temp_cnic = db.get_cnic(temp_client_id); 85 | int temp_card_no = db.get_card_num(acc_num); 86 | 87 | if (temp_cnic.compareTo(cnic) != 0) 88 | { 89 | return -1; //-1 means no account with this details 90 | } 91 | else if (temp_card_no != Integer.parseInt(card_no)) 92 | { 93 | return -2; 94 | } 95 | else if ( db.is_card_active(temp_card_no) == false ) 96 | { 97 | return -3; 98 | } 99 | else 100 | { 101 | db.block_card(temp_card_no); 102 | } 103 | return 0; 104 | } 105 | 106 | int unblock_card(int acc_num, String cnic, String card_no) 107 | { 108 | DB_Handler db = new DB_Handler(); 109 | 110 | int temp_client_id = db.get_client_id(acc_num); 111 | String temp_cnic = db.get_cnic(temp_client_id); 112 | int temp_card_no = db.get_card_num(acc_num); 113 | 114 | if (temp_cnic.compareTo(cnic) != 0) 115 | { 116 | return -1; //-1 means no account with this details 117 | } 118 | else if (temp_card_no != Integer.parseInt(card_no)) 119 | { 120 | return -2; 121 | } 122 | else if ( db.is_card_active(temp_card_no) == true ) 123 | { 124 | return -3; 125 | } 126 | else 127 | { 128 | db.unblock_card(temp_card_no); 129 | } 130 | return 0; 131 | } 132 | 133 | int close_account(String account_num, String cnic) 134 | { 135 | DB_Handler db = new DB_Handler(); 136 | int temp_client_id = db.get_client_id(Integer.parseInt(account_num)); 137 | 138 | if ( cnic.equals(db.get_cnic(temp_client_id)) ) 139 | { 140 | db.close_account(Integer.parseInt(account_num)); 141 | return 0; 142 | } 143 | else 144 | return -1; 145 | } 146 | 147 | public Client getClientInfo(String acc_num) { 148 | DB_Handler db = new DB_Handler(); 149 | Client client = db.searchClient2(acc_num); 150 | return client; 151 | } 152 | 153 | public Bank_Account getAccountInfo(String acc_num) { 154 | DB_Handler db = new DB_Handler(); 155 | Bank_Account account = db.searchAccount2(acc_num); 156 | return account; 157 | } 158 | 159 | public void updateClientInfo(String client_id, String phone, String email, String address ) { 160 | DB_Handler db = new DB_Handler(); 161 | db.updateClientInfo(client_id, phone, email, address); 162 | } 163 | 164 | public String getAccNum(String CNIC) { 165 | DB_Handler db = new DB_Handler(); 166 | String acc_num = ""; 167 | acc_num = db.getAccNum(CNIC); 168 | return acc_num; 169 | } 170 | 171 | // end of class 172 | } 173 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Rough.txt: -------------------------------------------------------------------------------- 1 | Rough file used for copy pasting data when required 2 | 3 | 67453-7856457-7 4 | 5 | 97493-7156357-2 -------------------------------------------------------------------------------- /BM_System/src/def_pkg/Transaction_History.java: -------------------------------------------------------------------------------- 1 | package def_pkg; 2 | 3 | public class Transaction_History { 4 | private String serial_no; 5 | private String amount; 6 | private String type; 7 | private String date; 8 | private String time; 9 | private String account_num; 10 | private String recv_acc_num; 11 | private String cheque_num; 12 | 13 | // default constructor 14 | public Transaction_History() { 15 | this.serial_no = ""; 16 | this.amount = ""; 17 | this.type = ""; 18 | this.date = ""; 19 | this.time = ""; 20 | this.account_num = ""; 21 | this.recv_acc_num = ""; 22 | this.cheque_num = ""; 23 | } 24 | 25 | // parameterized constructor 26 | public Transaction_History(String serial_no, String amount, String type, String date, String time, String account_num, String recv_acc_num, String cheque_num) { 27 | this.serial_no = serial_no; 28 | this.amount = amount; 29 | this.type = type; 30 | this.date = date; 31 | this.time = time; 32 | this.account_num = account_num; 33 | this.recv_acc_num = recv_acc_num; 34 | this.cheque_num = cheque_num; 35 | } 36 | 37 | public String getSerialNo() { 38 | return this.serial_no; 39 | } 40 | 41 | public String getAmount() { 42 | return this.amount; 43 | } 44 | 45 | public String getType() { 46 | return this.type; 47 | } 48 | 49 | public String getDate() { 50 | return this.date; 51 | } 52 | 53 | public String getTime() { 54 | return this.time; 55 | } 56 | 57 | public String getAccountNumber() { 58 | return this.account_num; 59 | } 60 | 61 | public String getRecvAccNum() { 62 | return this.recv_acc_num; 63 | } 64 | 65 | public String getChequeNum() { 66 | return this.cheque_num; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /BM_System/src/def_pkg/anchor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/src/def_pkg/anchor.png -------------------------------------------------------------------------------- /BM_System/src/def_pkg/ddot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/BM_System/src/def_pkg/ddot.png -------------------------------------------------------------------------------- /MySQL Script.sql: -------------------------------------------------------------------------------- 1 | -- 1 Client Table 2 | CREATE TABLE `bank_schema`.`client` ( 3 | `client_id` int NOT NULL AUTO_INCREMENT, 4 | `f_name` varchar(45) NOT NULL, 5 | `l_name` varchar(45) NOT NULL, 6 | `father_name` varchar(45) NOT NULL, 7 | `mother_name` varchar(45) NOT NULL, 8 | `CNIC` varchar(45) NOT NULL, 9 | `DOB` date NOT NULL, 10 | `phone` varchar(45) NOT NULL, 11 | `email` varchar(45) DEFAULT NULL, 12 | `address` varchar(100) NOT NULL, 13 | PRIMARY KEY (`client_id`), 14 | UNIQUE KEY `client_id_UNIQUE` (`client_id`) 15 | ) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 16 | 17 | ALTER TABLE bank_schema.client AUTO_INCREMENT=10000; 18 | 19 | -- 2 Login_Account Table 20 | CREATE TABLE `bank_schema`.`login_account` ( 21 | `login_id` int NOT NULL AUTO_INCREMENT, 22 | `username` varchar(45) NOT NULL, 23 | `password` char(8) NOT NULL, 24 | `type` char(1) NOT NULL, 25 | PRIMARY KEY (`login_id`), 26 | UNIQUE KEY `login_id_UNIQUE` (`login_id`) 27 | ) ENGINE=InnoDB AUTO_INCREMENT=206 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 28 | 29 | ALTER TABLE bank_schema.login_account AUTO_INCREMENT=60000; 30 | 31 | -- 3 Employee Table 32 | CREATE TABLE `bank_schema`.`employee` ( 33 | `employee_id` int NOT NULL AUTO_INCREMENT, 34 | `f_name` varchar(45) NOT NULL, 35 | `l_name` varchar(45) NOT NULL, 36 | `father_name` varchar(45) NOT NULL, 37 | `mother_name` varchar(45) NOT NULL, 38 | `job` varchar(45) NOT NULL, 39 | `phone_no` varchar(45) NOT NULL, 40 | `email` varchar(45) NOT NULL, 41 | `login_id` int DEFAULT NULL, 42 | PRIMARY KEY (`employee_id`), 43 | UNIQUE KEY `employee_id_UNIQUE` (`employee_id`), 44 | KEY `login_id_idx` (`login_id`), 45 | CONSTRAINT `login_id` FOREIGN KEY (`login_id`) REFERENCES `login_account` (`login_id`) 46 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 47 | 48 | ALTER TABLE bank_schema.employee AUTO_INCREMENT=20000; 49 | 50 | -- 4 Card Table 51 | CREATE TABLE `bank_schema`.`card` ( 52 | `card_num` int NOT NULL AUTO_INCREMENT, 53 | `type` char(1) NOT NULL, 54 | `Status` char(1) NOT NULL, 55 | `Pin_code` char(4) NOT NULL, 56 | `Issue_date` date NOT NULL, 57 | PRIMARY KEY (`card_num`) 58 | ) ENGINE=InnoDB AUTO_INCREMENT=301 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 59 | 60 | ALTER TABLE bank_schema.card AUTO_INCREMENT=40000; 61 | 62 | -- 5 Bank_Account table 63 | CREATE TABLE `bank_schema`.`bank_account` ( 64 | `acc_num` int NOT NULL AUTO_INCREMENT, 65 | `client_id` int NOT NULL, 66 | `login_id` int DEFAULT NULL, 67 | `type` char(10) NOT NULL, 68 | `balance` int NOT NULL, 69 | `status` int NOT NULL, 70 | `opening_date` date NOT NULL, 71 | `closing_date` date DEFAULT NULL, 72 | `card_num` int DEFAULT NULL, 73 | PRIMARY KEY (`acc_num`), 74 | UNIQUE KEY `acc_num_UNIQUE` (`acc_num`), 75 | KEY `client_id` (`client_id`), 76 | KEY `login_id` (`login_id`), 77 | KEY `card_num` (`card_num`), 78 | CONSTRAINT `bank_account_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `client` (`client_id`), 79 | CONSTRAINT `bank_account_ibfk_2` FOREIGN KEY (`login_id`) REFERENCES `login_account` (`login_id`), 80 | CONSTRAINT `bank_account_ibfk_3` FOREIGN KEY (`card_num`) REFERENCES `card` (`card_num`) 81 | ) ENGINE=InnoDB AUTO_INCREMENT=402 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 82 | 83 | ALTER TABLE bank_schema.bank_account AUTO_INCREMENT=500000; 84 | 85 | -- 6 Transaction_History Table 86 | CREATE TABLE `bank_schema`.`transaction_history` ( 87 | `serial_no` int unsigned NOT NULL AUTO_INCREMENT, 88 | `amount` int NOT NULL, 89 | `type` varchar(45) NOT NULL, 90 | `date` date NOT NULL, 91 | `time` varchar(45) NOT NULL, 92 | `account_num` int NOT NULL, 93 | `recv_acc_num` int DEFAULT NULL, 94 | `cheque_num` int DEFAULT NULL, 95 | PRIMARY KEY (`serial_no`), 96 | KEY `account_num` (`account_num`), 97 | CONSTRAINT `transaction_history_ibfk_1` FOREIGN KEY (`account_num`) REFERENCES `bank_account` (`acc_num`) 98 | ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 99 | 100 | ALTER TABLE bank_schema.transaction_history AUTO_INCREMENT=70000; 101 | 102 | -- 7 Cardless Withdrawal Table 103 | CREATE TABLE `bank_schema`.`cardless_withdrawl` ( 104 | `serial_no` int NOT NULL AUTO_INCREMENT, 105 | `card_no` int NOT NULL, 106 | `amount` int NOT NULL, 107 | `OTC` varchar(13) NOT NULL, 108 | `temp_pin` char(4) NOT NULL, 109 | `Status` char(1) NOT NULL, 110 | `date` date DEFAULT NULL, 111 | `time` varchar(45) DEFAULT NULL, 112 | PRIMARY KEY (`serial_no`), 113 | UNIQUE KEY `serial_no_UNIQUE` (`serial_no`), 114 | KEY `card_no` (`card_no`), 115 | CONSTRAINT `cardless_withdrawl_ibfk_1` FOREIGN KEY (`card_no`) REFERENCES `card` (`card_num`) 116 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 117 | 118 | ALTER TABLE bank_schema.cardless_withdrawl AUTO_INCREMENT=80000; 119 | 120 | 121 | -- data set 122 | 123 | -- employees 124 | Insert into bank_schema.employee values(NULL, "Nasir", "Saeed", "Saaed Yonus", "Sara Naeem", "Manager", "03908967581", "nasir_saeed2311@gmail.com", NULL ); 125 | Insert into bank_schema.employee values(NULL, "Faizan", "Raheem", "Raheem Aslam", "Asma Javeed", "Accountant", "03778234199", "faizan0045@gmail.com", NULL ); 126 | 127 | -- clients 128 | Insert Into bank_schema.client Values(NULL, "Ahmed", "Ali", "Zubair Ali", "Ayesha Khan", "67153-7853257-8", STR_TO_DATE("17,9,1999", "%d,%m,%Y"), "03787817865", "ahmedali987@gmail.com", "House No. 412, Street 7, Fasil Colony, Rawalpindi"); 129 | Insert Into bank_schema.client Values(NULL, "Maria", "Yasir", "Sohail Jameel", "Faiza Saleem", "78342-0978912-8", STR_TO_DATE("21,3,1995", "%d,%m,%Y"), "03569899631", "maria_y03@gmail.com", "House No. 112, Street 3B, Block 2, DHA Islamabad"); 130 | Insert Into bank_schema.client Values(NULL, "Daniel", "Zaid", "Zaid Bilal", "Saba Tahir", "43210-7809821-1", STR_TO_DATE("7,11,1995", "%d,%m,%Y"), "03665132497", "danielzahid909@gmail.com", "House No. 8, Street 12, Ramzan Colony, Rawalpindi"); 131 | 132 | -- bank accounts 133 | Insert Into bank_schema.bank_account Values(NULL, 10000, NULL,"Current", 1000, 1, CURDATE(), NULL, NULL); 134 | Insert Into bank_schema.bank_account Values(NULL, 10001, NULL,"Current", 20000, 1, CURDATE(), NULL, NULL); 135 | Insert Into bank_schema.bank_account Values(NULL, 10002, NULL,"Saving", 7000, 1, CURDATE(), NULL, NULL); 136 | 137 | -- login account 138 | Insert into bank_schema.login_account values (NULL, "nasir55", "122221", 'M'); 139 | Insert into bank_schema.login_account values (NULL, "faizan211", "909094", 'A'); 140 | Insert into bank_schema.login_account values (NULL, "ahmed107", "tom891", 'C'); 141 | Insert into bank_schema.login_account values (NULL, "maria_y70", "green8", 'C'); 142 | Insert into bank_schema.login_account values (NULL, "daniel345", "90jeep", 'C'); 143 | 144 | update bank_schema.employee set login_id = 60000 where employee_id = 20000; 145 | update bank_schema.employee set login_id = 60001 where employee_id = 20001; 146 | update bank_schema.bank_account set login_id = 60002 where acc_num = 500000; 147 | update bank_schema.bank_account set login_id = 60003 where acc_num = 500001; 148 | update bank_schema.bank_account set login_id = 60004 where acc_num = 500002; 149 | 150 | -- cards 151 | Insert into bank_schema.card values( NULL, "C", "A", "8947", CURDATE() ); 152 | Insert into bank_schema.card values( NULL, "D", "A", "3921", CURDATE() ); 153 | 154 | update bank_schema.bank_account set card_num = 40000 where acc_num = 500000; 155 | update bank_schema.bank_account set card_num = 40001 where acc_num = 500001; 156 | 157 | -- transactions 158 | Insert into bank_schema.transaction_history values(NULL, 1500, "withdraw", CURDATE(), CURRENT_TIME(), 500000, NULL, NULL); 159 | Insert into bank_schema.transaction_history values(NULL, 2000, "deposit", CURDATE(), CURRENT_TIME(), 500000, NULL, 7856459); 160 | Insert into bank_schema.transaction_history values(NULL, 5000, "deposit", CURDATE(), CURRENT_TIME(), 500000, NULL, NULL); 161 | 162 | Insert into bank_schema.transaction_history values(NULL, 1500, "transfer", CURDATE(), CURRENT_TIME(), 500001, 500000, NULL); 163 | Insert into bank_schema.transaction_history values(NULL, 1000, "withdraw", CURDATE(), CURRENT_TIME(), 500001, NULL, NULL); 164 | 165 | Insert into bank_schema.transaction_history values(NULL, 1800, "withdraw", CURDATE(), CURRENT_TIME(), 500002, NULL, NULL); 166 | Insert into bank_schema.transaction_history values(NULL, 1200, "deposit", CURDATE(), CURRENT_TIME(), 500002, NULL, 1674534); 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bank-Management-System 2 | Bank Management System in Java Swing 3 | 4 | 5 | #### Tool and Technologies Used: 6 | * Java 7 | * Java Swing 8 | * MySQL 9 | * Eclipse 10 | * iText Java Library (PDF Creation) 11 | 12 |
13 | 14 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/1-Login.PNG?raw=true) 15 |
16 |
17 |
18 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/2-User_Screen.PNG?raw=true) 19 |
20 |
21 |
22 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/3-E-Statement.PNG?raw=true) 23 |
24 |
25 |
26 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/4-Manager_Screen.PNG?raw=true) 27 |
28 |
29 |
30 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/5-Create%20Account.PNG?raw=true) 31 |
32 |
33 |
34 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/6-Search%20Account.PNG?raw=true) 35 |
36 |
37 |
38 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/7-Accountant_Screen.PNG?raw=true) 39 |
40 |
41 |
42 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/8_Cheque_Deposit.PNG?raw=true) 43 |
44 |
45 |
46 | ![alt text](https://github.com/halts440/Bank-Management-System/blob/main/Screenshots/9-Sample_E_Statement.PNG?raw=true) 47 |
48 | -------------------------------------------------------------------------------- /Screenshots/1-Login.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/1-Login.PNG -------------------------------------------------------------------------------- /Screenshots/2-User_Screen.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/2-User_Screen.PNG -------------------------------------------------------------------------------- /Screenshots/3-E-Statement.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/3-E-Statement.PNG -------------------------------------------------------------------------------- /Screenshots/4-Manager_Screen.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/4-Manager_Screen.PNG -------------------------------------------------------------------------------- /Screenshots/5-Create Account.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/5-Create Account.PNG -------------------------------------------------------------------------------- /Screenshots/6-Search Account.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/6-Search Account.PNG -------------------------------------------------------------------------------- /Screenshots/7-Accountant_Screen.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/7-Accountant_Screen.PNG -------------------------------------------------------------------------------- /Screenshots/8_Cheque_Deposit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/8_Cheque_Deposit.PNG -------------------------------------------------------------------------------- /Screenshots/9-Sample_E_Statement.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halts440/Bank-Management-System/093c62124d9abf9090bd945882b33f5b988d2633/Screenshots/9-Sample_E_Statement.PNG --------------------------------------------------------------------------------