Guest User

Untitled

a guest
Dec 26th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.97 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import messagebox
  3. import os,datetime,random,shutil
  4.  
  5. class transact(object):
  6. def __init__(self):
  7. self.transaction()
  8. def transaction(self):
  9. def deposit_():
  10. def deposit_entry():
  11. fh=open('tot_userid.txt','r+')
  12. if '$'+str(trans_acc.get())+'$' in fh.read():
  13. fh.seek(0)
  14. for x in fh.readlines():
  15. splt=x.split('$')
  16. if splt[1]==str(trans_acc.get()):
  17. user_id=(splt[2])
  18. else:
  19. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  20. return
  21. fh_=open('cust_data/'+user_id+'/transaction.txt','r+')
  22. money=fh_.readlines()[-1]
  23. st=money.split('$')
  24. money=st[2]
  25. file=open('cust_data/'+user_id+'/transaction.txt','a+')
  26. amount=e1.get()
  27. if int(e1.get())<=0:
  28. messagebox.showerror('Error','Amount Not valid')
  29. return
  30. else:
  31. pass
  32. new_money=str(int(money)+int(amount))
  33. file.writelines(['$'+str(datetime.datetime.now().day)+'/'+str(datetime.datetime.now().month)+'/'+str(datetime.datetime.now().year)+'$'+new_money+'$'+amount+'$'+'Deposit'+'$'+'\n'])
  34. def transaction_successful():
  35. messagebox.showinfo('Succcess','Transaction Successful')
  36. deposit.destroy()
  37. transaction_successful()
  38. fh=open('tot_userid.txt','r+')
  39. if '$'+str(trans_acc.get())+'$' in fh.read():
  40. fh.seek(0)
  41. for x in fh.readlines():
  42. splt=x.split('$')
  43. if splt[1]==str(trans_acc.get()):
  44. user_id=(splt[2])
  45. else:
  46. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  47. return
  48. fh_=open('cust_data/'+user_id+'/transaction.txt','r+')
  49. money=fh_.readlines()[-1]
  50. st=money.split('$')
  51. money=st[2]
  52. deposit=Tk()
  53. deposit.iconbitmap('bank.ico')
  54. deposit.config(bg='#D6F5FF')
  55. Label(deposit, text='Available Amount:- '+money, width=22, anchor='center',font=('Arial',16),bg='#D6F5FF' ).pack(padx=10,pady=10)
  56. deposit.title('Enter Deposit Amount')
  57. e1=Entry(deposit,bd=5)
  58. e1.pack()
  59. button=Button(deposit,text='Continue',command=deposit_entry)
  60. button.pack(pady=10)
  61. def withdrawl_():
  62. def withdrawl_entry():
  63. fh=open('tot_userid.txt','r+')
  64. if '$'+str(trans_acc.get())+'$' in fh.read():
  65. fh.seek(0)
  66. for x in fh.readlines():
  67. splt=x.split('$')
  68. if splt[1]==str(trans_acc.get()):
  69. user_id=(splt[2])
  70. else:
  71. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  72. return
  73. fh_=open('cust_data/'+user_id+'/transaction.txt','r+')
  74. money=fh_.readlines()[-1]
  75. st=money.split('$')
  76. money=st[2]
  77. file=open('cust_data/'+user_id+'/transaction.txt','a+')
  78. amount=e2.get()
  79. new_money=str(int(money)-int(amount))
  80. if int(e2.get())<=0:
  81. messagebox.showerror('Error','Amount Not valid')
  82. return
  83. elif int(e2.get())<500:
  84. messagebox.showerror('Error','Amount should be more than Rs 500')
  85. return
  86. elif int(e2.get())>int(money):
  87. messagebox.showerror('Error','Withdrawl amount exceed current Balance')
  88. return
  89. elif int(new_money)<500:
  90. messagebox.showerror('Error','You cannot withdraw this much amount')
  91. return
  92. else:
  93. pass
  94. file.writelines(['$'+str(datetime.datetime.now().day)+'/'+str(datetime.datetime.now().month)+'/'+str(datetime.datetime.now().year)+'$'+new_money+'$'+amount+'$'+'Withdrawl'+'$'+'\n'])
  95. def transaction_successful():
  96. messagebox.showinfo('Succcess','Transaction Successful')
  97. withdrawl.destroy()
  98. transaction_successful()
  99. fh=open('tot_userid.txt','r+')
  100. if '$'+str(trans_acc.get())+'$' in fh.read():
  101. fh.seek(0)
  102. for x in fh.readlines():
  103. splt=x.split('$')
  104. if splt[1]==str(trans_acc.get()):
  105. user_id=(splt[2])
  106. else:
  107. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  108. return
  109. fh_=open('cust_data/'+user_id+'/transaction.txt','r+')
  110. money=fh_.readlines()[-1]
  111. st=money.split('$')
  112. money=st[2]
  113. withdrawl=Tk()
  114. withdrawl.config(bg='#D6F5FF')
  115. withdrawl.iconbitmap('bank.ico')
  116. Label(withdrawl, text='Available Amount:- '+money, width=22, anchor='center',font=('Arial',16),bg='#D6F5FF' ).pack(padx=10,pady=10)
  117. withdrawl.title('Enter Withdraw Amount')
  118. e2=Entry(withdrawl,bd=5)
  119. e2.pack()
  120. button=Button(withdrawl,text='Continue',command=withdrawl_entry)
  121. button.pack(pady=10)
  122. self.transact=Tk()
  123. self.transact.geometry('295x242')
  124. self.transact.maxsize(height=242,width=295)
  125. self.transact.iconbitmap('bank.ico')
  126. self.transact.config(bg='#D6F5FF')
  127. self.transact.title('Transaction')
  128. Label(self.transact, text='Enter Account Number', width=22, anchor='center',font=('Arial',16),bg='#D6F5FF' ).pack(padx=10,pady=10)
  129. trans_acc=Entry(self.transact,bd=5)
  130. trans_acc.pack()
  131. def temp_disp():
  132. fh=open('tot_userid.txt','r+')
  133. if '$'+str(trans_acc.get())+'$' in fh.read():
  134. fh.seek(0)
  135. for x in fh.readlines():
  136. splt=x.split('$')
  137. if splt[1]==str(trans_acc.get()):
  138. user_id=(splt[2])
  139. else:
  140. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  141. return
  142. fh_=open('cust_data/'+user_id+'/transaction.txt','r+')
  143. money=fh_.readlines()[-1]
  144. st=money.split('$')
  145. money=st[2]
  146. Label(self.transact,text='Current Balance: '+money, width=22, anchor='center',font=('Times New Roman',14),bg='#D6F5FF' ).pack(padx=10,pady=10)
  147. Depo=Button(self.transact,text='Deposit ',command=deposit_)
  148. Depo.pack()
  149. Depo.place(x=60,y=170)
  150. With=Button(self.transact,text='Withdraw',command=withdrawl_)
  151. With.pack()
  152. With.place(x=160,y=170)
  153. Button(self.transact,text='Submit',command=temp_disp).pack(padx=10,pady=10)
  154.  
  155. class after_sign_in_customer():
  156. def __init__(self,userid):
  157. self.sign_in_after(userid)
  158. self.userid=userid
  159. def sign_in_after(self,userid):
  160. self.sign_in=Tk()
  161. self.sign_in.geometry('566x227')
  162. self.sign_in.maxsize(height=227,width=566)
  163. self.sign_in.title('Account')
  164. self.sign_in.iconbitmap('bank.ico')
  165. self.sign_in.config(bg='#D6F5FF')
  166. def sign_out():
  167. messagebox.showinfo('Have A Nice Day','You Are Signed Out')
  168. self.sign_in.destroy()
  169. start=homepage()
  170. signout=Button(self.sign_in,anchor='ne',text='Sign Out',command=sign_out)
  171. signout.pack(side='right')
  172. signout.place(x=620,y=5)
  173. def back_sign_in():
  174. self.acc_info.destroy()
  175. start=self.sign_in_after(userid)
  176. def acc_info():
  177. self.sign_in.destroy()
  178. self.acc_info=Tk()
  179. self.acc_info.config(bg="#D6F5FF")
  180. self.acc_info.iconbitmap('bank.ico')
  181. self.acc_info.title('Account Database')
  182. self.acc_info.geometry('298x277')
  183. file=open('cust_data/'+userid+'/acc_info.txt','r+')
  184. st=file.readlines()
  185. acc_label=Label(self.acc_info, text='Account Information',bg="#D6F5FF",font=('PRIMETIME',16), anchor='center')
  186. acc_label.pack(pady=15)
  187. name_label=Label(self.acc_info, text='Name',bg="#D6F5FF")
  188. name_label.pack()
  189. name_label.place(x=50,y=90)
  190. name_label1=Label(self.acc_info,text=str(st[0].rstrip('\n')+' '+st[1].rstrip('\n')),bg="#D6F5FF")
  191. name_label1.pack()
  192. name_label1.place(x=150,y=90)
  193. fname_label=Label(self.acc_info,text="Father's Name",bg="#D6F5FF")
  194. fname_label.pack()
  195. fname_label.place(x=50,y=115)
  196. fname_label1=Label(self.acc_info,text=str(st[2]),bg="#D6F5FF")
  197. fname_label1.pack()
  198. fname_label1.place(x=150,y=115)
  199. pan_label=Label(self.acc_info,text="PAN No.",bg="#D6F5FF")
  200. pan_label.pack()
  201. pan_label.place(x=50,y=140)
  202. pan_label1=Label(self.acc_info,text=str(st[4]),bg="#D6F5FF")
  203. pan_label1.pack()
  204. pan_label1.place(x=150,y=140)
  205. mob_no=Label(self.acc_info,text="Mobile No.",bg="#D6F5FF")
  206. mob_no.pack()
  207. mob_no.place(x=50,y=165)
  208. mob_no1=Label(self.acc_info,text=str(st[12]),bg="#D6F5FF")
  209. mob_no1.pack()
  210. mob_no1.place(x=150,y=165)
  211. email_id=Label(self.acc_info,text="Email Id ",bg="#D6F5FF")
  212. email_id.pack()
  213. email_id.place(x=50,y=190)
  214. email_id1=Label(self.acc_info,text=str(st[13]),bg="#D6F5FF")
  215. email_id1.pack()
  216. email_id1.place(x=150,y=190)
  217. Button(self.acc_info,text='Back', anchor='center',command=back_sign_in).pack(side='bottom',padx=10,pady=10)
  218. self.acc_info.mainloop()
  219. def last_5():
  220. self.sign_in.destroy()
  221. self.last_5=Tk()
  222. self.last_5.title('History')
  223. self.last_5.geometry('390x295')
  224. self.last_5.maxsize(height=295,width=390)
  225. self.last_5.config(bg="#D6F5FF")
  226. self.last_5.iconbitmap('bank.ico')
  227. self.last_5.title('Account Database')
  228. def close():
  229. self.last_5.destroy()
  230. close_but=Button(self.last_5,text='Close',command=close,anchor='center')
  231. close_but.pack(side='right')
  232. close_but.place(x=340,y=10)
  233. main=Label(self.last_5, text='Last 5 Transactions', anchor='center',font=('Bernard MT Condensed',16),bg="#D6F5FF",padx=15,pady=15 )
  234. main.pack()
  235. file=open('cust_data/'+userid+'/transaction.txt','r+')
  236. fh=file.readlines()
  237. bal=fh[-1]
  238. bal=bal.split('$')
  239. bal=bal[2]
  240. current_bal=Label(self.last_5, text='Current Balance:- '+bal+'.00', anchor='center',bg="#D6F5FF")
  241. current_bal.pack()
  242. current_bal.place(y=60,x=110)
  243. date=Label(self.last_5, text='Date',bg="#D6F5FF")
  244. date.pack()
  245. date.place(x=55,y=100)
  246. total_bal=Label(self.last_5, text='Current Balance',bg="#D6F5FF")
  247. total_bal.pack()
  248. total_bal.place(x=140,y=100)
  249. status=Label(self.last_5, text='Status',bg="#D6F5FF")
  250. status.pack()
  251. status.place(x=260,y=100)
  252. try:
  253. data1=fh[-1]
  254. data1=data1.split('$')
  255. data1_label1=Label(self.last_5, text=data1[1],bg="#D6F5FF")
  256. data1_label1.pack()
  257. data1_label1.place(x=50,y=130)
  258. data1_label2=Label(self.last_5, text=data1[2],bg="#D6F5FF")
  259. data1_label2.pack()
  260. data1_label2.place(x=150,y=130)
  261. data1_label3=Label(self.last_5, text=data1[3]+' '+data1[4],bg="#D6F5FF")
  262. data1_label3.pack()
  263. data1_label3.place(x=250,y=130)
  264. data2=fh[-2]
  265. data2=data2.split('$')
  266. data2_label1=Label(self.last_5, text=data2[1],bg="#D6F5FF")
  267. data2_label1.pack()
  268. data2_label1.place(x=50,y=155)
  269. data2_label2=Label(self.last_5, text=data2[2],bg="#D6F5FF")
  270. data2_label2.pack()
  271. data2_label2.place(x=150,y=155)
  272. data2_label3=Label(self.last_5, text=data2[3]+' '+data2[4],bg="#D6F5FF")
  273. data2_label3.pack()
  274. data2_label3.place(x=250,y=155)
  275. data3=fh[-3]
  276. data3=data3.split('$')
  277. data3_label1=Label(self.last_5, text=data3[1],bg="#D6F5FF")
  278. data3_label1.pack()
  279. data3_label1.place(x=50,y=180)
  280. data3_label2=Label(self.last_5, text=data3[2],bg="#D6F5FF")
  281. data3_label2.pack()
  282. data3_label2.place(x=150,y=180)
  283. data3_label3=Label(self.last_5, text=data3[3]+' '+data3[4],bg="#D6F5FF")
  284. data3_label3.pack()
  285. data3_label3.place(x=250,y=180)
  286. data4=fh[-4]
  287. data4=data4.split('$')
  288. data4_label1=Label(self.last_5, text=data4[1],bg="#D6F5FF")
  289. data4_label1.pack()
  290. data4_label1.place(x=50,y=205)
  291. data4_label2=Label(self.last_5, text=data4[2],bg="#D6F5FF")
  292. data4_label2.pack()
  293. data4_label2.place(x=150,y=205)
  294. data4_label3=Label(self.last_5, text=data4[3]+' '+data4[4],bg="#D6F5FF")
  295. data4_label3.pack()
  296. data4_label3.place(x=250,y=205)
  297. data5=fh[-5]
  298. data5=data5.split('$')
  299. data5_label1=Label(self.last_5, text=data5[1],bg="#D6F5FF")
  300. data5_label1.pack()
  301. data5_label1.place(x=50,y=230)
  302. data5_label2=Label(self.last_5, text=data5[2],bg="#D6F5FF")
  303. data5_label2.pack()
  304. data5_label2.place(x=150,y=230)
  305. data5_label3=Label(self.last_5, text=data5[3]+' '+data5[4],bg="#D6F5FF")
  306. data5_label3.pack()
  307. data5_label3.place(x=250,y=230)
  308. except IndexError:
  309. pass
  310. def total_balance():
  311. fh=open('cust_data/'+userid+'/transaction.txt','r+')
  312. file=fh.readlines()
  313. file=file[-1]
  314. file=file.split('$')
  315. file=file[2]
  316. messagebox.showinfo('Balance','Total Balance in your account is '+file+'.')
  317. return
  318. cm=Label(self.sign_in, text='Welcome to Account Management System', anchor='center',font=('Pricedown Bl',18),bg='#D6F5FF' )
  319. cm.pack()
  320. cm.place(x=67,y=40)
  321. choose=Label(self.sign_in, text='Choose The Required Option', anchor='w',padx=15,pady=15 ,font=('Pricedown Bl',16),bg='#D6F5FF')
  322. choose.pack()
  323. choose.place(x=140,y=70)
  324. info=Button(self.sign_in,text='Account Information',command=acc_info)
  325. info.pack()
  326. info.place(x=90,y=130)
  327. last_5=Button(self.sign_in,text='Last 5 Transaction',command=last_5)
  328. last_5.pack()
  329. last_5.place(x=230,y=130)
  330. total_bal=Button(self.sign_in,text='View Total Balance',command=total_balance)
  331. total_bal.place(x=350,y=130)
  332. self.sign_in.mainloop()
  333.  
  334. class account(object):
  335. def __init__(self):
  336. self.sign_in()
  337. def retrive_home(self):
  338. self.window.destroy()
  339. start=home_page()
  340. def sign_in(self):
  341. self.window=Tk()
  342. self.window.geometry('350x220')
  343. self.window.maxsize(height=220,width=350)
  344. self.window.config(bg="#D6F5FF")
  345. self.window.iconbitmap('bank.ico')
  346. self.window.title('Admin Login')
  347. def admin_check():
  348. if self.entry_check1.get()=='' or self.entry_check2.get()=='':
  349. messagebox.showerror('Error','Blank Username or Password')
  350. return
  351. if self.entry_check1.get()=="Admin" and self.entry_check2.get()=="000000":
  352. messagebox.showinfo('Welcome to Database','Welcome Admin')
  353. self.window.destroy()
  354. start=admin_win()
  355. else:
  356. messagebox.showerror('Error','Invalid Login Please Check credentials')
  357. user_id=Label(self.window,text='Enter Your User Id',bg="#D6F5FF")
  358. user_id.pack(padx=15,pady=5,anchor='center')
  359. self.entry_check1=Entry(self.window,bd=5)
  360. self.entry_check1.pack(padx=15,pady=5,anchor='center')
  361. pwd=Label(self.window,text='Enter Your Password',bg="#D6F5FF")
  362. pwd.pack(padx=15,pady=5,anchor='center')
  363. self.entry_check2=Entry(self.window,bd=5,show='*')
  364. self.entry_check2.pack(padx=15,pady=5,anchor='center')
  365. button=Button(self.window,text='Sign In',command=admin_check)
  366. button.pack(padx=5,side=RIGHT)
  367. button1=Button(self.window,text='Cancel',command=self.retrive_home)
  368. button1.pack(padx=5,side=LEFT)
  369. self.window.mainloop()
  370.  
  371. def admin_win():
  372. admin_win2=Tk()
  373. admin_win2.title('Admin')
  374. admin_win2.geometry('354x155')
  375. admin_win2.config(bg="#D6F5FF")
  376. admin_win2.iconbitmap('bank.ico')
  377. def delete_account():
  378. del_account=Tk()
  379. del_account.iconbitmap('bank.ico')
  380. del_account.title('Delete Account')
  381. del_account.config(bg="#D6F5FF")
  382. del_account.geometry('277x140')
  383. del_account.maxsize(height=140,width=277)
  384. def delete():
  385. acc_no=Enter_acc_no.get()
  386. if acc_no=='':
  387. messagebox.showerror('Error','Blank Account Number')
  388. return
  389. fh=open('tot_userid.txt','r+')
  390. if '$'+str(acc_no)+'$' in fh.read():
  391. fh.seek(0)
  392. for x in fh.readlines():
  393. splt=x.split('$')
  394. if splt[1]==str(acc_no):
  395. user_id=splt[2]
  396. else:
  397. messagebox.showerror('Error','Incorrect Account No. \nPlease Try Again')
  398. return
  399. dir='cust_data/'+user_id
  400. try:
  401. shutil.rmtree(dir)
  402. fh=open('tot_userid.txt','r+')
  403. fh1=open('new.txt','a+')
  404. except OSError as e:
  405. print ("Error: %s - %s." % (e.filename, e.strerror))
  406. del_account.destroy()
  407. final=Tk()
  408. final.config(bg="#D6F5FF")
  409. final.geometry('374x90')
  410. final.maxsize(height=90,width=374)
  411. final.iconbitmap('bank.ico')
  412. final.title('Succesful')
  413. Label(final, text='Account Sucessfully Deleted', anchor='center',font=('PRIMETIME',15)).pack(padx=15,pady=15)
  414. Button(final,text='Close',command=lambda:final.destroy()).pack()
  415. Label(del_account, text='Account Number', anchor='center',font=('PRIMETIME',15),bg="#D6F5FF").pack(padx=10,pady=10)
  416. Enter_acc_no=Entry(del_account)
  417. Enter_acc_no.pack(padx=5,pady=5)
  418. Button(del_account,text='Submit',command=delete).pack(padx=5,pady=15)
  419. def New():
  420. admin_win2.destroy()
  421. entries=[]
  422. new=Tk()
  423. new.title('Enter Details')
  424. new.config(bg="#D6F5FF")
  425. new.iconbitmap('bank.ico')
  426. fh=open('tot_userid.txt')
  427. def unq_user(Usrnm):
  428. f=open("tot_userid.txt","r")
  429. if "$"+Usrnm+"$" in f.read():
  430. messagebox.showerror('Error','This User id is already taken, Please try another combination')
  431. return(False)
  432. elif Usrnm[0].isdigit():
  433. messagebox.showerror('Error','Username must not start with a digit.')
  434. return(False)
  435. elif not(Usrnm.islower()):
  436. messagebox.showerror('Error','Username must contain only lowercase letters.')
  437. return(False)
  438. elif not(Usrnm.isalnum()):
  439. messagebox.showerror('Error','Extra characters are not allowed.')
  440. return(False)
  441. elif len(Usrnm)<6:
  442. messagebox.showerror('Error','Username is very small, give a big one.')
  443. return(False)
  444. else:
  445. return(True)
  446. def check_details():
  447. MsgBox = messagebox.askquestion ('Save and Continue','Are you sure you want to save and continue to save the application and continue',icon = 'warning')
  448. if MsgBox == 'yes':
  449. if e21.get()!='':
  450. if unq_user(e21.get())==True:
  451. if e1.get()=='' or e2.get()=='' or e3.get()=='' or e4.get()=='' or e7.get()=='' or e10.get()=='' or e11.get()=='' or e12.get()=='' or e13.get()=='' or e14.get()=='':
  452. messagebox.showerror('Error','All Fields are Mandatory')
  453. return(False)
  454. elif e16.get()=='' or e17.get()=='' or e18.get()=='' or e19.get()=='' or e20.get()=='' :
  455. messagebox.showerror('Error','All Fields are Mandatory')
  456. return(False)
  457. elif not(e1.get().isalpha()):
  458. messagebox.showerror('Error','Only Alphabets are Allowed. Check First Name')
  459. return(False)
  460. elif not(e2.get().isalpha()):
  461. messagebox.showerror('Error','Only Alphabets are Allowed. Check Last Name')
  462. return(False)
  463. elif not(e7.get().isalnum()):
  464. messagebox.showerror('Error',"No Special Characters Allowed,Check PAN No.")
  465. return(False)
  466. elif not(e11.get().isalpha()):
  467. messagebox.showerror('Error',"Only Alphabets are Allowed,Check City")
  468. return(False)
  469. elif not(e12.get().isalpha()):
  470. messagebox.showerror('Error',"Only Alphabets are Allowed,Check State")
  471. return(False)
  472. elif not(e13.get().isalnum()):
  473. messagebox.showerror('Error',"Only Integers Are Allowed,Check PIN Code")
  474. return(False)
  475. elif not(e14.get().isalpha()):
  476. messagebox.showerror('Error',"Only Alphabets are Allowed,Check Country")
  477. return(False)
  478. elif not(e16.get().isalpha()):
  479. messagebox.showerror('Error',"Only Alphabets are Allowed,Check Nationality")
  480. return(False)
  481. elif not(e17.get().isalnum()):
  482. messagebox.showerror('Error',"Only Integers Are Allowed,Check Mob No.")
  483. return(False)
  484. elif not(e19.get().isalnum()):
  485. messagebox.showerror('Error',"Only Integers Are Allowed,Check Opening Balance")
  486. return(False)
  487. elif not(e20.get().isalnum()):
  488. messagebox.showerror('Error',"Only Integers Are Allowed,Check Monthly Income")
  489. return(False)
  490. elif int(e19.get())<500:
  491. messagebox.showerror('Error',"Opening Blance Should be greater than Rs. 500/-")
  492. return(False)
  493. else:
  494. pass
  495. entries=[]
  496. entries.append(e1.get()+'\n')
  497. entries.append(e2.get()+'\n')
  498. entries.append(e3.get()+'\n')
  499. entries.append(e4.get()+'\n')
  500. entries.append(e6.get()+'\n')
  501. entries.append(e7.get()+'\n')
  502. entries.append(e10.get()+'\n')
  503. entries.append(e11.get()+'\n')
  504. entries.append(e12.get()+'\n')
  505. entries.append(e13.get()+'\n')
  506. entries.append(e14.get()+'\n')
  507. entries.append(e16.get()+'\n')
  508. entries.append(e17.get()+'\n')
  509. entries.append(e18.get()+'\n')
  510. entries.append(e19.get()+'\n')
  511. st=str(e5.get())
  512. for x in entries:
  513. if x=="":
  514. messagebox.showerror("Error","plese do fill all ")
  515. return
  516. fh=open('acc_no.txt','r+')
  517. acc_new=str(int(fh.readlines()[-1].rstrip('\n'))+1)
  518. fh.writelines([acc_new+'\n'])
  519. entries.append(acc_new+'\n')
  520. u=e21.get()
  521. fh_=open('tot_userid.txt','a+')
  522. fh_.writelines('$'+acc_new+'$'+u+'$'+'\n')
  523. pwd=random.randint(100000,9999999)
  524. dire='cust_data/'+u
  525. os.mkdir(dire)
  526. pwd_create=open('cust_data/'+u+'/security.txt','a+')
  527. pwd_create.writelines(['$'+u+'$'+str(pwd)+'$'+'\n'])
  528. balance=open('cust_data/'+u+'/'+'transaction.txt','a+')
  529. balance.writelines(['$'+str(datetime.datetime.now().day)+'/'+str(datetime.datetime.now().month)+'/'+str(datetime.datetime.now().year)+'$'+str(e19.get())+'$'+'Opening Balance'+'$'+'\n'])
  530. record=open('cust_data/'+u+'/'+'acc_info'+".txt","a+")
  531. record.writelines(entries)
  532. new.destroy()
  533. submit=Tk()
  534. submit.geometry('307x205')
  535. submit.title('Note the following')
  536. submit.iconbitmap('bank.ico')
  537. submit.config(bg="#D6F5FF")
  538. submit.maxsize(height=205,width=307)
  539. def retrieve_home():
  540. submit.destroy()
  541. start=admin_win()
  542. ap=Label(submit, text="Application Submitted",bg="#D6F5FF", anchor='center',font=('PRIMETIME',14)).pack(padx=10,pady=10)
  543. userid=Label(submit, text="User Id:",bg="#D6F5FF")
  544. userid.pack()
  545. userid.place(x=70,y=60)
  546. userid1=Label(submit, text=u,bg="#D6F5FF")
  547. userid1.pack()
  548. userid1.place(x=190,y=60)
  549. pwd2=Label(submit, text="Password: ",bg="#D6F5FF")
  550. pwd2.pack()
  551. pwd2.place(x=70,y=85)
  552. pwd1=Label(submit, text=str(pwd),bg="#D6F5FF")
  553. pwd1.pack()
  554. pwd1.place(x=190,y=85)
  555. acc=Label(submit, text="Account Number:",bg="#D6F5FF")
  556. acc.pack()
  557. acc.place(x=70,y=115)
  558. acc1=Label(submit, text=str(acc_new),bg="#D6F5FF")
  559. acc1.pack()
  560. acc1.place(x=190,y=115)
  561. Button(submit,text='Back',anchor='center',command=retrieve_home).pack(side='bottom',pady=10)
  562.  
  563. else:
  564. messagebox.showerror("Error","Please Enter the Username")
  565. return
  566. else:
  567. messagebox.showinfo('Return','You will now return to the application screen')
  568. L1=Label(new, text="First Name", width=22, anchor='w',padx=5,pady=5 ,bg="#D6F5FF")
  569. L1.grid(row=0)
  570. L2=Label(new, text="Last Name", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  571. L2.grid(row=1)
  572. L3=Label(new, text="Father's Name", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF" )
  573. L3.grid(row=2)
  574. L4=Label(new, text="Mother's Name", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  575. L4.grid(row=3)
  576. L5=Label(new, text="Date of Birth [DD/MM/YYYY]", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  577. L5.grid(row=4)
  578. l1=Label(new,text='Gender',width=22,anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=5)
  579. L6=Label(new, text="PAN No.", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  580. L6.grid(row=6)
  581. l2=Label(new,text='Category',width=22,anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=7)
  582. l2=Label(new,text='Religion',width=22,anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=9)
  583. L7=Label(new, text="Address", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  584. L7.grid(row=11)
  585. L8=Label(new, text="City", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  586. L8.grid(row=12)
  587. L9=Label(new, text="State", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF" )
  588. L9.grid(row=13)
  589. L10=Label(new, text="PIN Code", width=22, anchor='w',padx=5,pady=5 ,bg="#D6F5FF")
  590. L10.grid(row=14)
  591. L11=Label(new, text="Country", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  592. L11.grid(row=15)
  593. L13=Label(new, text="Nationality", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF")
  594. L13.grid(row=17)
  595. L14=Label(new, text="Mob No.", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=18)
  596. L15=Label(new, text="Email Id", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=19)
  597. L16=Label(new, text="Opening Balance", width=22, anchor='w',padx=5,pady=5 ,bg="#D6F5FF").grid(row=20)
  598. L17=Label(new, text="Monthly Income", width=22, anchor='w',padx=5,pady=5,bg="#D6F5FF").grid(row=21)
  599. L18=Label(new, text='\nCreate Your Unique User Id',width=22, anchor='center',padx=5,pady=5,bg="#D6F5FF").grid(row=22,column=0)
  600. L2=Button(new,text="Continue",anchor='center',command=check_details).grid(row=22,column=2)
  601. e1 = Entry(new)
  602. e2 = Entry(new)
  603. e3 = Entry(new)
  604. e4 = Entry(new)
  605. e5 = Entry(new)
  606. e6 = Entry(new)
  607. e7 = Entry(new)
  608. e10 = Entry(new)
  609. e11 = Entry(new)
  610. e12 = Entry(new)
  611. e13 = Entry(new)
  612. e14 = Entry(new)
  613. e16 = Entry(new)
  614. e17 = Entry(new)
  615. e18 = Entry(new)
  616. e19 = Entry(new)
  617. e20 = Entry(new)
  618. e21 = Entry(new)
  619. e1.grid(row=0, column=1,padx=5,pady=5)
  620. e2.grid(row=1, column=1,padx=5,pady=5)
  621. e3.grid(row=2, column=1,padx=5,pady=5)
  622. e4.grid(row=3, column=1,padx=5,pady=5)
  623. e5.grid(row=4, column=1,padx=5,pady=5)
  624. e6.grid(row=5, column=1,padx=5,pady=5)
  625. e7.grid(row=6, column=1,padx=5,pady=5)
  626. e10.grid(row=11, column=1,padx=5,pady=5)
  627. e11.grid(row=12, column=1,padx=5,pady=5)
  628. e12.grid(row=13, column=1,padx=5,pady=5)
  629. e13.grid(row=14, column=1,padx=5,pady=5)
  630. e14.grid(row=15, column=1,padx=5,pady=5)
  631. e16.grid(row=17, column=1,padx=5,pady=5)
  632. e17.grid(row=18, column=1,padx=5,pady=5)
  633. e18.grid(row=19, column=1,padx=5,pady=5)
  634. e19.grid(row=20, column=1,padx=5,pady=5)
  635. e20.grid(row=21, column=1,padx=5,pady=5)
  636. e21.grid(row=22, column=1,padx=5,pady=5)
  637. d1={1:'Male',2:'Female'}
  638. var=IntVar()
  639. for i in d1:
  640. r=Radiobutton(new,text=d1[i],value=i,width=22,bg="#D6F5FF",command=None)
  641. r.grid(row=5,column=i)
  642. e6.grid(row=5,column=1,columnspan=3,padx=5,pady=5)
  643. var1 = IntVar()
  644. Checkbutton(new, text="General", variable=var1,bg="#D6F5FF").grid(row=7,column=1)
  645. var2 = IntVar()
  646. Checkbutton(new, text="SC", variable=var2,bg="#D6F5FF").grid(row=7,column=2)
  647. var3 = IntVar()
  648. Checkbutton(new, text="ST", variable=var3,bg="#D6F5FF").grid(row=8,column=1)
  649. var4= IntVar()
  650. Checkbutton(new, text="OBC", variable=var4,bg="#D6F5FF").grid(row=8,column=2)
  651. var6 = IntVar()
  652. Checkbutton(new, text="Hindu", variable=var6,bg="#D6F5FF").grid(row=9,column=1)
  653. var7 = IntVar()
  654. Checkbutton(new, text="Muslim", variable=var7,bg="#D6F5FF").grid(row=9,column=2)
  655. var8 = IntVar()
  656. Checkbutton(new, text="Christian", variable=var8,bg="#D6F5FF").grid(row=10,column=1)
  657. var9 = IntVar()
  658. Checkbutton(new, text="Others", variable=var9,bg="#D6F5FF").grid(row=10,column=2)
  659. new.mainloop()
  660. def last_5():
  661. admin_win2.destroy()
  662. def last_5_final(acc_no):
  663. last_5_win.destroy()
  664. fh=open('tot_userid.txt','r+')
  665. if '$'+acc_no+'$' in fh.read():
  666. fh.seek(0)
  667. for x in fh.readlines():
  668. splt=x.split('$')
  669. if splt[1]==str(acc_no):
  670. userid=(splt[2])
  671. else:
  672. messagebox.showerror('Error','This Account no is not in our database ,Please check it')
  673. return
  674. last_5=Tk()
  675. last_5.geometry('390x295')
  676. last_5.maxsize(height=295,width=390)
  677. last_5.config(bg="#D6F5FF")
  678. last_5.title('Account Database')
  679. last_5.iconbitmap('bank.ico')
  680. def close():
  681. last_5.destroy()
  682. close_but=Button(last_5,text='Close',command=close,anchor='center')
  683. close_but.pack(side='right')
  684. close_but.place(x=340,y=10)
  685. main=Label(last_5, text='Last 5 Transactions', anchor='center',font=('Bernard MT Condensed',16),bg="#D6F5FF",padx=15,pady=15 )
  686. main.pack()
  687. file=open('cust_data/'+userid+'/transaction.txt','r+')
  688. fh=file.readlines()
  689. bal=fh[-1]
  690. bal=bal.split('$')
  691. bal=bal[2]
  692. current_bal=Label(last_5, text='Current Balance:- '+bal+'.00', anchor='center',bg="#D6F5FF")
  693. current_bal.pack()
  694. current_bal.place(y=60,x=110)
  695. date=Label(last_5, text='Date',bg="#D6F5FF")
  696. date.pack()
  697. date.place(x=55,y=100)
  698. total_bal=Label(last_5, text='Current Balance',bg="#D6F5FF")
  699. total_bal.pack()
  700. total_bal.place(x=140,y=100)
  701. status=Label(last_5, text='Status',bg="#D6F5FF")
  702. status.pack()
  703. status.place(x=260,y=100)
  704. try:
  705. data1=fh[-1]
  706. data1=data1.split('$')
  707. data1_label1=Label(last_5, text=data1[1],bg="#D6F5FF")
  708. data1_label1.pack()
  709. data1_label1.place(x=50,y=130)
  710. data1_label2=Label(last_5, text=data1[2],bg="#D6F5FF")
  711. data1_label2.pack()
  712. data1_label2.place(x=150,y=130)
  713. data1_label3=Label(last_5, text=data1[3]+' '+data1[4],bg="#D6F5FF")
  714. data1_label3.pack()
  715. data1_label3.place(x=250,y=130)
  716. data2=fh[-2]
  717. data2=data2.split('$')
  718. data2_label1=Label(last_5, text=data2[1],bg="#D6F5FF")
  719. data2_label1.pack()
  720. data2_label1.place(x=50,y=155)
  721. data2_label2=Label(last_5, text=data2[2],bg="#D6F5FF")
  722. data2_label2.pack()
  723. data2_label2.place(x=150,y=155)
  724. data2_label3=Label(last_5, text=data2[3]+' '+data2[4],bg="#D6F5FF")
  725. data2_label3.pack()
  726. data2_label3.place(x=250,y=155)
  727. data3=fh[-3]
  728. data3=data3.split('$')
  729. data3_label1=Label(last_5, text=data3[1],bg="#D6F5FF")
  730. data3_label1.pack()
  731. data3_label1.place(x=50,y=180)
  732. data3_label2=Label(last_5, text=data3[2],bg="#D6F5FF")
  733. data3_label2.pack()
  734. data3_label2.place(x=150,y=180)
  735. data3_label3=Label(last_5, text=data3[3]+' '+data3[4],bg="#D6F5FF")
  736. data3_label3.pack()
  737. data3_label3.place(x=250,y=180)
  738. data4=fh[-4]
  739. data4=data4.split('$')
  740. data4_label1=Label(last_5, text=data4[1],bg="#D6F5FF")
  741. data4_label1.pack()
  742. data4_label1.place(x=50,y=205)
  743. data4_label2=Label(last_5, text=data4[2],bg="#D6F5FF")
  744. data4_label2.pack()
  745. data4_label2.place(x=150,y=205)
  746. data4_label3=Label(last_5, text=data4[3]+' '+data4[4],bg="#D6F5FF")
  747. data4_label3.pack()
  748. data4_label3.place(x=250,y=205)
  749. data5=fh[-5]
  750. data5=data5.split('$')
  751. data5_label1=Label(last_5, text=data5[1],bg="#D6F5FF")
  752. data5_label1.pack()
  753. data5_label1.place(x=50,y=230)
  754. data5_label2=Label(last_5, text=data5[2],bg="#D6F5FF")
  755. data5_label2.pack()
  756. data5_label2.place(x=150,y=230)
  757. data5_label3=Label(last_5, text=data5[3]+' '+data5[4],bg="#D6F5FF")
  758. data5_label3.pack()
  759. data5_label3.place(x=250,y=230)
  760. except IndexError:
  761. pass
  762. last_5_win=Tk()
  763. last_5_win.config(bg="#D6F5FF")
  764. last_5_win.title('History')
  765. last_5_win.iconbitmap('bank.ico')
  766. acc_label=Label(last_5_win,text='Enter Account Number',anchor='center',font=('PRIMETIME',15),bg="#D6F5FF")
  767. acc_label.pack(padx=15,pady=15)
  768. acc_entry=Entry(last_5_win,bd=5)
  769. acc_entry.pack(padx=5,pady=5)
  770. acc_cont=Button(last_5_win,text='Continue',command=lambda:last_5_final(acc_entry.get()))
  771. acc_cont.pack(padx=5,pady=5)
  772. info=Label(admin_win2, text='Click the desired option', width=25, anchor='center',font=('Pricedown Bl',16),bg="#D6F5FF")
  773. info.pack()
  774. info.place(x=40,y=10)
  775. create=Button(admin_win2,text="Create Account",command=New)
  776. create.pack()
  777. create.place(x=40,y=70)
  778. delete=Button(admin_win2,text="Delete Account",command=delete_account)
  779. delete.pack()
  780. delete.place(x=140,y=70)
  781. Transaction=Button(admin_win2,text="Transaction",command=transact)
  782. Transaction.pack()
  783. Transaction.place(x=240,y=70)
  784. Transaction_history=Button(admin_win2,text="Last 5 Transactions",command=last_5)
  785. Transaction_history.pack()
  786. Transaction_history.place(x=130,y=110)
  787. admin_win2.mainloop()
  788.  
  789. class Customer_win(object):
  790. def __init__(self):
  791. self.sign_in()
  792. def retrive_home(self):
  793. self.window.destroy()
  794. start=home_page()
  795. def win_dow(self):
  796. self.window.destroy()
  797. start=after_sign_in_customer()
  798. def sign_in(self):
  799. self.window=Tk()
  800. self.window.config(bg="#D6F5FF")
  801. self.window.geometry('350x220')
  802. self.window.iconbitmap('bank.ico')
  803.  
  804. self.window.maxsize(height=220,width=350)
  805. self.window.title('Welcome to Customer Login')
  806. def next():
  807. self.username=self.entry_check1.get()
  808. st=self.username
  809. password=self.entry_check2.get()
  810. if self.username=='' or password=='':
  811. messagebox.showerror('Error','Blank Username or Password')
  812. return
  813. fh=open('tot_userid.txt','r+')
  814. if '$'+self.username+'$' in fh.read():
  815. fh=open('cust_data/'+self.username+'/security'+'.txt','r+')
  816. password_verify=fh.readlines()[0]
  817. password_verify=password_verify.split('$')
  818. password_verify=password_verify[2]
  819. fh.close()
  820. fh=open('cust_data/'+self.username+'/acc_info'+'.txt','r+')
  821. name_user=fh.readlines()[0]
  822. if password_verify==password:
  823. i='Welcome Back'+ ' '+name_user
  824. messagebox.showinfo('Welcome to Database',i)
  825. self.window.destroy()
  826. start=after_sign_in_customer(st)
  827. else:
  828. messagebox.showerror('Password Incorrect',self.username+' '+'Your Password in incorrect \nPlease Try Again')
  829. else:
  830. messagebox.showerror('Error','Invalid Login Please Check credentials')
  831. user_id=Label(self.window,text='Enter Your User Id',bg="#D6F5FF")
  832. user_id.pack(padx=15,pady=5,anchor='center')
  833. self.entry_check1=Entry(self.window,bd=5)
  834. self.entry_check1.pack(padx=15,pady=5,anchor='center')
  835. pwd=Label(self.window,text='Enter Your Password',bg="#D6F5FF")
  836. pwd.pack(padx=15,pady=5,anchor='center')
  837. self.entry_check2=Entry(self.window,bd=5,show='*')
  838. self.entry_check2.pack(padx=15,pady=5,anchor='center')
  839. button=Button(self.window,text='Sign In',command=next)
  840. button.pack(padx=5,side=RIGHT)
  841. button1=Button(self.window,text='Cancel',command=self.retrive_home)
  842. button1.pack(padx=5,side=LEFT)
  843. self.window.mainloop()
  844.  
  845. class credits_win(object):
  846. def __init__(self):
  847. self.Credits=Tk()
  848. self.Credits.title("Credits")
  849. self.Credits.iconbitmap('bank.ico')
  850. self.Credits.geometry("522x320")
  851. self.Credits.maxsize(width=522,height=320)
  852. self.Credits.config(bg="#D6F5FF")
  853. credits_text='''
  854. This project is an experimental approach towards making a Bank Database
  855.  
  856. Here, "Python" language is used under complete development.
  857.  
  858. © All Rights Reserved
  859.  
  860. Thanks to python 3.4
  861.  
  862. Thanks
  863.  
  864. Have A Nice Day!
  865.  
  866. '''
  867. text=Label(self.Credits,text=credits_text,bg="#D6F5FF",anchor='center')
  868. text.pack()
  869. text.place(x=50,y=50)
  870. self.Credits.mainloop()
  871.  
  872. class home_page(object):
  873. def __init__(self):
  874. homepage=Tk()
  875. homepage.title('PyBank')
  876. homepage.geometry('388x304')
  877. homepage.maxsize(height=304,width=388)
  878. homepage.iconbitmap('bank.ico')
  879. homepage.config(bg='#FFFFFF')
  880. def Opt1():
  881. homepage.destroy()
  882. start=account()
  883. def Opt2():
  884. homepage.destroy()
  885. start=Customer_win()
  886. def Opt3():
  887. homepage.destroy()
  888. start=credits_win()
  889. def Opt4():
  890. homepage.destroy()
  891. logo = PhotoImage(file="bank.gif")
  892. logo_final= Label(homepage, image=logo,bg='#FFFFFF').pack(side='top')
  893. Pybank=Label(text="PYBANK",font=('PRIMETIME',30),bg='#FFFFFF' )
  894. Pybank.pack()
  895. Pybank.place(y=100,x=100)
  896. admin_label=Label(text="Admin Login",bg='#FFFFFF')
  897. admin_label.pack(padx=10,pady=10)
  898. admin_label.place(x=100,y=180)
  899. admin_but=Button(text="Admin",command=Opt1)
  900. admin_but.pack()
  901. admin_but.place(x=110,y=210)
  902. customer_label=Label(text='Customer Login',bg='#FFFFFF')
  903. customer_label.pack(padx=10,pady=10)
  904. customer_label.place(x=220,y=180)
  905. customer_but=Button(text='Customer',command=Opt2)
  906. customer_but.pack()
  907. customer_but.place(x=235,y=210)
  908. credits_but=Button(text='Credits',command=Opt3)
  909. credits_but.pack()
  910. credits_but.place(x=110,y=250)
  911. exit_but=Button(text='Close',command=Opt4)
  912. exit_but.pack()
  913. exit_but.place(x=245,y=250)
  914. homepage.mainloop()
  915. start=home_page()
Add Comment
Please, Sign In to add comment