├── Accnt_Record.txt ├── new.gif ├── .DS_Store ├── credit.gif ├── debit.gif ├── login.gif ├── logout.gif ├── pile1.gif ├── quit.GIF ├── balance1.gif ├── transaction.gif ├── README.txt ├── BankSystem.py └── GUI-BankSystem.py /Accnt_Record.txt: -------------------------------------------------------------------------------- 1 | 63710015000 -------------------------------------------------------------------------------- /new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/new.gif -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/.DS_Store -------------------------------------------------------------------------------- /credit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/credit.gif -------------------------------------------------------------------------------- /debit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/debit.gif -------------------------------------------------------------------------------- /login.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/login.gif -------------------------------------------------------------------------------- /logout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/logout.gif -------------------------------------------------------------------------------- /pile1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/pile1.gif -------------------------------------------------------------------------------- /quit.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/quit.GIF -------------------------------------------------------------------------------- /balance1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/balance1.gif -------------------------------------------------------------------------------- /transaction.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prashasy/BankingSystem/HEAD/transaction.gif -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | My Banking System code using Python 3.6. 2 | It has a GUI using tkinter and file-handling as back-end. 3 | Suggestions are welcome!! -------------------------------------------------------------------------------- /BankSystem.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from time import gmtime, strftime 3 | class Bank: 4 | f1=open("Accnt_Record.txt",'r+') 5 | a=int(f1.readline())+1 6 | f1.close() 7 | 8 | #def __init__(self): 9 | 10 | def BankSystem(self): 11 | print("Enter your choice\n") 12 | print("1] Create an account in our bank\n") 13 | print("2] Credit amount in your acount\n") 14 | print("3] Debit amount from your account\n") 15 | print("4] Check Balance\n") 16 | print("5] Transaction Summary") 17 | choice=int(input("Enter your choice:")) 18 | 19 | if (choice==1): 20 | name=input("Enter name:") 21 | amt=input("\nEnter opening balance:") 22 | self.create(name,amt) 23 | elif (choice==2 or choice==3 or choice==4 or choice==5): 24 | name=input("Enter name: ") 25 | accnt_no=input("\nEnter Account Number:") 26 | 27 | f=open(str(accnt_no)+"-pin.txt",'r') 28 | p=int(f.readline()) 29 | f.close() 30 | for i in range(0,3): 31 | pin=input("Enter pin:") 32 | if( not (pin == p)): 33 | print ("PIN incorret.Try Again") 34 | if(i==2): return 35 | else: break 36 | 37 | if(choice==2 or choice==3): 38 | amt=input("\nEnter amount:") 39 | if(choice==2):self.credit(accnt_no,name,amt) 40 | if(choice==3):self.debit(accnt_no,name,amt) 41 | if(choice==4):self.check_bal(accnt_no) 42 | 43 | if(choice==5):self.transact_history(accnt_no) 44 | print("Thankyou for Banking with us!!") 45 | return 46 | def check_bal(self,accnt_no): 47 | f=open(str(accnt_no)+".txt",'r') 48 | cb=int(f.readline()) 49 | print("\nCurrent Balance=(INR)",cb) 50 | f.close() 51 | return 52 | def update(self,cb,name,accnt_no): 53 | f=open(str(accnt_no)+".txt","w") 54 | f.write(str(cb)+"\n") 55 | f.write(str(name)+"\n") 56 | f.write(str(accnt_no)+"\n") 57 | f.close() 58 | return 59 | def debit(self,accnt_no,name,amt): 60 | f=open(str(accnt_no)+".txt",'r+') 61 | cb=int(f.readline()) 62 | if(cb=1 and (pin/100000)==0): 94 | break 95 | if(i==1): 96 | print ("You have exhausted your two attempts.Try again later!!") 97 | return 98 | print("Enter pin of exaclty 4 digits!!") 99 | 100 | fpin=open(str(accnt_no)+"-pin.txt",'w') 101 | fpin.write(str(pin)) 102 | fpin.close() 103 | 104 | f1=open("Accnt_Record.txt",'w') 105 | f1.write(str(Bank.a)) 106 | f1.close() 107 | Bank.a+=1 108 | f=open(str(accnt_no)+".txt","w") 109 | f.write(str(amt)+"\n") 110 | f.write(str(name)+"\n") 111 | f.write(str(accnt_no)+"\n") 112 | f.close() 113 | ff=open(str(accnt_no)+"-rec.txt",'w') 114 | ff.write("Date \tCredit\t Debit\tBalance\n") 115 | ff.write(str(strftime("%y-%m-%d %h:%m:%s",gmtime()))+"\t"+str(amt)+"\t \t"+str(amt)+"\n") 116 | ff.close() 117 | print ("""Congratulations!! 118 | Account created successfully!! 119 | Your Account No. is - """,accnt_no) 120 | return 121 | print ("Welcome to Apna bank!!") 122 | while True: 123 | ch=int(input("Enter 1 to continue 0 to quit: ")) 124 | if ch==0: 125 | sys.exit(0) 126 | b=Bank() 127 | Bank.BankSystem(b) 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /GUI-BankSystem.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import messagebox 3 | from time import gmtime, strftime 4 | 5 | 6 | def is_number(s): 7 | try: 8 | float(s) 9 | return 1 10 | except ValueError: 11 | return 0 12 | 13 | def check_acc_nmb(num): 14 | try: 15 | fpin=open(num+".txt",'r') 16 | except FileNotFoundError: 17 | messagebox.showinfo("Error","Invalid Credentials!\nTry Again!") 18 | return 0 19 | fpin.close() 20 | return 21 | 22 | def home_return(master): 23 | master.destroy() 24 | Main_Menu() 25 | 26 | def write(master,name,oc,pin): 27 | 28 | if( (is_number(name)) or (is_number(oc)==0) or (is_number(pin)==0)or name==""): 29 | messagebox.showinfo("Error","Invalid Credentials\nPlease try again.") 30 | master.destroy() 31 | return 32 | 33 | f1=open("Accnt_Record.txt",'r') 34 | accnt_no=int(f1.readline()) 35 | accnt_no+=1 36 | f1.close() 37 | 38 | f1=open("Accnt_Record.txt",'w') 39 | f1.write(str(accnt_no)) 40 | f1.close() 41 | 42 | fdet=open(str(accnt_no)+".txt","w") 43 | fdet.write(pin+"\n") 44 | fdet.write(oc+"\n") 45 | fdet.write(str(accnt_no)+"\n") 46 | fdet.write(name+"\n") 47 | fdet.close() 48 | 49 | frec=open(str(accnt_no)+"-rec.txt",'w') 50 | frec.write("Date Credit Debit Balance\n") 51 | frec.write(str(strftime("[%Y-%m-%d] [%H:%M:%S] ",gmtime()))+" "+oc+" "+oc+"\n") 52 | frec.close() 53 | 54 | messagebox.showinfo("Details","Your Account Number is:"+str(accnt_no)) 55 | master.destroy() 56 | return 57 | 58 | def crdt_write(master,amt,accnt,name): 59 | 60 | if(is_number(amt)==0): 61 | messagebox.showinfo("Error","Invalid Credentials\nPlease try again.") 62 | master.destroy() 63 | return 64 | 65 | fdet=open(accnt+".txt",'r') 66 | pin=fdet.readline() 67 | camt=int(fdet.readline()) 68 | fdet.close() 69 | amti=int(amt) 70 | cb=amti+camt 71 | fdet=open(accnt+".txt",'w') 72 | fdet.write(pin) 73 | fdet.write(str(cb)+"\n") 74 | fdet.write(accnt+"\n") 75 | fdet.write(name+"\n") 76 | fdet.close() 77 | frec=open(str(accnt)+"-rec.txt",'a+') 78 | frec.write(str(strftime("[%Y-%m-%d] [%H:%M:%S] ",gmtime()))+" "+str(amti)+" "+str(cb)+"\n") 79 | frec.close() 80 | messagebox.showinfo("Operation Successfull!!","Amount Credited Successfully!!") 81 | master.destroy() 82 | return 83 | 84 | def debit_write(master,amt,accnt,name): 85 | 86 | if(is_number(amt)==0): 87 | messagebox.showinfo("Error","Invalid Credentials\nPlease try again.") 88 | master.destroy() 89 | return 90 | 91 | fdet=open(accnt+".txt",'r') 92 | pin=fdet.readline() 93 | camt=int(fdet.readline()) 94 | fdet.close() 95 | if(int(amt)>camt): 96 | messagebox.showinfo("Error!!","You dont have that amount left in your account\nPlease try again.") 97 | else: 98 | amti=int(amt) 99 | cb=camt-amti 100 | fdet=open(accnt+".txt",'w') 101 | fdet.write(pin) 102 | fdet.write(str(cb)+"\n") 103 | fdet.write(accnt+"\n") 104 | fdet.write(name+"\n") 105 | fdet.close() 106 | frec=open(str(accnt)+"-rec.txt",'a+') 107 | frec.write(str(strftime("[%Y-%m-%d] [%H:%M:%S] ",gmtime()))+" "+" "+str(amti)+" "+str(cb)+"\n") 108 | frec.close() 109 | messagebox.showinfo("Operation Successfull!!","Amount Debited Successfully!!") 110 | master.destroy() 111 | return 112 | 113 | def Cr_Amt(accnt,name): 114 | creditwn=tk.Tk() 115 | creditwn.geometry("600x300") 116 | creditwn.title("Credit Amount") 117 | creditwn.configure(bg="orange") 118 | fr1=tk.Frame(creditwn,bg="blue") 119 | l_title=tk.Message(creditwn,text="JUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 120 | l_title.config(font=("Courier","50","bold")) 121 | l_title.pack(side="top") 122 | l1=tk.Label(creditwn,relief="raised",text="Enter Amount to be credited: ") 123 | e1=tk.Entry(creditwn,relief="raised") 124 | l1.pack(side="top") 125 | e1.pack(side="top") 126 | b=tk.Button(creditwn,text="Credit",relief="raised",command=lambda:crdt_write(creditwn,e1.get(),accnt,name)) 127 | b.pack(side="top") 128 | creditwn.bind("",lambda x:crdt_write(creditwn,e1.get(),accnt,name)) 129 | 130 | 131 | def De_Amt(accnt,name): 132 | debitwn=tk.Tk() 133 | debitwn.geometry("600x300") 134 | debitwn.title("Debit Amount") 135 | debitwn.configure(bg="orange") 136 | fr1=tk.Frame(debitwn,bg="blue") 137 | l_title=tk.Message(debitwn,text="JUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 138 | l_title.config(font=("Courier","50","bold")) 139 | l_title.pack(side="top") 140 | l1=tk.Label(debitwn,relief="raised",text="Enter Amount to be debited: ") 141 | e1=tk.Entry(debitwn,relief="raised") 142 | l1.pack(side="top") 143 | e1.pack(side="top") 144 | b=tk.Button(debitwn,text="Debit",relief="raised",command=lambda:debit_write(debitwn,e1.get(),accnt,name)) 145 | b.pack(side="top") 146 | debitwn.bind("",lambda x:debit_write(debitwn,e1.get(),accnt,name)) 147 | 148 | 149 | 150 | 151 | def disp_bal(accnt): 152 | fdet=open(accnt+".txt",'r') 153 | fdet.readline() 154 | bal=fdet.readline() 155 | fdet.close() 156 | messagebox.showinfo("Balance",bal) 157 | 158 | 159 | 160 | 161 | def disp_tr_hist(accnt): 162 | disp_wn=tk.Tk() 163 | disp_wn.geometry("900x600") 164 | disp_wn.title("Transaction History") 165 | disp_wn.configure(bg="orange") 166 | fr1=tk.Frame(disp_wn,bg="blue") 167 | l_title=tk.Message(disp_wn,text="JUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 168 | l_title.config(font=("Courier","50","bold")) 169 | l_title.pack(side="top") 170 | fr1=tk.Frame(disp_wn) 171 | fr1.pack(side="top") 172 | l1=tk.Message(disp_wn,text="Your Transaction History:",padx=100,pady=20,width=1000,bg="blue",fg="orange",relief="raised") 173 | l1.pack(side="top") 174 | fr2=tk.Frame(disp_wn) 175 | fr2.pack(side="top") 176 | frec=open(accnt+"-rec.txt",'r') 177 | for line in frec: 178 | l=tk.Message(disp_wn,anchor="w",text=line,relief="raised",width=2000) 179 | l.pack(side="top") 180 | b=tk.Button(disp_wn,text="Quit",relief="raised",command=disp_wn.destroy) 181 | b.pack(side="top") 182 | frec.close() 183 | 184 | def logged_in_menu(accnt,name): 185 | rootwn=tk.Tk() 186 | rootwn.geometry("1600x500") 187 | rootwn.title("JUIT BANK-"+name) 188 | rootwn.configure(background='orange') 189 | fr1=tk.Frame(rootwn) 190 | fr1.pack(side="top") 191 | l_title=tk.Message(rootwn,text="WELCOME TO\nJUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 192 | l_title.config(font=("Courier","50","bold")) 193 | l_title.pack(side="top") 194 | label=tk.Label(text="Logged in as: "+name,relief="raised",bg="black",fg="white",anchor="center",justify="center") 195 | label.pack(side="top") 196 | img2=tk.PhotoImage(file="credit.gif") 197 | myimg2=img2.subsample(2,2) 198 | img3=tk.PhotoImage(file="debit.gif") 199 | myimg3=img3.subsample(2,2) 200 | img4=tk.PhotoImage(file="balance1.gif") 201 | myimg4=img4.subsample(2,2) 202 | img5=tk.PhotoImage(file="transaction.gif") 203 | myimg5=img5.subsample(2,2) 204 | b2=tk.Button(image=myimg2,command=lambda: Cr_Amt(accnt,name)) 205 | b2.image=myimg2 206 | b3=tk.Button(image=myimg3,command=lambda: De_Amt(accnt,name)) 207 | b3.image=myimg3 208 | b4=tk.Button(image=myimg4,command=lambda: disp_bal(accnt)) 209 | b4.image=myimg4 210 | b5=tk.Button(image=myimg5,command=lambda: disp_tr_hist(accnt)) 211 | b5.image=myimg5 212 | 213 | img6=tk.PhotoImage(file="logout.gif") 214 | myimg6=img6.subsample(2,2) 215 | b6=tk.Button(image=myimg6,relief="raised",command=lambda: logout(rootwn)) 216 | b6.image=myimg6 217 | 218 | 219 | b2.place(x=100,y=150) 220 | b3.place(x=100,y=220) 221 | b4.place(x=900,y=150) 222 | b5.place(x=900,y=220) 223 | b6.place(x=500,y=400) 224 | 225 | 226 | def logout(master): 227 | 228 | messagebox.showinfo("Logged Out","You Have Been Successfully Logged Out!!") 229 | master.destroy() 230 | Main_Menu() 231 | 232 | def check_log_in(master,name,acc_num,pin): 233 | if(check_acc_nmb(acc_num)==0): 234 | master.destroy() 235 | Main_Menu() 236 | return 237 | 238 | if( (is_number(name)) or (is_number(pin)==0) ): 239 | messagebox.showinfo("Error","Invalid Credentials\nPlease try again.") 240 | master.destroy() 241 | Main_Menu() 242 | else: 243 | master.destroy() 244 | logged_in_menu(acc_num,name) 245 | 246 | 247 | def log_in(master): 248 | master.destroy() 249 | loginwn=tk.Tk() 250 | loginwn.geometry("600x300") 251 | loginwn.title("Log in") 252 | loginwn.configure(bg="orange") 253 | fr1=tk.Frame(loginwn,bg="blue") 254 | l_title=tk.Message(loginwn,text="JUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 255 | l_title.config(font=("Courier","50","bold")) 256 | l_title.pack(side="top") 257 | l1=tk.Label(loginwn,text="Enter Name:",relief="raised") 258 | l1.pack(side="top") 259 | e1=tk.Entry(loginwn) 260 | e1.pack(side="top") 261 | l2=tk.Label(loginwn,text="Enter account number:",relief="raised") 262 | l2.pack(side="top") 263 | e2=tk.Entry(loginwn) 264 | e2.pack(side="top") 265 | l3=tk.Label(loginwn,text="Enter your PIN:",relief="raised") 266 | l3.pack(side="top") 267 | e3=tk.Entry(loginwn,show="*") 268 | e3.pack(side="top") 269 | b=tk.Button(loginwn,text="Submit",command=lambda: check_log_in(loginwn,e1.get().strip(),e2.get().strip(),e3.get().strip())) 270 | b.pack(side="top") 271 | b1=tk.Button(text="HOME",relief="raised",bg="black",fg="white",command=lambda: home_return(loginwn)) 272 | b1.pack(side="top") 273 | loginwn.bind("",lambda x:check_log_in(loginwn,e1.get().strip(),e2.get().strip(),e3.get().strip())) 274 | 275 | 276 | def Create(): 277 | 278 | crwn=tk.Tk() 279 | crwn.geometry("600x300") 280 | crwn.title("Create Account") 281 | crwn.configure(bg="orange") 282 | fr1=tk.Frame(crwn,bg="blue") 283 | l_title=tk.Message(crwn,text="JUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 284 | l_title.config(font=("Courier","50","bold")) 285 | l_title.pack(side="top") 286 | l1=tk.Label(crwn,text="Enter Name:",relief="raised") 287 | l1.pack(side="top") 288 | e1=tk.Entry(crwn) 289 | e1.pack(side="top") 290 | l2=tk.Label(crwn,text="Enter opening credit:",relief="raised") 291 | l2.pack(side="top") 292 | e2=tk.Entry(crwn) 293 | e2.pack(side="top") 294 | l3=tk.Label(crwn,text="Enter desired PIN:",relief="raised") 295 | l3.pack(side="top") 296 | e3=tk.Entry(crwn,show="*") 297 | e3.pack(side="top") 298 | b=tk.Button(crwn,text="Submit",command=lambda: write(crwn,e1.get().strip(),e2.get().strip(),e3.get().strip())) 299 | b.pack(side="top") 300 | crwn.bind("",lambda x:write(crwn,e1.get().strip(),e2.get().strip(),e3.get().strip())) 301 | return 302 | 303 | 304 | def Main_Menu(): 305 | 306 | 307 | rootwn=tk.Tk() 308 | rootwn.geometry("1600x500") 309 | rootwn.title("JUIT Bank") 310 | rootwn.configure(background='orange') 311 | fr1=tk.Frame(rootwn) 312 | fr1.pack(side="top") 313 | bg_image = tk.PhotoImage(file ="pile1.gif") 314 | x = tk.Label (image = bg_image) 315 | x.place(y=-400) 316 | l_title=tk.Message(text="WELCOME TO\nJUIT BANK",relief="raised",width=2000,padx=600,pady=0,fg="white",bg="black",justify="center",anchor="center") 317 | l_title.config(font=("Courier","50","bold")) 318 | l_title.pack(side="top") 319 | imgc1=tk.PhotoImage(file="new.gif") 320 | imglo=tk.PhotoImage(file="login.gif") 321 | imgc=imgc1.subsample(2,2) 322 | imglog=imglo.subsample(2,2) 323 | 324 | b1=tk.Button(image=imgc,command=Create) 325 | b1.image=imgc 326 | b2=tk.Button(image=imglog,command=lambda: log_in(rootwn)) 327 | b2.image=imglog 328 | img6=tk.PhotoImage(file="quit.gif") 329 | myimg6=img6.subsample(2,2) 330 | 331 | b6=tk.Button(image=myimg6,command=rootwn.destroy) 332 | b6.image=myimg6 333 | b1.place(x=800,y=300) 334 | b2.place(x=800,y=200) 335 | b6.place(x=920,y=400) 336 | 337 | rootwn.mainloop() 338 | 339 | Main_Menu() --------------------------------------------------------------------------------