├── .gitignore ├── LICENSE ├── README.md ├── photos ├── Clients.png ├── Current.png ├── Structure.png ├── cash_in_hand.png ├── empass.png ├── employees.png ├── loan.png ├── overdraft.png └── savings.png └── src └── main └── OmJShah ├── admin ├── editemployee.py ├── fireemployee.py ├── hireemployee.py └── showemployee.py ├── client ├── depositmoney.py ├── loan_od.py ├── redeemcode.py ├── transfermoney.py └── withdrawmoney.py ├── employee ├── createaccount.py ├── deleteaccount.py ├── editaccount.py └── showaccounts.py ├── initialization ├── check.py └── setup.py ├── main.py ├── panels ├── accounttype.py ├── adminpanel.py ├── clientpanel.py └── employeepanel.py ├── tests.py └── tools ├── connection.py └── dataentering.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | firsttime.txt 3 | cred.dat 4 | links.txt 5 | tempCodeRunnerFile.py 6 | start program.bat 7 | README.md 8 | .vscode/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Om J Shah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OLD NOTICE: 2 | See [this pull request](https://github.com/OJASisLive/Bank-Management-System-Python-SQL/pull/6) for details about merger of ["shorten-the-code"](https://github.com/OJASisLive/Bank-Management-System-Python-SQL/tree/shorten-the-code) branch into the main branch. 3 | 4 | 5 | # Bank Management System: 6 | First of all, whole code is written by me and nothing has been copy pasted fron anywhere. 7 | 8 | The project has Dependencies which are all open sourced (modules such as pickle, csv, mysql-connector) 9 | 10 | # Requirements: 11 | 1. Python 3 12 | 2. MySQL workbench 8.0 13 | 14 | because I've tested the code using these versions only... 15 | 16 | # Setup: 17 | Run the file named "main.py" and follow the instructions of the program... 18 | 19 | # How to reset: 20 | Open the file named "firsttime.txt" and change the value from False to True (case sensitive) 21 | 22 | # Troubleshooting: 23 | 1. I suspect that the people who haven't set a password for SQL may encounter an error. (will fix it later) 24 | 25 | I strongly suggest users to have a password set in MySQL. 26 | 27 | 2. Check if the terminal shows the message "Connection established successfully" 28 | 29 | That means you entered your credentials properly 30 | 31 | 3. Any other exception will pop up in the terminal... 32 | 33 | # More information/Structure/Wiki 34 | [Wiki](https://github.com/OJASisLive/Bank-Management-System-Python-SQL/wiki) 35 | 36 | # About: 37 | This project aims to create a bridge between Python and SQL and use it in real world problems/applications... 38 | 39 | This project is currently under development... 40 | 41 | # Done by: 42 | Om J Shah 43 | -------------------------------------------------------------------------------- /photos/Clients.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/Clients.png -------------------------------------------------------------------------------- /photos/Current.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/Current.png -------------------------------------------------------------------------------- /photos/Structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/Structure.png -------------------------------------------------------------------------------- /photos/cash_in_hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/cash_in_hand.png -------------------------------------------------------------------------------- /photos/empass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/empass.png -------------------------------------------------------------------------------- /photos/employees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/employees.png -------------------------------------------------------------------------------- /photos/loan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/loan.png -------------------------------------------------------------------------------- /photos/overdraft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/overdraft.png -------------------------------------------------------------------------------- /photos/savings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OJASisLive/Bank-Management-System-Python-SQL/badae0c91f0d0838078ab22ea61e9a7cbe6f53f9/photos/savings.png -------------------------------------------------------------------------------- /src/main/OmJShah/admin/editemployee.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | from tools import dataentering 3 | 4 | def age(birthdate): 5 | today = date.today() 6 | age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) 7 | return age 8 | emp_no=None 9 | hire_date=None 10 | birth_date=None 11 | 12 | def ap3(conn,cur): 13 | global emp_no,birth_date,hire_date 14 | print("---------Edit employee process----------\n") 15 | while True: 16 | print("input ~ to quit") 17 | emp_no=input(("Enter emp_no of the employee to edit the details: ")) 18 | if emp_no=="~": break 19 | if len(emp_no) <= 5: 20 | try: 21 | emp_no=int(emp_no) 22 | print("Checking...") 23 | except ValueError: 24 | print("emp_no should be an integer!!") 25 | else: 26 | next(conn,cur) 27 | break 28 | else: 29 | print("Maximum length is 5!") 30 | 31 | def next(conn,cur): 32 | cur.execute("select * from employees where emp_no={}".format(emp_no)) 33 | results=cur.fetchall() 34 | if len(results)==0: 35 | print("That employee number does not exist.") 36 | else: 37 | results1=results[0] 38 | print("1.emp_no:",results1[0]) 39 | print("2.birth_date:",results1[1]) 40 | print("3.first_name:",results1[2]) 41 | print("4.last-name:",results1[3]) 42 | print("5.gender:",results1[4]) 43 | print("6.hire_date:",results1[5]) 44 | print("7.password") 45 | birth_date=results1[1] 46 | hire_date=results1[5] 47 | f2(conn,cur) 48 | 49 | def f2(conn,cur): 50 | global emp_no,birth_date,hire_date 51 | print("0 to quit.") 52 | a=input("What would you like to change from the above:") 53 | if a == '1': 54 | en=dataentering.primary_key_no("emp_no") 55 | query="update employees set emp_no=%s where emp_no=%s" 56 | query2="update empass set emp_no=%s where emp_no=%s" 57 | data=(en,emp_no) 58 | done=dataentering.tableupdate(conn,cur,query,data) 59 | if done: 60 | done=dataentering.tableupdate(conn,cur,query2,data) 61 | if done: 62 | print("Updated employee number...") 63 | 64 | if a == '2': 65 | birth_date=dataentering.birthdate("employee",20,60) 66 | if age(birth_date)-age(hire_date)>=20: 67 | query="update employees set birth_date=%s where emp_no=%s" 68 | data=(birth_date,emp_no) 69 | done=dataentering.tableupdate(conn,cur,query,data) 70 | if done: 71 | print("Updated birth date") 72 | else: 73 | print("Employee must be atleast 20 years of age when hired!!") 74 | print(birth_date,": birth_date") 75 | print(hire_date,":hire date you entered") 76 | 77 | if a == '3': 78 | first_name=dataentering.fname() 79 | query="update employees set first_name=%s where emp_no=%s" 80 | data=(first_name,emp_no) 81 | done=dataentering.tableupdate(conn,cur,query,data) 82 | if done: 83 | print("Updated first name...") 84 | 85 | if a == '4': 86 | last_name=dataentering.lname() 87 | query="update employees set last_name=%s where emp_no=%s" 88 | data=(last_name,emp_no) 89 | done=dataentering.tableupdate(conn,cur,query,data) 90 | if done: 91 | print("Updated last name...") 92 | 93 | if a == '5': 94 | gender=dataentering.gender() 95 | query="update employees set gender=%s where emp_no=%s" 96 | data=(gender,emp_no) 97 | done=dataentering.tableupdate(conn,cur,query,data) 98 | if done: 99 | print("Updated gender...") 100 | 101 | if a == '6': 102 | hire_date=dataentering.date2("employee",birth_date,"hire",20,60) 103 | query="update employees set hire_date=%s where emp_no=%s" 104 | data=(hire_date,emp_no) 105 | done=dataentering.tableupdate(conn,cur,query,data) 106 | if done: 107 | print("Updated hire date...") 108 | 109 | if a=='7': 110 | print("1.Show the password") 111 | print("2.Change the password") 112 | ans=input("Enter your choice (1,2):") 113 | if ans=='1': 114 | cur.execute("SELECT pass from empass where emp_no={}".format(emp_no)) 115 | result=cur.fetchall() 116 | print(result[0][0], "is the password.") 117 | elif ans=='2': 118 | while True: 119 | password=input("Enter employee login password(max 8 characters, min 4): ") 120 | lp=len(password) 121 | if lp>8: 122 | print("Max 8 characters only.") 123 | elif lp<4: 124 | print("Minimum 4 characters to be entered.") 125 | else: 126 | query="UPDATE empass set pass=LPAD(%s,%s,'0') where emp_no=%s" 127 | data=(password,lp,emp_no) 128 | done=dataentering.tableupdate(conn,cur,query,data) 129 | if done: 130 | print("Password changed successfully!!!") 131 | break 132 | else: 133 | break -------------------------------------------------------------------------------- /src/main/OmJShah/admin/fireemployee.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | def ap2(conn,cur): 3 | print("---------Fire employee process----------\n") 4 | while True: 5 | emp_no=input(("Enter emp_no of the employee to fire them: ")) 6 | if len(emp_no) <= 5: 7 | try: 8 | emp_no=int(emp_no) 9 | print("Checking...") 10 | except ValueError: 11 | print("emp_no should be an integer!!") 12 | else: 13 | break 14 | else: 15 | print("Maximum length is 5!") 16 | 17 | query="delete from employees where emp_no = {}".format(emp_no) 18 | query2="delete from empass where emp_no = {}".format(emp_no) 19 | cur.execute("select emp_no from employees") 20 | record=cur.fetchall() 21 | changed=False 22 | for r in record: 23 | if r[0]==emp_no: 24 | try: 25 | cur.execute(query2) 26 | conn.commit() 27 | cur.execute(query) 28 | conn.commit() 29 | changed=True 30 | except mysql.connector.Error as err: 31 | print(err.msg) 32 | print("-----------Value deletion was unsuccessful!!!!-------------\n") 33 | else: 34 | print("Employee fired successfully...\n") 35 | if not changed: 36 | print("The employee number does not exist.") 37 | print("------------Could not fire employee-----------\n") -------------------------------------------------------------------------------- /src/main/OmJShah/admin/hireemployee.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | from tools import dataentering 3 | 4 | def ap1(query,cur): 5 | print("-------------Hire Employee Process-------------") 6 | 7 | #Employee number 8 | emp_no=dataentering.primary_key_no("emp_no") 9 | #Employee Birth date 10 | birth_date=dataentering.birthdate("employee",20,60) 11 | #Employee name 12 | first_name,last_name=dataentering.fname(),dataentering.lname() 13 | #Employee Gender 14 | gender=dataentering.gender() 15 | #Employee hire date 16 | hire_date=dataentering.date2("Employee",birth_date,"hire",20,60) 17 | 18 | 19 | print("=========== Final Data ===========") 20 | print(emp_no,birth_date,first_name,last_name,gender,hire_date) 21 | add_employee=("INSERT INTO employees " 22 | "(emp_no,birth_date,first_name,last_name,gender,hire_date) " 23 | "VALUES (%s,%s,%s,%s,%s,%s)") 24 | data_employee=(emp_no,birth_date,first_name,last_name,gender,hire_date) 25 | try: 26 | cur.execute(add_employee, data_employee) 27 | query.commit() 28 | except mysql.connector.Error as err: 29 | print(err.msg) 30 | print("-----------Value addition was unsuccessful!!!!-------------") 31 | else: 32 | print("Values added successfully!!") 33 | while True: 34 | password=input("Enter employee login password(max 8 characters, min 4): ") 35 | lp=len(password) 36 | if lp>8: 37 | print("Max 8 characters only.") 38 | elif lp<4: 39 | print("Minimum 4 characters to be entered.") 40 | else: 41 | try: 42 | cur.execute("INSERT INTO empass values({},LPAD({},{},'0'))".format(emp_no,password,lp)) 43 | query.commit() 44 | except mysql.connector.Error as err: 45 | print(err.msg) 46 | print("-----------Password addition was unsuccessful!!!!-------------") 47 | else: 48 | print("Password added successfully!!!") 49 | break 50 | -------------------------------------------------------------------------------- /src/main/OmJShah/admin/showemployee.py: -------------------------------------------------------------------------------- 1 | def ap4(cur): 2 | cur.execute("select * from employees") 3 | results=cur.fetchall() 4 | print("+---------+-------------+------------------+------------------+---------+-------------+") 5 | print("|","%7s"%"EMP_NO","|","%11s"%"BIRTH_DATE","|","%16s"%"FIRST_NAME","|","%16s"%"LAST_NAME","|","%7s"%"GENDER","|","%11s"%"HIRE_DATE","|") 6 | for row in results: 7 | print("+---------+-------------+------------------+------------------+---------+-------------+") 8 | print("|","%7s"%row[0],"|","%11s"%row[1],"|","%16s"%row[2],"|","%16s"%row[3],"|","%7s"%row[4],"|","%11s"%row[5],"|") 9 | print("+---------+-------------+------------------+------------------+---------+-------------+") -------------------------------------------------------------------------------- /src/main/OmJShah/client/depositmoney.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | def cp2(conn,cur,acc_type,acc_no): 3 | cash_in_hand=dataentering.handcash(conn,cur,acc_no) 4 | 5 | deposit_amt=dataentering.amounts("deposit",cash_in_hand,acc_type) 6 | deposit_amt=deposit_amt[0] 7 | if deposit_amt: 8 | query2="update {} set balance = balance+%s where acc_no = %s".format(acc_type) 9 | data2=(deposit_amt,acc_no) 10 | done2=dataentering.tableupdate(conn,cur,query2,data2) 11 | if done2: 12 | query3="update cash_in_hand set cash_in_hand = cash_in_hand-%s where acc_no = %s" 13 | data3=(cash_in_hand,acc_no) 14 | done3=dataentering.tableupdate(conn,cur,query3,data3) 15 | if done3: 16 | print("Deposit of {} currency successful".format(deposit_amt)) 17 | print() 18 | else: 19 | query2="update {} set balance = balance-%s where acc_no = %s".format(acc_type) 20 | data2=(deposit_amt,acc_no) 21 | done2=dataentering.tableupdate(conn,cur,query2,data2) 22 | if done2: 23 | print("Unable to subtract amount from cash_in_hand\n") 24 | else: 25 | print("Error while trying to add amount to balance.\n") 26 | else: 27 | pass -------------------------------------------------------------------------------- /src/main/OmJShah/client/loan_od.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | def cp5(cur,acc_type,acc_no): 3 | loan_or_od=None 4 | if acc_type=="current": 5 | loan_or_od="overdraft" 6 | else: 7 | loan_or_od="loan" 8 | cur.execute("select {} from {} where acc_no={}".format(loan_or_od,acc_type,acc_no)) 9 | a=cur.fetchall() 10 | if a[0][0]=="NO" and acc_type=="savings": 11 | loan_process() 12 | elif a[0][0]=="NO" and acc_type=="current": 13 | #TODO:Check status of pending overdraft request if any 14 | print("Congratulations! You don't have any overdraft to repay.") 15 | elif a[0][0]=="YES" and acc_type=="current": 16 | cur.execute("select {}_amt from {} where acc_no={}".format(loan_or_od,loan_or_od,acc_no)) 17 | od=cur.fetchall() 18 | od=od[0][0] 19 | print("Your remaining od amount is {}") 20 | else: 21 | print("You already have a loan pending to repay...") 22 | cur.execute("select {}_amt,{}_type from {} where acc_no={}".format(loan_or_od,loan_or_od,loan_or_od,acc_no)) 23 | loan=cur.fetchall() 24 | loan_type=loan[0][1] 25 | if loan_type=='PL':loan_type='Personal Loan' 26 | if loan_type=='HL':loan_type='Health Loan' 27 | if loan_type=='EL':loan_type='Education Loan' 28 | if loan_type=='TL':loan_type='Term Loan' 29 | else:loan_type='Business Loan' 30 | loan_amt=loan[0][0] 31 | print("Your remaining od amount is {} of loan type {}".format(loan_amt,loan_type)) 32 | 33 | 34 | def loan_process(): 35 | while True: 36 | loan_amt=input("Enter loan amount: ") 37 | try: 38 | loan_amt=int(loan_amt) 39 | except ValueError: 40 | print("Loan amount should be an integer") 41 | else: 42 | print("Done OK") 43 | break 44 | 45 | while True: 46 | print() 47 | print("1.Personal Loan") 48 | print("2.Home Loan") 49 | print("3.Education Loan") 50 | print("4.Term Loan") 51 | print("5.Business Loan") 52 | print(" Input ~ to quit\n") 53 | loan_type=input("Enter choice: ") 54 | if loan_type=="1": 55 | loan_type='PL' 56 | break 57 | elif loan_type=="2": 58 | loan_type='HL' 59 | break 60 | elif loan_type=="3": 61 | loan_type='EL' 62 | break 63 | elif loan_type=="4": 64 | loan_type='TL' 65 | break 66 | elif loan_type=="5": 67 | loan_type='BL' 68 | break 69 | elif loan_type=="~": 70 | break 71 | else: 72 | print("Wrong Input!!") 73 | 74 | if loan_type!="~": 75 | return loan_amt,loan_type 76 | #TODO: Add a method to store requests in dat file or csv file... 77 | -------------------------------------------------------------------------------- /src/main/OmJShah/client/redeemcode.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | def cp4(conn,cur,acc_type,acc_no): 3 | rc=input("Enter redeem code: ") 4 | if rc=="TESTREDEEMCODE": 5 | query="update {} set balance = balance+%s where acc_no = %s".format(acc_type) 6 | data=(5000,acc_no) 7 | done = dataentering.tableupdate(conn,cur,query,data) 8 | if done: 9 | print("Added 5000 currency to your account!!") 10 | else: 11 | print("There was a problem while processing the request") 12 | else: 13 | print("Sorry! This redeem code doesn't work") -------------------------------------------------------------------------------- /src/main/OmJShah/client/transfermoney.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | def cp6(conn,cur,acc_type,acc_no,balance): 3 | acc_to_transfer=dataentering.primary_key_no("acc_no of receiver") 4 | cur.execute("select * from clients where acc_no={}".format(acc_to_transfer)) 5 | result=cur.fetchall() 6 | if result==[]: 7 | print("That account number doesn't exist\n") 8 | elif acc_to_transfer==acc_no: 9 | print("You can't transfer to yourself\n") 10 | else: 11 | acc_type_receiver=result[0][1] 12 | if acc_type_receiver == 'S': acc_type_receiver="savings" 13 | if acc_type_receiver == 'C': acc_type_receiver="current" 14 | fname,lname=result[0][2],result[0][3] 15 | transfer_amt,overdraft=dataentering.amounts("transfer",balance,acc_type) 16 | print(" Y - Yes") 17 | print(" N - No") 18 | ch=input("Do you want transfer {} currency to {} {}'s account: ".format(transfer_amt,fname,lname)) 19 | if ch == "Y" : 20 | 21 | if transfer_amt: 22 | if acc_type=="current": 23 | if overdraft!=None: 24 | print('''You will be notified about the overdraft status when an employee 25 | sanctions your overdraft...''') 26 | #TODO:some more stuff 27 | else: 28 | query="update {} set balance=balance-%s where acc_no = %s".format(acc_type) 29 | data=(transfer_amt,acc_no) 30 | done=dataentering.tableupdate(conn,cur,query,data) 31 | if done: 32 | query2="update {} set balance=balance+%s where acc_no=%s".format(acc_type_receiver) 33 | data2=(transfer_amt,acc_to_transfer) 34 | done2=dataentering.tableupdate(conn,cur,query2,data2) 35 | if done2: 36 | print("Successfully transferred {} currency\n".format(transfer_amt)) 37 | else: 38 | query="update {} set balance=balance+%s where acc_no = %s".format(acc_type) 39 | data=(transfer_amt,acc_no) 40 | done=dataentering.tableupdate(conn,cur,query,data) 41 | if done: 42 | print("Couldn't update receiver's balance\n") 43 | else: 44 | print("Couldn't transfer money.") 45 | else : 46 | print("You do not have enough balance!!") 47 | 48 | else: 49 | print("Cancelled transfer") -------------------------------------------------------------------------------- /src/main/OmJShah/client/withdrawmoney.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | def cp3(conn,cur,acc_type,acc_no): 3 | cur.execute("select balance from {} where acc_no={}".format(acc_type,acc_no)) 4 | balance=cur.fetchall() 5 | balance=balance[0][0] 6 | withdraw_amt=dataentering.amounts("withdraw",balance,acc_type) 7 | withdraw_amt=withdraw_amt[0] 8 | if withdraw_amt: 9 | query="update {} set balance = balance-%s where acc_no=%s".format(acc_type) 10 | data=(withdraw_amt,acc_no) 11 | done=dataentering.tableupdate(conn,cur,query,data) 12 | if done: 13 | query2="update cash_in_hand set cash_in_hand=cash_in_hand+%s where acc_no=%s" 14 | data2=(withdraw_amt,acc_no) 15 | done2=dataentering.tableupdate(conn,cur,query2,data2) 16 | if done2: 17 | print("Successfully withdrawn {} currency".format(withdraw_amt)) 18 | print() 19 | else: 20 | query="update {} set balance = balance+%s where acc_no=%s".format(acc_type) 21 | data=(withdraw_amt,acc_no) 22 | done=dataentering.tableupdate(conn,cur,query,data) 23 | if done: 24 | print("Couldn't remove money from cash_in_hand\n") 25 | else: 26 | print("couldn't update balance\n") 27 | else: 28 | print("Couldn't withdraw amount\n") -------------------------------------------------------------------------------- /src/main/OmJShah/employee/createaccount.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | 3 | def ep1(query,cur): 4 | print("-------------Create account Process-------------") 5 | 6 | #client number 7 | acc_no=dataentering.primary_key_no("acc_no") 8 | #client Birth date 9 | birth_date=dataentering.birthdate("Client",10,100) 10 | #client name 11 | first_name,last_name=dataentering.fname(),dataentering.lname() 12 | #client Gender 13 | gender=dataentering.gender() 14 | #client Account Type 15 | while True: 16 | print("1.Savings account") 17 | print("2.Current account") 18 | a=input("Enter choice (1 or 2):") 19 | if a== '1': 20 | acc_type='S' 21 | break 22 | elif a=='2': 23 | acc_type='C' 24 | break 25 | else: 26 | print("Wrong input!!") 27 | 28 | #Account creation date 29 | acc_creation_date=dataentering.date2("client",birth_date,"account_creation",10,100) 30 | #client password/pin 31 | password,lp=dataentering.clientpassword() 32 | 33 | #mobile no 34 | mobile_no,lmn=dataentering.mobileno() 35 | 36 | #email-id 37 | email_id=dataentering.email() 38 | 39 | print("=========== Final Data ===========") 40 | print(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password) 41 | add_client=("INSERT INTO clients " 42 | "(acc_no,type,first_name,last_name,gender,birth_date,accd,mobile_no,email_id,pass) " 43 | "VALUES (%s,%s,%s,%s,%s,%s,%s,LPAD(%s,%s,'0'),%s,LPAD(%s,%s,'0'))") 44 | data_client=(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,lmn,email_id,password,lp) 45 | 46 | done=dataentering.tableupdate(query,cur,add_client,data_client) 47 | if done: 48 | if acc_type=='S': 49 | bank_balance=dataentering.balance() 50 | add_savings=("INSERT INTO SAVINGS VALUES(%s,%s,'NO')") 51 | data_savings=(acc_no,bank_balance) 52 | done2=dataentering.tableupdate(query,cur,add_savings,data_savings) 53 | if done2: 54 | pass 55 | else: 56 | print("Unable to add to savings table.") 57 | print("Deleting from main table.......") 58 | delete_client=("delete from clients where acc_no = %s") 59 | data_delete_client=(acc_no) 60 | done=dataentering.tableupdate(query,cur,delete_client,data_delete_client) 61 | else: 62 | bank_balance=dataentering.balance() 63 | add_current=("INSERT INTO current VALUES(%s,%s,'NO')") 64 | data_current=(acc_no,bank_balance) 65 | done2=dataentering.tableupdate(query,cur,add_current,data_current) 66 | if done2: 67 | pass 68 | else: 69 | print("Unable to add to savings table.") 70 | print("Deleting from main table.......") 71 | delete_client=("delete from clients where acc_no = %s") 72 | data_delete_client=(acc_no) 73 | done=dataentering.tableupdate(query,cur,delete_client,data_delete_client) 74 | 75 | print("Values added successfully!!") -------------------------------------------------------------------------------- /src/main/OmJShah/employee/deleteaccount.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | 3 | acc_no=None 4 | def ep3(conn,cur): 5 | global acc_no 6 | while True: 7 | print("\n----------------Account Deleteion Menu-----------------\n") 8 | print("input ~ to quit") 9 | acc_no=input("Enter acc_no (max 5 int) to DELETE THE ACCOUNT: ") 10 | if acc_no=="~": break 11 | elif len(acc_no) <= 5: 12 | try: 13 | acc_no=int(acc_no) 14 | print("Done OK") 15 | except ValueError: 16 | print("acc_no should be an integer!!") 17 | else: 18 | print("Maximum length is 5!") 19 | cur.execute("select * from clients where acc_no={}".format(acc_no)) 20 | results=cur.fetchall() 21 | if len(results)==0: 22 | print("That account number does not exist.") 23 | else : 24 | results1=results[0] 25 | acc_type=results1[1] 26 | if acc_type == 'S': 27 | loan_or_od="loan" 28 | acc_type="savings" 29 | if acc_type == 'C': 30 | loan_or_od="overdraft" 31 | acc_type="current" 32 | cur.execute("select {} from {} where acc_no={}".format(loan_or_od,acc_type,acc_no)) 33 | status=cur.fetchall() 34 | status=status[0][0] 35 | first_name=results1[2] 36 | last_name=results1[3] 37 | if status == "YES": 38 | print("The Client {} {} has {} money to repay".format(first_name,last_name,loan_or_od)) 39 | print("The account can't be deleted until {} is repayed".format(loan_or_od)) 40 | break 41 | else: 42 | print(first_name,last_name,"found.") 43 | print(" Y - Deletes the account") 44 | print(" N - Cancel process") 45 | print("It's case sensitive") 46 | choice=input("Do you really wish to delete the account of {} {}: ".format(first_name,last_name)) 47 | if choice == "Y": 48 | query="delete from clients where acc_no = %s" 49 | data=(acc_no,) 50 | query2="delete from {} where acc_no = %s".format(acc_type) 51 | data2=(acc_no,) 52 | done=dataentering.tableupdate(conn,cur,query,data) 53 | if done: 54 | done2=dataentering.tableupdate(conn,cur,query2,data2) 55 | if done2: 56 | print("Deleted {} {}'s account.".format(first_name,last_name)) 57 | break 58 | else: 59 | print("Deletion from {} table was unsuccessful".format(acc_type)) 60 | else: 61 | print("Deletion was unsuccessful") 62 | else: 63 | break 64 | -------------------------------------------------------------------------------- /src/main/OmJShah/employee/editaccount.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | from tools import dataentering 3 | 4 | acc_no=None 5 | first_name=None 6 | last_name=None 7 | gender=None 8 | birth_date=None 9 | acc_creation_date=None 10 | mobile_no=None 11 | email_id=None 12 | password = None 13 | 14 | def age(birthdate): 15 | today = date.today() 16 | age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) 17 | return age 18 | 19 | def ep2(conn,cur): 20 | global acc_no,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password 21 | while True: 22 | print("\ninput ~ to quit") 23 | acc_no=input("Enter acc_no (max 5 int) to edit details: ") 24 | if acc_no=="~": break 25 | elif len(acc_no) <= 5: 26 | try: 27 | acc_no=int(acc_no) 28 | print("Done OK") 29 | except ValueError: 30 | print("acc_no should be an integer!!") 31 | else: 32 | print("Maximum length is 5!") 33 | cur.execute("select * from clients where acc_no={}".format(acc_no)) 34 | results=cur.fetchall() 35 | if len(results)==0: 36 | print("That account number does not exist.") 37 | else: 38 | results1=results[0] 39 | first_name=results1[2] 40 | last_name=results1[3] 41 | gender=results1[4] 42 | birth_date=results1[5] 43 | acc_creation_date=results1[6] 44 | mobile_no=results1[7] 45 | email_id=results1[8] 46 | password=results1[9] 47 | 48 | print("1. first_name = ",first_name) 49 | print("2. last_name = ",last_name) 50 | print("3. gender = ",gender) 51 | print("4. birth_date = ",birth_date) 52 | print("5. account_creation_date = ",acc_creation_date) 53 | print("6. mobile_no = ",mobile_no) 54 | print("7. email_id = ",email_id) 55 | print("8. password") 56 | print("0 to quit") 57 | ep2f2(conn,cur) 58 | 59 | def ep2f2(conn,cur): 60 | global acc_no,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password 61 | choice=input("What would you like to change from here: ") 62 | #First-name 63 | if choice == "1": 64 | first_name=dataentering.fname() 65 | query="update clients set first_name=%s where acc_no=%s" 66 | data=(first_name,acc_no) 67 | done=dataentering.tableupdate(conn,cur,query,data) 68 | if done: 69 | print("Updated first name") 70 | 71 | #Last-name 72 | elif choice == "2": 73 | last_name=dataentering.lname() 74 | query="update clients set last_name=%s where acc_no=%s" 75 | data=(last_name,acc_no) 76 | done=dataentering.tableupdate(conn,cur,query,data) 77 | if done: 78 | print("Updated last name") 79 | 80 | #Gender 81 | elif choice == "3": 82 | gender=dataentering.gender() 83 | query="update clients set gender=%s where acc_no=%s" 84 | data=(gender,acc_no) 85 | done=dataentering.tableupdate(conn,cur,query,data) 86 | if done: 87 | print("Updated gender") 88 | 89 | #Birth-date 90 | elif choice == "4": 91 | birth_date=dataentering.birthdate("Client",10,100) 92 | if age(birth_date)-age(acc_creation_date)>=10: 93 | query="update clients set birth_date=%s where acc_no=%s" 94 | data=(birth_date,acc_no) 95 | done=dataentering.tableupdate(conn,cur,query,data) 96 | if done: 97 | print("Updated birth date") 98 | else: 99 | print("The client should atleast be 10 years of age.") 100 | print("Birth date:",birth_date) 101 | print("Account Creation Date:",acc_creation_date) 102 | 103 | #Account-creation-date(accd) 104 | elif choice == "5": 105 | acc_creation_date=dataentering.date2("client",birth_date,"account_creation",10,100) 106 | query="update clients set accd=%s where acc_no=%s" 107 | data=(acc_creation_date,acc_no) 108 | done=dataentering.tableupdate(conn,cur,query,data) 109 | if done: 110 | print("Updated account creation date") 111 | 112 | #Mobile No 113 | elif choice == "6": 114 | mobile_no,lmn=dataentering.mobileno() 115 | query="update clients set mobile_no=LPAD(%s,%s,'0') where acc_no=%s" 116 | data=(mobile_no,lmn,acc_no) 117 | done=dataentering.tableupdate(conn,cur,query,data) 118 | if done: 119 | print("Updated mobile number") 120 | 121 | #Email ID 122 | elif choice == "7": 123 | email_id=dataentering.email() 124 | query="update clients set email=%s where acc_no=%s" 125 | data=(mobile_no,acc_no) 126 | done=dataentering.tableupdate(conn,cur,query,data) 127 | if done: 128 | print("Updated mobile number") 129 | #Password 130 | elif choice == "8": 131 | while True: 132 | print("1.Show Password") 133 | print("2.Change Password") 134 | print("0 to quit") 135 | choice=input("Enter choice: ") 136 | if choice == "1": 137 | print("\nThe password will be printed on the next line") 138 | print(password) 139 | print() 140 | elif choice == "2": 141 | password,lp=dataentering.clientpassword() 142 | query="update clients set pass=LPAD(%s,%s,'0') where acc_no=%s" 143 | data=(password,lp,acc_no) 144 | done=dataentering.tableupdate(conn,cur,query,data) 145 | if done: 146 | print("Updated password") 147 | elif choice == "0": 148 | break 149 | else: 150 | print("Wrong input!!") 151 | elif choice == "0": 152 | pass 153 | else: 154 | print("Wrong input!!") -------------------------------------------------------------------------------- /src/main/OmJShah/employee/showaccounts.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | 3 | def ep4(cur): 4 | cur.execute("select * from clients") 5 | results=cur.fetchall() 6 | print("+---------+-------+------------------+------------------+---------+-------------+-------------+------------------+---------------------------+") 7 | print("|","%7s"%"ACC_NO","|","%5s"%"TYPE","|","%16s"%"FIRST_NAME","|","%16s"%"LAST_NAME","|","%7s"%"GENDER","|","%11s"%"BIRTH_DATE","|","%11s"%"ACCD","|","%16s"%"MOBILE_NO","|","%25s"%"EMAIL_ID","|") 8 | for row in results: 9 | print("+---------+-------+------------------+------------------+---------+-------------+-------------+------------------+---------------------------+") 10 | print("|","%7s"%row[0],"|","%5s"%row[1],"|","%16s"%row[2],"|","%16s"%row[3],"|","%7s"%row[4],"|","%11s"%row[5],"|","%11s"%row[6],"|","%16s"%row[7],"|","%25s"%row[8],"|") 11 | print("+---------+-------+------------------+------------------+---------+-------------+-------------+------------------+---------------------------+") 12 | -------------------------------------------------------------------------------- /src/main/OmJShah/initialization/check.py: -------------------------------------------------------------------------------- 1 | def check(): 2 | try: 3 | with open("files//firsttime.txt","r") as a: 4 | if a.read().strip()=="True": 5 | return True 6 | else: 7 | return False 8 | except FileNotFoundError: 9 | with open("files//firsttime.txt","w") as a: 10 | a.write("True") 11 | return True -------------------------------------------------------------------------------- /src/main/OmJShah/initialization/setup.py: -------------------------------------------------------------------------------- 1 | from initialization import check 2 | 3 | import pickle 4 | import mysql.connector 5 | 6 | from mysql.connector import errorcode 7 | existing=0 8 | 9 | conn=None 10 | cursor=None 11 | 12 | TABLES = {} 13 | TABLES['employees'] = ( 14 | "CREATE TABLE `employees` (" 15 | " `emp_no` int(5) NOT NULL ," 16 | " `birth_date` date NOT NULL," 17 | " `first_name` varchar(15) NOT NULL," 18 | " `last_name` varchar(15) NOT NULL," 19 | " `gender` enum('M','F') NOT NULL," 20 | " `hire_date` date NOT NULL," 21 | " PRIMARY KEY (`emp_no`)" 22 | ") ") 23 | 24 | TABLES['clients'] = ( 25 | "CREATE TABLE `clients` (" 26 | " `acc_no` int NOT NULL PRIMARY KEY," 27 | " `type` enum('S','C') NOT NULL," 28 | " `first_name` varchar(15) NOT NULL," 29 | " `last_name` varchar(15) NOT NULL," 30 | " `gender` enum('M','F') NOT NULL," 31 | " `birth_date` date NOT NULL," 32 | " `accd` date NOT NULL," 33 | " `mobile_no` varchar(20) NOT NULL," 34 | " `email_id` varchar(25) NOT NULL," 35 | " `pass` varchar(8) NOT NULL" 36 | ") " 37 | ) 38 | 39 | TABLES['empass'] = ( 40 | "CREATE TABLE `empass` (" 41 | " `emp_no` int(5) NOT NULL," 42 | " `pass` varchar(8) NOT NULL," 43 | " PRIMARY KEY (`emp_no`)" 44 | ") " 45 | ) 46 | 47 | 48 | TABLES['savings'] = ( 49 | "CREATE TABLE `savings` (" 50 | " `acc_no` int(5) NOT NULL," 51 | " `balance` int NOT NULL," 52 | " `loan` enum('YES','NO') NOT NULL," 53 | " PRIMARY KEY (`acc_no`)" 54 | ") " 55 | ) 56 | 57 | TABLES['current'] = ( 58 | "CREATE TABLE `current` (" 59 | " `acc_no` int(5) NOT NULL," 60 | " `balance` int NOT NULL," 61 | " `overdraft` enum('YES','NO') NOT NULL," 62 | " PRIMARY KEY (`acc_no`)" 63 | ") " 64 | ) 65 | 66 | TABLES['loan'] = ( 67 | "CREATE TABLE `loan` (" 68 | " `acc_no` int(5) NOT NULL," 69 | " `loan_type` enum('PL','HL','EL','TL','BL') NOT NULL," 70 | " `loan_amt` int NOT NULL," 71 | " `time_period_months` int NOT NULL," 72 | " `iterest_perc_per_annum` int(1) NOT NULL," 73 | " `amt-per-month` int NOT NULL," 74 | " `remaining_amt` int NOT NULL," 75 | " PRIMARY KEY (`acc_no`)" 76 | ") " 77 | ) 78 | 79 | TABLES['overdraft']=( 80 | "CREATE TABLE `overdraft` (" 81 | " `acc_no` int(5) NOT NULL," 82 | " `overdraft_amt` int NOT NULL," 83 | " `od_with_interest_remaining` int NOT NULL," 84 | " PRIMARY KEY (`acc_no`)" 85 | ") " 86 | ) 87 | 88 | TABLES['cash_in_hand']=( 89 | "CREATE TABLE `cash_in_hand` (" 90 | " `acc_no` int(5) NOT NULL," 91 | " `cash_in_hand` int NOT NULL," 92 | " PRIMARY KEY (`acc_no`)" 93 | ") " 94 | ) 95 | 96 | 97 | ############################################################################################ 98 | query="" 99 | Password="" 100 | Database="" 101 | def sqlpwd(): 102 | global Password 103 | cred = open("files//cred.dat","rb") 104 | dat=pickle.load(cred) 105 | cred.close() 106 | Password=dat[0] 107 | return Password 108 | 109 | def sqldb(): 110 | global Database 111 | cred = open("files//cred.dat","rb") 112 | dat=pickle.load(cred) 113 | cred.close() 114 | Database=dat[1] 115 | return Database 116 | 117 | def connectionquery(): 118 | try: 119 | Databa=sqldb() 120 | Passwo=sqlpwd() 121 | query=mysql.connector.connect(host="localhost",user="root",password=Passwo,database=Databa) 122 | except: 123 | import traceback 124 | traceback.print_exc() 125 | query="" 126 | return query 127 | 128 | def querycheck(): 129 | global conn 130 | global cursor 131 | global existing 132 | conn=connectionquery() 133 | ans=False 134 | if conn!="": 135 | if conn.is_connected: 136 | print("Connection established successfully.") 137 | if check.check()==True: 138 | cursor=conn.cursor() 139 | #Table creation 140 | for table_name in TABLES: 141 | table_description = TABLES[table_name] 142 | try: 143 | print("Creating table {}: ".format(table_name), end='') 144 | cursor.execute(table_description) 145 | existing+=1 146 | except mysql.connector.Error as err: 147 | if err.errno == errorcode.ER_TABLE_EXISTS_ERROR: 148 | print("already exists.") 149 | existing+=1 150 | else: 151 | print(err.msg) 152 | else: 153 | print("OK") 154 | if existing==8: 155 | with open("files//firsttime.txt","w") as f: 156 | f.write("False") 157 | ans=True 158 | 159 | if not ans: 160 | print("There was a problem in connection") 161 | print("Maybe this is because you entered wrong credentials(password and database name)") 162 | return ans 163 | 164 | def mysqlsetup(): 165 | print("\n-----------------MYSQL Setup-------------------\n") 166 | print("Remember that you can't change the database afterwards\n") 167 | print("Create a database in your MYSQL Workbench.\n") 168 | Database=input("Enter database name: ") 169 | Password=input("Enter sql password (enter '' if nothing):") 170 | cred2= open("files//cred.dat","wb") 171 | data=[Password,Database] 172 | pickle.dump(data,cred2) 173 | cred2.close() 174 | querycheck() 175 | 176 | def setup(): 177 | global cursor 178 | global conn 179 | global existing 180 | while check.check(): 181 | print("\n\n-----------------Welcome to the Project!!!-------------------") 182 | print("This is the setup process which runs when the user uses the program for the first time.") 183 | print("\n----------------------Database Setup------------------------\n") 184 | print("1.Mysql 8.0 (Dependency MYSQL)") 185 | print("2.Standalone (Data files)") 186 | print("0.Cancel operation\n") 187 | ans2=input("How do you want to store the data? (1/2): ") 188 | if ans2 == "0": 189 | break 190 | elif ans2=="1": 191 | mysqlsetup() 192 | if existing==7: 193 | continue 194 | elif ans2=="2": 195 | print("\nThis is under development :). Please use mysql till then...") 196 | else: 197 | print("\nWrong input, (1/2).........") 198 | else: 199 | if querycheck(): 200 | return True -------------------------------------------------------------------------------- /src/main/OmJShah/main.py: -------------------------------------------------------------------------------- 1 | from initialization import setup 2 | from initialization import check 3 | from panels import accounttype 4 | from tools import connection 5 | while True: 6 | print("1.Continue") 7 | print("2.Quit") 8 | a=input("Enter your choice(1,2): ") 9 | if a == "1": 10 | if not check.check(): 11 | query,cur=connection.cc() 12 | accounttype.acctype(query,cur) 13 | break 14 | else: 15 | setup.setup() 16 | elif a == "2": 17 | print("Shutting down the program") 18 | break 19 | else: 20 | print("Wrong input.") -------------------------------------------------------------------------------- /src/main/OmJShah/panels/accounttype.py: -------------------------------------------------------------------------------- 1 | from panels import adminpanel 2 | from panels import employeepanel 3 | from panels import clientpanel 4 | def acctype(query,cur): 5 | while True: 6 | print("--------------Account Selector Menu--------------") 7 | print("1.Admin.") 8 | print("2.Employee.") 9 | print("3.Client.") 10 | print("Enter ~ to end process.") 11 | a=input("\nEnter your account type:") 12 | 13 | if a=='1': 14 | b=input("\nEnter admin password:") 15 | if b=="admin123": 16 | adminpanel.ap(query,cur) 17 | else: 18 | print("\nWrong password!\n") 19 | 20 | elif a=='2': 21 | b=input("\nEnter employee password:") 22 | if b=="emp123": 23 | employeepanel.ep(query,cur) 24 | else: 25 | print("\nWrong password!\n") 26 | 27 | elif a=='3': 28 | clientpanel.cp(query,cur) 29 | 30 | elif a=='~': 31 | print("\nShutting down the program.") 32 | break 33 | 34 | else: 35 | print("\nWrong input!") -------------------------------------------------------------------------------- /src/main/OmJShah/panels/adminpanel.py: -------------------------------------------------------------------------------- 1 | from admin import hireemployee 2 | from admin import fireemployee 3 | from admin import editemployee 4 | from admin import showemployee 5 | def ap(query,conn): 6 | print("\nWelcome Admin!!") 7 | 8 | while True: 9 | print("\n---------------------Admin Panel-----------------------") 10 | print("\n1.Hire Employee") 11 | print("2.Fire Employee") 12 | print("3.Change employee data") 13 | print("4.Show employee table") 14 | print("\nInput 0 to quit.") 15 | a=input("Enter choice:") 16 | if a=='1': 17 | hireemployee.ap1(query,conn) 18 | elif a=='2': 19 | fireemployee.ap2(query,conn) 20 | elif a=='3': 21 | editemployee.ap3(query,conn) 22 | elif a=='4': 23 | showemployee.ap4(conn) 24 | elif a=='0': 25 | print("Quit Admin Panel.") 26 | break 27 | else: 28 | print("Wrong input!(1,2,3)") -------------------------------------------------------------------------------- /src/main/OmJShah/panels/clientpanel.py: -------------------------------------------------------------------------------- 1 | from tools import dataentering 2 | from client import redeemcode 3 | from client import depositmoney 4 | from client import withdrawmoney 5 | from client import loan_od 6 | from client import transfermoney 7 | def cp(conn,cur): 8 | print("\n------------------Client Panel------------------") 9 | print("Welcome client!!") 10 | acc_no=dataentering.primary_key_no("acc_no") 11 | cur.execute("select first_name,last_name,pass,type from clients where acc_no = {}".format(acc_no)) 12 | result=cur.fetchall() 13 | if result == []: 14 | print("No account holder with this account number.") 15 | else: 16 | acc_type=result[0][3] 17 | if acc_type == 'S': acc_type="savings" 18 | if acc_type == 'C': acc_type="current" 19 | while True: 20 | print("\nInput ~ to quit") 21 | passwd=input("Enter password to continue: ") 22 | if passwd == "~": 23 | break 24 | elif passwd == result[0][2]: 25 | print("\n--------------------Welcome {} {}-------------------".format(result[0][0],result[0][1])) 26 | cmenu(conn,cur,acc_no,acc_type) 27 | else: 28 | print("Wrong password") 29 | 30 | def cmenu(conn,cur,acc_no,acc_type): 31 | cash_in_hand=dataentering.handcash(conn,cur,acc_no) 32 | print("\n Your Cash_In_Hand is {} currency".format(cash_in_hand)) 33 | print() 34 | print("1.Show Balance") 35 | print("2.Deposit money") 36 | print("3.Withdraw money") 37 | print("4.Redeem Code") 38 | if acc_type=='savings': 39 | print("5.Ask for loan / Check loan status") 40 | else: 41 | print("5.Check overdraft status") 42 | print("6.Transfer money to other account") 43 | print("~ to quit") 44 | choice=input("Enter your choice: ") 45 | if choice=="~": pass 46 | elif choice=="1": 47 | cur.execute("select balance from {} where acc_no={}".format(acc_type,acc_no)) 48 | balance=cur.fetchall() 49 | print("Your balance is: ",balance[0][0]) 50 | print() 51 | elif choice=="2": 52 | depositmoney.cp2(conn,cur,acc_type,acc_no) 53 | elif choice=="3": 54 | withdrawmoney.cp3(conn,cur,acc_type,acc_no) 55 | elif choice=="4": 56 | redeemcode.cp4(conn,cur,acc_type,acc_no) 57 | elif choice=="5": 58 | loan_od.cp5(cur,acc_type,acc_no) 59 | elif choice=="6": 60 | cur.execute("select balance from {} where acc_no={}".format(acc_type,acc_no)) 61 | balance=cur.fetchall() 62 | balance=balance[0][0] 63 | transfermoney.cp6(conn,cur,acc_type,acc_no,balance) 64 | else: 65 | print("Wrong input!!!!\n") 66 | -------------------------------------------------------------------------------- /src/main/OmJShah/panels/employeepanel.py: -------------------------------------------------------------------------------- 1 | from employee import createaccount 2 | from employee import editaccount 3 | from employee import deleteaccount 4 | from employee import showaccounts 5 | 6 | def ep(conn,cur): 7 | print("\nWelcome employee!!") 8 | print("Please log in with your creds (emp_id and password):") 9 | print("---------------------Employee Panel--------------------") 10 | print("1.Employee login.") 11 | print("2.Quit.") 12 | ch = input("Enter your choice:") 13 | logged_in= bool(False) 14 | if ch == "1": 15 | print("------------login panel-------------") 16 | logged_in=bool(True) 17 | elif ch == "2": 18 | pass 19 | else: 20 | print("Wrong input!!!(1 or 2 only)") 21 | if logged_in: 22 | while True: 23 | emp_no=input("Enter emp_no (max 5 int): ") 24 | if len(emp_no) <= 5: 25 | try: 26 | emp_no=int(emp_no) 27 | print("Done OK") 28 | except ValueError: 29 | print("emp_no should be an integer!!") 30 | else: 31 | break 32 | else: 33 | print("Maximum length is 5!") 34 | 35 | cur.execute("select * from empass where emp_no = {}".format(emp_no)) 36 | record=cur.fetchall() 37 | if record == []: 38 | print("This emp_no doesn't exist!!!") 39 | else: 40 | while True: 41 | password=record[0][1] 42 | print("\nInput ~ to quit.") 43 | a=input("Enter your password to continue:") 44 | print() 45 | if a==password: 46 | choice=menu(emp_no,cur) 47 | if choice=="1": 48 | createaccount.ep1(conn,cur) 49 | elif choice=="2": 50 | editaccount.ep2(conn,cur) 51 | elif choice=="3": 52 | deleteaccount.ep3(conn,cur) 53 | elif choice=="4": 54 | showaccounts.ep4(cur) 55 | elif choice=="0": 56 | break 57 | else: 58 | print("Wrong input!") 59 | elif a == "~" : break 60 | else: 61 | print("Wrong password!!") 62 | break 63 | 64 | def menu(x,cur): 65 | cur.execute("select first_name,last_name from employees where emp_no = {}".format(x)) 66 | record=cur.fetchone() 67 | print("---------------Welcome {} {} ----------------".format(record[0],record[1])) 68 | print("1.Create client account") 69 | print("2.Change client details") 70 | print("3.Close client account") 71 | print("4.Show client table") 72 | print("Enter 0 to quit.") 73 | choice=input("Enter your choice: ") 74 | return choice -------------------------------------------------------------------------------- /src/main/OmJShah/tests.py: -------------------------------------------------------------------------------- 1 | file=open("files//config.txt","r") 2 | x=file.read() 3 | print(x) 4 | #alter table current modify column overdraft enum('YES','NO'); 5 | #alter table current drop foreign key current_ibfk_1; 6 | #alter table savings drop foreign key savings_ibfk_1; -------------------------------------------------------------------------------- /src/main/OmJShah/tools/connection.py: -------------------------------------------------------------------------------- 1 | from initialization import check 2 | import mysql.connector 3 | import pickle 4 | def cc(): 5 | global cur 6 | global conn 7 | if not check.check(): 8 | cred = open("files//cred.dat","rb") 9 | dat=pickle.load(cred) 10 | cred.close() 11 | Passwo=dat[0] 12 | Databa=dat[1] 13 | conn=mysql.connector.connect(host="localhost",user="root",password=Passwo,database=Databa) 14 | cur=conn.cursor() 15 | return conn,cur 16 | else: 17 | return 0,0 -------------------------------------------------------------------------------- /src/main/OmJShah/tools/dataentering.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | import mysql.connector 3 | 4 | def age(birthdate): 5 | today = date.today() 6 | age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) 7 | return age 8 | 9 | 10 | def primary_key_no(x): 11 | #Employee number and client number 12 | while True: 13 | emp_no=input("Enter {} (max 5 int): ".format(x)) 14 | if len(emp_no) <= 5: 15 | try: 16 | emp_no=int(emp_no) 17 | print("Done OK") 18 | except ValueError: 19 | print("{} should be an integer!!".format(x)) 20 | else: 21 | return emp_no 22 | else: 23 | print("Maximum length is 5!") 24 | 25 | def birthdate(person,minage,maxage): 26 | #Employee Birth date and client birth date 27 | while True: 28 | while True: 29 | year=input("Enter birth year (4 int): ") 30 | if len(year) == 4: 31 | try: 32 | year=int(year) 33 | print("Done OK") 34 | except ValueError: 35 | print("year should be an integer!!") 36 | else: 37 | break 38 | else: 39 | print("Year consists of 4 integers!!") 40 | 41 | while True: 42 | month=input("Enter birth month (2 int) (01 to 12): ") 43 | if len(month) == 2: 44 | try: 45 | month=int(month) 46 | print("Done OK") 47 | except ValueError: 48 | print("month should be an integer!!") 49 | else: 50 | break 51 | else: 52 | print("Month consists of 2 integers!!") 53 | 54 | while True: 55 | day=input("Enter birth day (2 int) : ") 56 | if len(day) == 2: 57 | try: 58 | day=int(day) 59 | print("Done OK") 60 | except ValueError: 61 | print("Date should be an integer!!") 62 | else: 63 | break 64 | else: 65 | print("Date consists of 2 integers!!") 66 | 67 | try: 68 | birth_date=date(year,month,day) 69 | except ValueError: 70 | import traceback 71 | traceback.print_exc() 72 | else: 73 | if age(birth_date)>=minage and age(birth_date)<=maxage: 74 | return birth_date 75 | else: 76 | if age(birth_date)maxage: 167 | print("{} must be below {} years of age!!".format(person,maxage)) 168 | elif age(birth_date)-age(hire_date)>=minage: 169 | break 170 | else: 171 | print("{} must atleast be {} years of age!!".format(person,minage)) 172 | return hire_date 173 | 174 | def mobileno(): 175 | while True: 176 | mobile_no_str=input("Enter mobile no. (7 to 15 int): ") 177 | mobile_no=mobile_no_str 178 | #Thanks to the international phone numbering plan (ITU-T E. 164), 179 | #phone numbers cannot contain more than 15 digits. The shortest 180 | #international phone numbers in use contain seven digits. 181 | try: 182 | mobile_no=int(mobile_no) 183 | except ValueError: 184 | print("mobile_no should be an integer!!") 185 | else: 186 | if len(mobile_no_str)>6 and len(mobile_no_str)<16: 187 | mobile_no=mobile_no_str 188 | lmn=len(mobile_no) 189 | break 190 | else: 191 | print("Mobile number can have min 7 digits and max 15!!") 192 | return mobile_no,lmn 193 | 194 | def email(): 195 | while True: 196 | email_id=input("Enter client Email ID (max 25 char): ") 197 | if len(email_id)<26: 198 | break 199 | else: 200 | print("Maximum 25 characters") 201 | return email_id 202 | 203 | def clientpassword(): 204 | while True: 205 | password=input("Enter client login password(max 8 characters, min 4): ") 206 | lp=len(password) 207 | if lp>8: 208 | print("Max 8 characters only.") 209 | elif lp<4: 210 | print("Minimum 4 characters to be entered.") 211 | else: 212 | break 213 | return password,lp 214 | 215 | def tableupdate(conn,cur,query,data): 216 | try: 217 | cur.execute(query,data) 218 | conn.commit() 219 | except mysql.connector.Error as err: 220 | print(err.msg) 221 | print("-----------Value addition/deletion was unsuccessful!!!!-------------") 222 | else: 223 | return bool(True) 224 | 225 | #bank balance 226 | def balance(): 227 | while True: 228 | bank_balance=input("Enter starting balance (min 1000 currency): ") 229 | if len(bank_balance) >= 3: 230 | try: 231 | bank_balance=int(bank_balance) 232 | print("Done OK") 233 | except ValueError: 234 | print("Balance should be an integer!!") 235 | else: 236 | if bank_balance>=1000: 237 | return bank_balance 238 | else: 239 | print("Minimum balance is 1000 currency") 240 | 241 | #Withdraw amount and Deposit amount 242 | def amounts(deposit_or_withdraw_or_transfer,cash_in_hand_or_balance,acc_type): 243 | while True: 244 | print() 245 | print("--------------------{} screen-------------------".format(deposit_or_withdraw_or_transfer)) 246 | amt=input("Enter amount to {}: ".format(deposit_or_withdraw_or_transfer)) 247 | try: 248 | amt=int(amt) 249 | print("Done OK") 250 | except ValueError: 251 | print("{} amount should be an integer!!".format(deposit_or_withdraw_or_transfer)) 252 | else: 253 | if amt<=cash_in_hand_or_balance: 254 | return amt,None 255 | else: 256 | if deposit_or_withdraw_or_transfer=="transfer": 257 | if acc_type=="current": 258 | overdraft=amt-cash_in_hand_or_balance 259 | if (overdraft) <= 50000: 260 | return amt,overdraft 261 | else: 262 | return bool(False),None 263 | else: 264 | print("You do not have enough balance\n") 265 | else: 266 | if deposit_or_withdraw_or_transfer=="deposit": 267 | print("You do not have sufficient cash_in_hand\n") 268 | else: 269 | print("You do not have enough balance\n") 270 | return bool(False),None 271 | 272 | def handcash(conn,cur,acc_no): 273 | cur.execute("select cash_in_hand from cash_in_hand where acc_no={}".format(acc_no)) 274 | cash_in_hand=cur.fetchall() 275 | if cash_in_hand==[]: 276 | query="insert into cash_in_hand values(%s,0)" 277 | data=(acc_no,) 278 | done=tableupdate(conn,cur,query,data) 279 | if done: 280 | cash_in_hand=0 281 | else: 282 | print("Unable to figure out your cash in hand values.") 283 | else: 284 | cash_in_hand=cash_in_hand[0][0] 285 | return cash_in_hand --------------------------------------------------------------------------------