-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.py
157 lines (137 loc) · 3.15 KB
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#menu driven program in python
#add records to bank database
#loan management system in bank
import os
import pickle
#accept data
def InsertRec():
accno=int(input("Enter the account number:"))
name=input("Enter the withdrawers name:")
amt=int(input("Enter the amount withdrawn:"))
#create the dict.
rec={"AC/NO":accno,"Name":name,"Amount":amt}
#Writing the dict
f=open("loan.dat","wb")
pickle.dump(rec,f)
f.close()
print("SUCCESS!")
def searchrec(r):
f=open("loan.dat","rb")
flag=False
while True:
try:
rec=pickle.load(f)
if rec['AC/NO']==r:
print("AC/NO",rec["AC/NO"])
print("Name",rec["Name"])
print("Amount",rec["Amount"])
flag=True
except EOFError:
break
if flag==False:
print("No records")
f.close()
def updaterec(r,m):
f=open("loan.dat","rb")
reclst=[]
while True:
try:
rec=pickle.load(f)
reclst.append(rec)
except EOFError:
break
f.close()
for i in range(len(reclst)):
if reclst[i]['AC/NO']==r:
reclst[i]['Amount']==m
f=open("loan.dat","wb")
for x in reclst:
picle.dump(x,f)
f.close()
def readrec():
f=open("loan.dat","rb")
while True:
try:
rec=pickle.load(f)
print("Your account number is:",rec['AC/NO'])
print("Your name is:",rec["Name"])
print("You have withdrawn:",rec["Amount"])
except EOFError:
break
f.close()
def deleterec(r):
f=open("loan.dat","rb")
reclst=[]
while True:
try:
rec=pickle.load(f)
reclst.append(rec)
except EOFError:
break
f.close()
f=open("loan.dat","wb")
for x in reclst:
if x['AC/NO']==r:
continue
pickle.dump(x,f)
f.close()
while True:
print('###BANK MANAGEMENT USING FILE HANDLING###')
print("1.Add the withdrawers details>")
print("2.To modify the withdrawers detail>")
print("3.Delete the record>")
print("4.View the withdrawers details>")
print("5.Search the records>")
print("6.EXIT>")
ch=input("Enter the choice>")
if ch=='1':
InsertRec()
elif ch=='5':
r=int(input("Account number:"))
searchrec(r)
print("###YOUR RECORD IS FOUND!!!###")
elif ch=='2':
r=int(input("Enter the accno to be updated:"))
m=int(input("Enter the new amount:"))
elif ch=="3":
r=int(input("Enter the account number:"))
deleterec(r)
elif ch=='4':
readrec()
print("###HERE ARE ALL THE RECORDS###")
elif ch=="6":
print("###THANKS FOR USING ARE LOAN MANAGEMENT SYSTEM! HAVE A GREAT DAY!")
break
#transanctions and billings in csv format(excel)
#transanctions and billings in csv format(excel)
print("CSV FILES!")
import csv
fh=open("loan.csv","w")
loanwriter=csv.writer(fh)
loanwriter.writerow(['AC/NO','Name','Amount'])
n=int(input("Enter number of customers:"))
for i in range(n):
print("Transanctions record",(i+1))
accno=int(input("Enter AC/NO:"))
name=input("Enter the name:")
amt=int(input("Enter the amount:"))
loanrec=[accno,name,amt]
loanwriter.writerow(loanrec)
fh.close()
#end
'''
#mysql python connector
#main
from tkinter import *
window=Tk()
window.geometry("400x400")
window.title("Employee database")
label=Label(window,text="Hello Welcome to our Employee database",
relief=RAISED,
padx=20,
pady=10,
compound='up',
)
label.pack()
window.mainloop()
'''