-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage_book.py
99 lines (90 loc) · 3.05 KB
/
manage_book.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
import validator as vd
import library
from config import cls
ldm=library.Library_Management_System.Library_database()
lum=library.Library_Management_System.User()
lub=library.Library_Management_System.Book()
ttype='book'
def add():
cls()
title,auth,pubn,isbn,qnt,rstype=None,None,None,None,None,None
while title==None:
title = vd.entry('Title','string','book',int(50))
while auth==None:
auth = vd.entry('Author','string','book',int(20))
while pubn==None:
pubn = vd.entry('Publication','string','book',int(30))
while isbn==None:
isbn = vd.entry('ISBN','int','book',int(13))
while qnt==None:
qnt = vd.entry('Quantity','int','book',int(2))
while rstype==None:
rstype = vd.entry('Book type','select','book',None)
if ldm.Search(isbn,ttype,1):
li=[title,auth,pubn,isbn,qnt,qnt,rstype]
ldm.Add(li,ttype)
return True
else:
return 0
def search():
cls()
print('[ 1 ] >> Search by UID\n[ 2 ] >> Search by ISBN\n[ B ] >> back')
choice=input('Enter a choice : ')
if choice=='1':
bid=0
while int(bid)<10001 or int(bid)>99999:
bid=input('Enter Id (Eg. 10000) : ')
bid='BKID'+str(bid)
ldm.Search(bid,ttype,0)
elif choice=='2':
isbn = None
while isbn==None:
isbn = vd.entry('ISBN','int','book',int(13))
ldm.Search(isbn,ttype,0)
elif choice=='b' or choice=='B':
cls()
return 0
else:
search()
def display():
ldm.Display(ttype)
def update():
search = None
while search==None:
search = vd.entry('ISBN','int','book',int(13))
title,auth,pubn,isbn,qnt,rstype=None,None,None,None,None,None
while title==None:
title = vd.entry('Title','string','book',int(50))
while auth==None:
auth = vd.entry('Author','string','book',int(20))
while pubn==None:
pubn = vd.entry('Publication','string','book',int(30))
while isbn==None:
isbn = vd.entry('ISBN','int','book',int(13))
while qnt==None:
qnt = vd.entry('Quantity','int','book',int(2))
while rstype==None:
rstype = vd.entry('Book type','select','book',None)
convert=title+'_'+auth+'-'+pubn+'-'+str(isbn)+'-'+str(qnt)+'-'+str(qnt)+'-'+rstype
ldm.Update(search,convert,ttype)
def delete():
find = None
while find==None:
find = vd.entry('ISBN','int','book',int(13))
ldm.Delete(find,ttype)
def issue():
find_user = None
while find_user==None:
find_user = vd.entry('Contact','int','user',int(10))
li=lum.Verify(find_user)
if li[0]:
find_book = None
while find_book==None:
find_book = vd.entry('ISBN','int','book',int(13))
cls()
lub.Book_request(find_user,find_book,li[1])
else:
cls()
print('-------------------------------')
print(' * User not Registered * ')
print('-------------------------------')