Library Management System Class 12
Library Management System Class 12
Library Management System Class 12
ARMAAN GARNAYAK
CLASS-XII
ROLL-NO-12629828
Contents
I would like to thank our Principal Mr. Laxmi Kanta Debta and
our Computer science teacher Mr. Pratap Mishra, whose
valuable guidance has been the ones that helped me patch
this project and make it full proof success. His suggestions
and his instructions has served as the major contributor
towards the completion of this project.
General Description
Main
Screen
Administration
Menu
1
Display
Student
Main Record Display All
Menu Students
Record
Modify Modify
Administration Student
Book
Menu Record
Display
Specific Book
Delete
Student
Display All
Record
Books
Create Book
2
Source Code
from pickle import load,dump
time
print() print()
print() print()
print()
print() print()
print() print()
a=str(a) if
a.isalpha():
pass
3
"""***********************************************************************************
***********************************************************************************"""
class book:
self.bno=bno
self.bname=bname
self.auname=auname def
create_book(self):
print()
print()
print()
print()
print()
print()
def show_book(self):
print()
print()
print()
4
print ("\t \t Book Name:",self.bname)
print()
print()
print()
def modify_book(self):
print()
print()
print()
print()
print()
print()
print()
def ret_bno(self):
report_book(self):
self.admno=admno
self.name=name self.stbno=stbno
5
print() print("\t \t \t Creating Student
Record \t \t \t")
print()
print()
print()
print("#"*70)
print()
def showstud(self):
print()
print()
print()
print("\t Name:",self.name)
print()
print()
print("\t Token:",self.token)
print()
def displaystud(self):
print()
6
print ("\t Admission Number of the Student is:",self.admno)
print()
if (self.token==1):
def modifystud(self):
print()
print()
print()
def ret_stbno(self):
ret_token(self):
add_token(self):
self.token=1 def
reset_token(self):
self.token=0 def
get_stbno(self,t):
self.stbno=t def
reportstud(self):
7
print (self.admno, self.name, self.token)
"""***********************************************************************************
***********************************************************************************"""
def writebook():
ch="Y"
fp=open("book1.dat","ab")
while ch=="Y":
bk.create_book() dump(bk,fp)
print()
print()
print ("#"*70)
print()
ch=ch.upper()
"""***********************************************************************************
FUNCTION TO ENTER STUDENT RECORD
***********************************************************************************"""
def writestudent():
ch="Y"
fp=open("student1.dat","ab")
while ch=="Y":
st.createstud() dump(st,fp)
ch=ch.upper()
print()
8
"""***********************************************************************************
***********************************************************************************"""
def display_alls():
fin=open("student1.dat","rb")
if not (fin):
print() st=load(fin)
pass
fin.close()
"""***********************************************************************************
***********************************************************************************"""
def display_allb():
fin=open("book1.dat","rb")
else: try:
while True:
bk=load(fin)
9
bk.show_book()
except EOFError:
pass
fin.close()
"""***********************************************************************************
**********************************************************************************"""
def display_spb(no):
flag=0
fin=open("book1.dat","rb")
bk=load(fin)
if(bk.ret_bno()==no):
bk.show_book()
flag=1
except EOFError:
pass
fin.close() if
flag==0:
print()
print()
"""***********************************************************************************
**********************************************************************************"""
10
def display_sps(n):
flag=0
fin=open("student1.dat","rb")
st=load(fin)
if(st.ret_admno()==n):
st.showstud()
flag=1
except EOFError:
pass
fin.close() if
flag==0:
print()
"""***********************************************************************************
***********************************************************************************"""
def modify_bookrecord():
found=0
\t Modify Book")
print()
print()
print()
11
fin=open("book1.dat","rb")
fout=open("temp.dat","wb")
try:
while True:
bk=load(fin)
if bk.ret_bno()==n:
Book Details")
bk.show_book()
print()
print()
print()
bk.modify_book()
dump(bk,fout) found=1
else:
dump(bk,fout)
except EOFError:
pass
remove("book1.dat")
rename("temp.dat","book1.dat")
"""***********************************************************************************
FUNCTION TO MODIFY STUDENT RECORD
**********************************************************************************”””
12
def modify_student_record():
found=0
print()
print("\t \t \t Modify Student Record")
print()
print()
print()
fin=open("student1.dat","rb")
fout=open("temp.dat","wb")
st=load(fin) if
st.ret_admno()==n:
print()
st.showstud() print()
st.modifystud() dump(st,fout)
found=1
else:
dump(st,fout)
except EOFError:
fout.close()
13
remove("student1.dat")
rename("temp.dat","student1.dat")
"""*************************************************
**********************************
**********************************************************************************"""
def del_stud():
flag=0
print() print()
print()
fin=open("student1.dat","rb")
fout=open("temp.dat","wb")
st=load(fin) if
st.ret_admno()<n:
dump(st,fout)
else:
flag=1
except EOFError:
pass
fin.close()
fout.close()
remove("student1.dat")
rename("temp.dat","student1.dat")
14
if flag==1:
print()
else:
print()
print("\t \t \t \t SORYY..!! RECORD DOES NOT EXIST..!!..")
"""***********************************************************************************
FUNCTION TO DELETE BOOK RECORD
**********************************************************************************""" def
del_book():
flag=0
print() print()
print()
fin=open("book1.dat","rb")
fout=open("temp.dat","wb")
try: while
True:
bk=load(fin)
if bk.ret_bno()<n:
dump(bk,fout)
else:
flag=1
except EOFError:
15
pass fin.close() fout.close()
remove("book1.dat")
rename("temp.dat","book1.dat")
if flag==1:
"""***********************************************************************************
**********************************************************************************"""
def book_issue():
sn=" "
bn=" "
found=0
flag=0
print()
print()
print()
print()
print()
fin1=open("book1.dat","rb")
fin2=open("student1.dat","rb") fout=open("temp.dat","ab")
try: while
True:
16
st=load(fin2) if
(st.ret_admno()==sn):
st.showstud()
found=1 if
st.ret_token()==0:
try:
while True:
bk=load(fin1) if bk.ret_bno()==bn:
bk.show_book() flag=1
st.add_token() st.get_stbno(bk.ret_bno())
dump(st,fout) os.system("cls")
print()
print("\t PLEASE NOTE : Write the current date in backside of your book ")
print ()
print()
except EOFError:
pass
else:
except EOFError:
17
pass
"""***********************************************************************************
FUNCTION TO DEPOSIT BOOK
***********************************************************************************"""
def book_deposit():
sn=" "
found=0
flag=0 day=0
fine=0 print()
print()
print()
fin1=open("student1.dat","rb")
fin2=open("book1.dat","rb") fout=open("temp.dat","rb")
st=load(fout) if
st.ret_admno()==sn:
found=1
print()
if st.ret_token()==1:
bk=load(fin2) if
bk.ret_bno()==st.ret_stbno():
18
bk.show_book()
flag=1
print()
days=int(input("\t Book
if days>=15:
fine=(days-15)*20
print()
st.reset_token()
st.get_stbno(0)
st.showstud()
print()
except EOFError:
pass
else:
print()
except EOFError:
pass
if(found==0):
print()
19
bk=book() st=student()
"""***********************************************************************************
ADMINISTRATOR MENU
**********************************************************************************""" def
adminmenu():
ch="Y" while
ch=="Y":
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
20
print()
print()
print()
print()
print()
os.system("cls")
if ch1==1:
writestudent() elif
ch1==2:
display_alls() elif
ch1==3: print()
print()
modify_student_record()
elif ch1==5:
del_stud() elif
ch1==6:
writebook() elif
ch1==7:
display_allb() elif
ch1==8: print()
print()
21
bn=input("\t \t ENTER BOOK NUMBER TO BE DISPLAYED:")
display_spb(bn)
elif ch1==9:
modify_bookrecord()
elif ch1==10:
del_book() print()
print()
os.system("cls")
if ch=="Y":
continue else:
mainmenu()
"""***********************************************************************************
MAIN MENU
**********************************************************************************""" def
mainmenu():
ch="Y" while
ch=="Y":
print()
print()
print()
print()
22
print("\t 2. BOOK DEPOSIT")
print()
print()
print("\t 4. EXIT")
print()
print() print("\t \t
if ch1==1:
book_issue() elif
ch1==2:
book_deposit() elif
ch1==3:
adminmenu()
else:
exit(0)
print()
os.system("cls")
os.system("cls")
mainmenu()
23
OUTPUT
Introduction
24
Main Menu
Administration Menu
25
Issue Book
26
Deposit Book
27
Bibliography
Help from these resources
• Computer Science with Python – Sumita Arora
• http://www.github.com
• www.google.com
• http://slideshare.in
28