You are on page 1of 49

MAJOR PROJECT REPORT

ON
LIBRARY MANAGEMENT SYSTEM

Submitted In Partial Fulfilment of the Requirement Of


Bachelors of Computer Application (BCA)
Guru Gobind Singh Indraprastha University, Delhi

Session 2019-20

Guided By: Submitted by:


Dr. Ruchi Aggarwal Shubham Guleria
HOD of BCA 42325502017

JIMS ENGINEERING MANAGEMENT TECHINICAL CAMPUS


48/4 Knowledge Park III, Greater Noida – 201306(U.P.)

Page 1
DECLARATION

I hereby declare that this minor project report titled “Library Management System” submitted by me
to JEMTEC, Greater Noida is a bonafide work undertaken during the period from 07 January 2020 to
28 March 2020 by me and has not been submitted to any other university or institution for the award of
any degree, diploma / certificate or publication any time before.

_____________________
(Signature of the Student) Date: - 28/Apr/2020
Name: - Shubham Guleria
Enroll. No.: - 42325502017

Page 2
BONAFIDE CERTIFICATE

This is to certify that as per best of my belief the project entitled “Library Management System” is
the bonafide research work carried out by Shubham Guleria student of BCA, JEMTEC, Greater
Noida, in partial fulfilment of the requirement for the major project report of the Degree of Bachelor of
Computer Application.
He has worked under my guidance.
I wish him a success in all his future career endeavours.

Name: Dr.Ruchi Agarwal


___________________
Designation: H.O.D. BCA Department Signature with Date

Page 3
ACKNOWLEDGEMENT

I offer my sincere thanks and humble regards to JEMTEC, Greater Noida for imparting us very
valuable professional training in BCA.
I pay my gratitude and sincere regards to Dr.Ruchi Agarwal, my project guide for giving me the
cream of his knowledge. I am thankful to him as he has been a constant source of advice, motivation
and inspiration. I am also thankful to her for giving his suggestions and encouragement throughout the
project work.
I take the opportunity to express my gratitude and thanks to our computer Lab staff and library staff for
providing me opportunity to utilize their resources for the completion of the project.
I am also thankful to my family and friends for constantly motivating me to complete the project and
providing me an environment, which enhanced my knowledge.

Date: - 28/Apr/2020
Name: - Shubham Guleria
Enroll. – 42325502017
Course: - BCA (VI-Sem.)

_____________________
(Signature of the Student)

Page 4
INDEX

S.NO TOPIC PAGE NO.

ABSTRACT 6

1 INTRODUCTION 7

2 SYSTEM ANALYSIS 10

3 SYSTEM DESIGN 19

4 SYSTEM IMPLEMENTATION 23

5 CONCLUSION 48

6 REFREENCES 49

Page 5
ABSTRACT

Library management system is a project which aims in developing a computerized


system to maintain all the daily work of library .This project has many features
which are generally not availiable in normal library management systems like
facility of user login and a facility of teachers login .It also has a facility of admin
login through which the admin can monitor the whole system. It has also a facility
list of books issued and its issue date and return date and also the students can
request the librarian to add new books by filling the book request form.

             The Library Management System is designed & developed for a receipt and
issuance of books in the library along with the student’s details. The books received in
the library are entered in Books Entry form and the new student is entered in the student
entry form. When the student wants to get the desired book the same is issued on the
availability basis to the student. The student has to pay the fine if any on the basis of no.
of days delayed deposit of the book in the library.

Overall this project of ours is being developed to help the students as well as staff
of library to maintain the library in the best way possible and also reduce the
human efforts.

Page 6
CHAPTER
1INTRODUCTIO
N

This chapter gives an overview about the aim , objectives ,background and operation
environment of the system.

1.1 PROJECT AIMS ANDOBJECTIVES


The project aims and objectives that will be achieved after completion of this project are
discussed in this subchapter. The aims and objectives are as follows:
 Student Entry
 Book issue
 Request column for librarian for providing newbooks.
 A search column to search availability ofbooks
 A teacher login page where teacher can add any events being organized in the college
and important suggestions regardingbooks.

Page 7
1.2 BACKGROUND OFPROJECT

Library Management System is an application which refers to library systems which are
generally small or medium in size. It is used by librarian to manage the library using a
computerized system where he/she can record various transactions like issue of books, return of
books, addition of new books, addition of new students etc.

Books and student maintenance modules are also included in this system which would keep track
of the students using the library and also a detailed description about the books a library
contains. With this computerized system there will be no loss of book record or member record
which generally happens when a noncomputerized system isused.

In addition, report module is also included in Library Management System. If user’s position is
admin, the user is able to generate different kinds of reports like lists of students registered, list
of books, issue and return reports.

All these modules are able to help librarian to manage the library with more convenience andin
a more efficient way as compared to library systems which are notcomputerized.

Page 8
1.3 OPERATIONENVIRONMENT

PROCESSOR INTEL CORE PROCESSOR OR BETTER


PERFORMANCE

OPERATING SYSTEM WINDOWS7 OR ABOVE

MEMORY 2GB RAM OR MORE

HARD DISK SPACE MINIMUM 3 GB FOR DATABASE USAGE FOR


FUTURE
DATABASE MY SQL

Page 9
CHAPTER 2

SYSTEM ANALYSIS

2.1 SOFTWARE REQUIREMENTSPECIFICATION


2.1.1 GENERALDESCRIPTION

PRODUCT DESCRIPTION:
Library Management System is a computerized system which helps
user(librarian) to manage the library daily activity in electronic format. It reduces
the risk of paper work such as file lost, file damaged and time consuming.
It can help user to manage the transaction or record more effectively and time-
saving.

PROBLEM STATEMENT:
The problem occurred before having computerized system includes:
 Filelost
When computerized system is not implemented file is always lost because of human
environment. Sometimes due to some human error there may be a loss of records.

 File damaged when a computerized system is not there file is always lost due to
some accident like spilling of water by some member on fileaccidentally.besides
some natural disaster like floods or fires may also damage thefiles.

Page 10
 Difficult to searchrecord
When there is no computerized system there is always a difficulty in searching of
records if the records are large in number .
 Spaceconsuming
After the number of records become large the space for physical storage of file and
records also increases if no computerized system is implemented.
 Cost consuming
As there is no computerized system the to add each record paper will be needed
which will increase the cost for the management of library.

2.1.2 SYSTEMOBJECTIVES
 Improvement in control andperformance
The system is developed to cope up with the current issues and problems of library
.The system can add user, validate user and is also bug free.
 Savecost
After computerized system is implemented less human force will be required to
maintain the library thus reducing the overall cost.
 Savetime
Librarian is able to search record by using few clicks of mouse and few search
keywords thus saving his valuable time.

Page 11
2.1.3 SYSTEMREQUIREMENTS
2.1.3.1 NON FUNCTIONALREQUIREMENTS
 Product Requirements
EFFICIENCYREQUIREMENT
When a library management system will be implemented librarian and user will
easily acess library as searching and book transaction will be very faster .

RELIABILITY REQUIREMENT
The system should accurately performs member registration ,member validation ,
book transaction and search

USABILITY REQUIREMENT
The system is designed for a user friendly environment so that student and staff of
library can perform the various tasks easily and in an effective way.

Page 12
2.1.3.2 FUNCTIONALREQUIREMENTS
1. NORMALUSER

1.1 USER LOGIN


Description offeature
This feature used by the user to login into system. Theyarerequired to enter user id and
password before they are allowed to enter the system .The user id and password will beverified
and if invalid id is there user is allowed to not enter thesystem.

Functional requirements
-user id is provided when they register
-The system must only allow user with valid id and passwordto enter thesystem
-The system performs authorization process which decides what user level can acess to.
-The user must be able to logout after they finished using system.

1.2 REGISTER NEWUSER


Description of feature
This feature can be performed by all users to register new user to create account.

Functional requirements
-System must be able to verify information

1.3 REGISTER NEW BOOK


Description offeature
This feature allows to add new books to the library
Functional requirements
-System must be able to verify information
-System must be able to enter number of copies into table.
- System must be able to not allow two books having same book id.

Page 13
1.4SEARCH BOOK

DESCRIPTION OF FEATURE
This feature is found in book maintenance part . we can search book based on book id ,
book name , publication or by author name.

Functional requirements
- System must be able to search the database based on select searchtype
- System must be able to filter book based on keywordenterd
- System must be able to show the filtered book in tableview

1.5 ISSUE BOOKS AND RETURNBOOKS

DESCRIPTION OF FEATURE
This feature allows to issue and return books and also view reports of book issued.

Functional requirements
-System must be able to enter issue information in database.
-System must be able to update number of books.
- System must be able to search if book is available or notbeforeissuing books
-System should be able to enter issue and return date information

Page 14
2.1.4 SOFTWARE AND HARDWAREREQUIREMENTS
This section describes the software and hardware requirements of thesystem
2.1.4.1 SOFTWAREREQUIREMENTS

 Operating system- Windows 7 is used as the operating system as it is stableand


supports more features and is more userfriendly
 Database MYSQL-MYSQL is used as database as it easy to maintain andretrieve
records by simple queries which are in English language which are easy to
understand and easy towrite.

2.1.4.2 HARDWAREREQUIREMENTS
 Intel core i3 3nd generation is used as a processor because it is fast than other
processors a provide reliable and stable and we can run our pc for longtime.
By using this processor we can keep on developing our project without any
worries.
 Ram 2 gb is used as it will provide fast reading and writing capabilitiesand
will in turn support in processing

Page 15
2.2 SOFTWARE TOOLSUSED

Python (version - 3.7.3):


Python is a widely used general-purpose, high level programming language. It was
initially designed by Guido van Rossum in 1991 and developed by Python Software
Foundation. It was mainly developed for emphasis on code readability, and its syntax
allows programmers to express concepts in fewer lines of code. Python is a
programming language that lets you work quickly and integrate systems more
efficiently.
It is an interpreted, high-level, general-purposeprogramming language. Its language
constructs and object-oriented approach aim to help programmers write clear, logical
code for small and large-scale projects. Python is dynamically typed and garbage-
collected.

Why use Python?


 Python works on different platforms (Windows, Mac, Linux, Raspberry Pi,etc.).
 Python has a simple syntax similar to the Englishlanguage.
 Python has syntax that allows developers to write programs with fewer lines than some
other programminglanguages.
 Python runs on an interpreter system, meaning that code can be executed as soon as it is
written. This means that prototyping can be veryquick.

Page 16
 MYSQL- MySQL("My S-Q-L", officially, but also called "My Sequel") is (as of
July 2013) the world's second most widely used open-source relational database
management system (RDBMS). It is named after co-founder Michael Widenius
daughter, My. The SQL phrase stands for Structured Query Language. The
MySQL development project has made its source code available under the terms
of the GNU General Public License, as well as under avariety
of proprietary agreements. MySQL was owned and sponsored by a single for-
profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation
.MySQL is a popular choice of database for use in web applications, and is a
central component of the widely used LAMP open source web application
software stack (and other 'AMP' stacks). LAMP is an acronym for "Linux, Apache,
MySQL, Perl/PHP/Python." Free-software-open source projects that require a
full-featured database management system often use MySQL. For commercial
use, several paid editions are available, and offer additional functionality.
Applications which use MySQL database

Page 17
CHAPTER
3SYSTEM
DESIGN

3.1 TABLEDESIGN

VARIOUS TABELS TO MAINTAIN


INFORMATION
 TABLEFORKEEPINGTRACKOFADMIN

Page 18
 STUDENT TABLE FOR STUDENTINFORMATION

 BOOKTABLETO TRACK BOOK

Page 19
 Issuetabletokeeptrackofbooksissued

Page 20
CHAPTER 4
SYSTEMIMPLEMENTATION

4.1.1 Screenshot forhomepage

from tkinter import *


from tkinter import messagebox
import re
from tkinter import ttk
import sqlite3
from sqlite3 import Error
import os,sys
py=sys.executable

Page 21
#creating window
class reg(Tk):
def __init__(self):
super().__init__()
self.title("Library Administration")
self.maxsize(1366, 768)
self.minsize(1366, 768)
self.state("zoomed")
self.iconbitmap(r'libico.ico')
self.configure(background="dark blue")
#creating variables Please chech carefully
z = StringVar()
y = StringVar()
x = StringVar()
w = StringVar()
v = StringVar()
u = StringVar()
s = StringVar()
r = StringVar()

def insert():
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
c = self.myCursor.execute("Insert into admin values (?,?,?,?,?,?,?)",
[z.get(), y.get(), x.get(), w.get(), v.get(), s.get(), r.get()])
self.conn.commit()
self.myCursor.close()
self.conn.close()
if c:
messagebox.showinfo("Confirm", "Data Inserted Successfully")
self.destroy()
os.system('%s %s' % (py, 'Main.py'))
except Error:
messagebox.showinfo("Error", "Something Goes Wrong")
# verify input
def verify():
if(len(z.get())) <4:
messagebox.showinfo("Error","Enter User Id\nUser Id should be greater than 4
letters")
elif (len(y.get())) <3:
messagebox.showinfo("Error", "Please Enter Your Full Name")
elif (len(x.get())) <7:
while True:
if not re.search("[a-z]", x.get()):
flag = -1
break
elif not re.search("[0-9]", x.get()):
flag = -1
break
elif not re.search("[_@$]", x.get()):
flag = -1
break
elif re.search("\s", x.get()):
flag = -1
break
else:
flag = 0
break
if len(x.get()) == 0:
messagebox.showinfo("Error","Please Enter Your Password")
elif flag == -1:
messagebox.showinfo("Error","Minimum 7 characters.\nThe alphabets must
be between [a-z]\nAt least 1 number or digit between [0-9].\nAt least 1 character from [ _

Page 22
or @ or $ ].")
elif len(s.get()) == 0 or len(s.get()) >10 or len(s.get()) <10:
messagebox.showinfo("Error","Enter Valid Phone Number")
elif len(s.get()) == 10:
if s.get().isdigit():
cas = re.fullmatch("[6-9][0-9]{9}", s.get())
if cas is None:
messagebox.showinfo("Error","Check Your Phone Number")
else:
insert()
#label and input
Label(self,text="Library Management System",font=("Algerian",35,'bold'),fg="white",bg="dark
blue").place(x=100,y=80)
Label(self,text="Enter your details and click
save",font=("Arial",20,'bold'),fg="white",bg="dark blue").place(x=450,y=650)
d = Frame(self, width=650, height=400, bg="light blue").place(x=370, y=180)
Label(d,text = "Library Information",font = ("Arial",13,"bold"),bg="light
blue").place(x=600,y=220)
Label(d, text="User ID", font=("Arial", 13, "bold"), bg="light blue").place(x=420,
y=260)
Label(d, text="User - Name", font=("Arial", 13, "bold"), bg="light
blue").place(x=420, y=300)
Label(d, text="User - Password", font=("Arial", 13, "bold"), bg="light
blue").place(x=420, y=340)
Label(d, text="Phone", font=("Arial", 13, "bold"), bg="light blue").place(x=420,
y=380)
Entry(d,textvariable=z,width=60).place(x=620,y=260)
Entry(d, textvariable=y, width=60).place(x=620, y=300)
Entry(d, show = '*',textvariable=x, width=60).place(x=620, y=340)
Entry(d, textvariable=s, width=40).place(x=620, y=380)
Button(d, text="Save", width=10, font=("Arial", 13, "bold"),
command=verify).place(x=560, y=520)
Button(d, text="Cancel", width=10, font=("Arial", 13, "bold")).place(x=720, y=520)

reg().mainloop()

from tkinter import *


from tkinter import messagebox

Page 23
import sqlite3
from sqlite3 import Error
import os
py=sys.executable

#creating window
class Lib(Tk):
def __init__(self):
super().__init__()
self.a = StringVar()
self.b = StringVar()
self.maxsize(1366, 768)
self.minsize(1366, 768)
self.state("zoomed")
self.iconbitmap(r'libico.ico')
self.configure(bg='light blue')
self.title("Library Administration")

#verifying input
def chex():
if len(self.user_text.get()) <0:
messagebox.showinfo("Oop's","Please Enter Your User Id")
elif len(self.pass_text.get()) <0:
messagebox.showinfo("Oop's","Please Enter Your Password")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Select * from admin where id=? AND password =?",
[self.user_text.get(),self.pass_text.get()])
self.pc = self.myCursor.fetchall()
self.myCursor.close()
self.conn.close()
if self.pc:
self.destroy()
os.system('%s %s' % (py, 'options.py'))
else:
messagebox.showinfo('Error', 'Username and password not found')
self.user_text.delete(0, END)
self.pass_text.delete(0, END)
except Error:
messagebox.showinfo('Error',"Something Goes Wrong,Try restarting")
def fp():
os.system('%s %s' % (py, 'f_passwd.py'))

def check():
try:
conn = sqlite3.connect('library_administration.db')
mycursor = conn.cursor()
mycursor.execute("Select * from admin")
z = mycursor.fetchone()
mycursor.close()
conn.close()
if not z:
messagebox.showinfo("Error", "Please Register A user")
x = messagebox.askyesno("Confirm","Do you want to register a user")
if x:
self.destroy()
os.system('%s %s' % (py, 'Reg.py'))
else:
self.label = Label(self, text="Admin Login", font=("Algerian", 35,
'bold'))

Page 24
self.label.place(x=530, y=30)
self.label1 = Label(self, text="User-Id", font=("Times New roman", 25,
'bold'))
self.label1.place(x=450, y=200)
self.user_text = Entry(self, textvariable=self.a, width=45)
self.user_text.place(x=650, y=215)
self.label2 = Label(self, text="Password", font=("Times new roman", 25,
'bold'))
self.label2.place(x=450, y=250)
self.pass_text = Entry(self, show='*', textvariable=self.b, width=45)
self.pass_text.place(x=650, y=265)
self.butt = Button(self, text="Login", font=10, width=15,
command=chex).place(x=650, y=315)
except Error:
messagebox.showinfo("Error", "Something Goes Wrong")

check()

Lib().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys
from tkinter import ttk
py=sys.executable

#creating window
class MainWin(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.configure(bg='grey')
self.maxsize(1366, 768)

Page 25
self.minsize(1366, 768)
self.state('zoomed')
self.title('Library Administration')
self.a = StringVar()
self.b = StringVar()
self.mymenu = Menu(self)
#calling scripts
def a_s():
os.system('%s %s' % (py, 'Add_Student.py'))

def a_b():
os.system('%s %s' % (py, 'Add_Books.py'))

def r_b():
os.system('%s %s' % (py, 'remove_book.py'))

def r_s():
os.system('%s %s' % (py, 'Remove_student.py'))

def ib():
os.system('%s %s' % (py, 'issueTable.py'))

def rb1():
os.system('%s %s' % (py, 'renew.py'))

def ret():
os.system('%s %s' % (py, 'ret.py'))

def sea():
os.system('%s %s' % (py,'Search.py'))

# def handle(event):
# if self.listTree.identify_region(event.x,event.y) == "separator":
# return "break"
def add_user():
os.system('%s %s' % (py, 'Reg.py'))
def rem_user():
os.system('%s %s' % (py, 'Rem.py'))
def cfine():
os.system('%s %s' % (py,'fine.py'))
def sest():
os.system('%s %s' % (py,'Search_Student.py'))

#creating table

self.listTree = ttk.Treeview(self,height=13,columns=('SID','Name','Fine','Book Name','Issue


Date','Return Date'))
self.vsb = ttk.Scrollbar(self,orient="vertical",command=self.listTree.yview)
self.hsb = ttk.Scrollbar(self,orient="horizontal",command=self.listTree.xview)
self.listTree.configure(yscrollcommand=self.vsb.set,xscrollcommand=self.hsb.set)
self.listTree.heading("#0",text='Book ID',anchor = 'center')
self.listTree.column("#0",width=100,minwidth=100,anchor='center')
self.listTree.heading("#1", text='SID')
self.listTree.column("#1",width=100,minwidth=100,anchor='center')
self.listTree.heading("Name", text='Name')
self.listTree.column("Name", width=150,minwidth=150,anchor='center')
self.listTree.heading("Fine", text='Fine')
self.listTree.column("Fine", width=100,minwidth=100,anchor='center')
self.listTree.heading("Book Name", text='Book Name')
self.listTree.column("Book Name", width=200, minwidth=200,anchor='center')
self.listTree.heading("Return Date", text='Return Date')
self.listTree.column("Return Date", width=125, minwidth=125,anchor='center')
self.listTree.heading("Issue Date", text='Issue Date')
self.listTree.column("Issue Date", width=125, minwidth=125,anchor='center')

Page 26
# self.listTree.bind('<Button-1>',handle) if you don't want to expand column activat this
and the above handle function
self.listTree.place(x=40,y=400)
self.vsb.place(x=943,y=400,height=287)
self.hsb.place(x=41,y=687,width=902)
ttk.Style().configure("Treeview",font=('Times new Roman',15))

list1 = Menu(self)
list1.add_command(label="Student", command=a_s)
list1.add_command(label="Book", command=a_b)

list2 = Menu(self)
list2.add_command(label="Student", command=r_s)
list2.add_command(label="Book", command=r_b)

list3 = Menu(self)
list3.add_command(label = "Add User",command = add_user)
list3.add_command(label = "Remove User",command = rem_user)
list3.add_command(label = "Clear Fine",command = cfine)

self.mymenu.add_cascade(label='Add', menu=list1)
self.mymenu.add_cascade(label='Remove', menu=list2)
self.mymenu.add_cascade(label = 'Admin Tools', menu = list3)

self.config(menu=self.mymenu)

def ser():
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.change = int(self.a.get())
self.myCursor.execute("Select
issue.BID,issue.SID,students.name,students.Fine,books.Book_name,issue.Issue_date,issue.Retur
n_date from books,students,issue where issue.BID = books.Book_Id and SID = ?",[self.change])
self.pc = self.myCursor.fetchall()
if self.pc:
self.listTree.delete(*self.listTree.get_children())
for row in self.pc:
self.listTree.insert("",'end',text=row[0] ,values =
(row[1],row[2],row[3],row[4],row[5],row[6]))
else:
messagebox.showinfo("Error", "Either ID is wrong or The book is not yet
issued on this ID")
except Error:
messagebox.showerror("Error","Something Goes Wrong")
def ent():
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Select
issue.BID,issue.SID,students.name,students.Fine,books.Book_name,issue.Issue_date,issue.Retur
n_date from books,students, issue where issue.BID = books.Book_Id and BID = ?",
[self.b.get()])
self.pc = self.myCursor.fetchall()
if self.pc:
self.listTree.delete(*self.listTree.get_children())
for row in self.pc:
self.listTree.insert("", 'end', text=row[0],values=(row[1], row[2],
row[3], row[4], row[5],row[6]))
else:
messagebox.showinfo("Error", "Please Enter a valid ID")
except Error:
messagebox.showerror("Error", "Something Goes Wrong")

Page 27
def check():
try:
conn = sqlite3.connect('library_administration.db')
mycursor = conn.cursor()
mycursor.execute("Select * from admin")
z = mycursor.fetchone()
if not z:
messagebox.showinfo("Error", "Please Register A user")
x = messagebox.askyesno("Confirm","Do you want to register a user")
if x:
self.destroy()
os.system('%s %s' % (py, 'Reg.py'))
else:
#label and input box
self.label3 = Label(self, text='Welcome To Jemtec\'s Library', bg='light blue',
font=('Algerian', 45, 'bold'))
self.label3.place(x=290, y=80)
self.label4 = Label(self, text="Enter Student Id", bg='light blue',
font=('Arial', 20, 'bold'))
self.label4.place(x=100, y=200)
self.e1 = Entry(self, textvariable=self.a, width=40).place(x=400, y=210)
self.srt = Button(self, text='Search', width=15, font=('arial',
10),command = ser).place(x=700, y=206)
self.label5 = Label(self, text='OR', bg='light blue', font=('arial', 16,
'bold')).place(x=170, y=235)
self.label5 = Label(self, text="Enter Book Id", bg='light blue',
font=('Arial', 20, 'bold'))
self.label5.place(x=100, y=260)
self.e2 = Entry(self, textvariable=self.b, width=40).place(x=400, y=270)
self.brt = Button(self, text='Find', width=15, font=('arial',
10),command = ent).place(x=700, y=266)
self.label6 = Label(self, text="Details", bg='light blue',
font=('Arial', 15, 'underline', 'bold'))
self.label6.place(x=20, y=350)
self.button = Button(self, text='Search Student', width=20,
font=('Algerian', 20), command=sest).place(x=1000,y=250)
self.button = Button(self, text='Search Book', width=20,
font=('Algerian', 20), command=sea).place(x=1000,y=350)
self.brt = Button(self, text="Issue Book", width=20, font=('Algerian',
20), command=ib).place(x=1000, y=450)
self.brt = Button(self, text="Renew Book", width=20, font=('Algerian',
20), command=rb1).place(x=1000, y=550)
self.brt = Button(self, text="Return Book", width=20, font=('Algerian',
20), command=ret).place(x=1000, y=650)
except Error:
messagebox.showerror("Error", "Something Goes Wrong")
check()

MainWin().mainloop()

Page 28
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
import sqlite3
from sqlite3 import Error
import os
import sys
py = sys.executable

#creating window
class Add(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(500,500)
self.minsize(500,500)
self.title('Add Student')
f = StringVar()
a = StringVar()
b = StringVar()
c = StringVar()
d = StringVar()
e = StringVar()

Page 29
#uploading image
def convertToBinaryData(filename):
with open(filename, 'rb') as file:
blobData = file.read()
return blobData
#verifying input
def asi():
if len(f.get()) <1:
messagebox.showinfo("Oop's", "Please Enter Your ERoll Number")
elif len(a.get()) <1:
messagebox.showinfo("Oop's","Please Enter Your Student Name")
elif len(b.get()) <1:
messagebox.showinfo("Oop's", "Please Enter Your Student Id")
elif len(c.get()) <1:
messagebox.showinfo("Oop's", "Please Enter Your Student Course")
elif len(d.get()) <10 or len(d.get()) >10:
messagebox.showinfo("Oop's", "Please Enter Your Student Phone Number")
elif len(e.get()) <1:
messagebox.showinfo("Oop's", "Please Select a Image")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
pc = self.myCursor.execute("Insert into
students('Roll_no','name','Student_Id','class','Phone_number','Image') values
(?,?,?,?,?,?)",[f.get(),a.get(),b.get(),c.get(),d.get(),convertToBinaryData(e.get())])
self.conn.commit()
if pc:
messagebox.showinfo("Done","Student Inserted Successfully")
ask = messagebox.askyesno("Confirm","Do you want to add another
student?")
if ask:
self.destroy()
os.system('%s %s' % (py, 'Add_Student.py'))
else:
self.destroy()
else:
messagebox.showerror("Error","Something goes wrong")
self.myCursor.close()
self.conn.close()
except Error:
messagebox.showerror("Error","Something goes wrong")

# label and input box


label4 = Label(self, text='Student Details', fg='red', font=('Arial', 25, 'bold')).pack()
lbl = Label(self, text='ER Number:', font=('Comic Scan Ms', 10, 'bold')).place(x=70, y=82)
S_name = Entry(self, textvariable=f, width=30).place(x=200, y=84)
label = Label(self, text='Student Name:', font=('Comic Scan Ms', 10, 'bold')).place(x=70,
y=130)
S_name = Entry(self, textvariable=a, width=30).place(x=200, y=132)
label5 = Label(self, text='Student Id:', font=('Comic Scan Ms', 10, 'bold')).place(x=70,
y=180)
S_ID = Entry(self, textvariable=b, width=30).place(x=200, y=182)
label6 = Label(self, text='Student Course:', font=('Comic Scan Ms', 10, 'bold')).place(x=70,
y=230)
S_Class = Entry(self, textvariable=c, width=30).place(x=200, y=232)
label7 = Label(self, text='Phone Number:', font=('Comic Scan Ms', 10, 'bold')).place(x=70,
y=280)
def fileDialog():
filename = filedialog.askopenfilename(initialdir = "/",title = "Select A
File",filetype = (("jpeg","*.jpg"),("png","*.png"),("All Files","*.*")))
e.set(filename)
label8 = Label(self,text="Upload image", font=('Comic Scan Ms', 10,
'bold')).place(x=70,y=330)

Page 30
upload_image = Entry(self,textvariable = e,width = 30).place(x=200,y=330)
butt=Button(self,text="Browse",width=7,command=fileDialog).place(x=400,y=328)
S_phone_number = Entry(self, textvariable=d, width=30).place(x=200, y=282)
S_butt = Button(self, text="Submit",width = 15,command=asi).place(x=230, y=390)

Add().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys
py = sys.executable

#creating window
class Add(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(500, 500)
self.minsize(500, 500)
Page 31
self.title('Add Book')
a = StringVar()
b = StringVar()
c = StringVar()
#verifying Input
def b_q():
if len(a.get()) == 0 or len(b.get()) == 0:
messagebox.showerror("Error","Please Enter The Details")
else:
g = 1
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Insert into books values (?,?,?,?)",
[a.get(),b.get(),c.get(),g])
self.conn.commit()
messagebox.showinfo('Info', 'Succesfully Added')
ask = messagebox.askyesno("Confirm", "Do you want to add another book?")
if ask:
self.destroy()
os.system('%s %s' % (py, 'Add_Books.py'))
else:
self.destroy()
except Error:
messagebox.showerror("Error","Check The Details")
#creating input box and label
Label(self, text='').pack()
Label(self, text='Book Details', fg='red', font=('Arial', 25, 'bold')).pack()
Label(self, text='').pack()
Label(self, text='Book Id:', font=('Comic Scan Ms', 10, 'bold')).place(x=100, y=130)
Entry(self, textvariable=a, width=30).place(x=230, y=132)
Label(self, text='Book Name:', font=('Comic Scan Ms', 10, 'bold')).place(x=100,
y=180)
Entry(self, textvariable=b, width=30).place(x=230, y=182)
Label(self, text='Book Author:', font=('Comic Scan Ms', 10, 'bold')).place(x=100,
y=230)
Entry(self, textvariable=c, width=30).place(x=230, y=232)
Button(self, text="Submit", command=b_q).place(x=260, y=330)
Add().mainloop()

Page 32
from tkinter import *
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys

py = sys.executable

class Rem(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(450,250)
self.minsize(450,250)
self.title("Remove Student")
a = StringVar()

def iii():
if len(a.get()) == 0:
messagebox.showerror("Error", "Please Enter The Student Id")
else:
c = messagebox.askyesno('Remove Book', 'Are You Sure You Want To Remove The
Student')
if c:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("DELETE FROM students WHERE Student_Id = ?",
[a.get()])
messagebox.showinfo('Remove', 'Succesfully Removed')
self.conn.commit()
self.conn.close()
d = messagebox.askyesno("Confirm", "Do you want to remove another
student")
if d:
self.destroy()
os.system('%s %s' % (py, 'Remove_student.py'))
else:
self.destroy()
except Error:
messagebox.showerror("Error", "Something Goes Wrong")

self.lb = Label(self, text="Enter Student Id", font=('Comic Scan Ms', 15, 'bold'))
self.lb.place(x=30, y=70)
self.e1 = Entry(self, textvariable=a, width=30).place(x=230, y=77)
self.butt1234 = Button(self, text="Remove", width=20, command=iii).place(x=230, y=120)
Rem().mainloop()

Page 33
from tkinter import *
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys

py = sys.executable

class rb(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(500,250)
self.minsize(500,250)
self.title("Remove book")
a = StringVar()

def aaa():
if len(a.get()) == 0:
messagebox.showerror("Error","Please Enter The Book Id")
else:
c = messagebox.askyesno('Remove Book', 'Are You Sure You Want To Remove The
Book')
if c:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("DELETE FROM books WHERE Book_Id = ?",
[a.get()])
messagebox.showinfo('Remove', 'Succesfully Removed')
self.conn.commit()
self.conn.close()
d = messagebox.askyesno("Confirm","Do you want to remove another
book")
if d:
self.destroy()
os.system('%s %s' % (py, 'remove_book.py'))
else:
self.destroy()
except Error:
messagebox.showerror("Error", "Something Goes Wrong")

lb = Label(self, text="Enter Book Id", font=('Comic Scan Ms', 20, 'bold'))


Page 34
lb.place(x=30, y=70)
e = Entry(self, textvariable=a, width=30).place(x=240, y=75)
bt = Button(self, text="Remove", width=20, command=aaa).place(x=240, y=120)

rb().mainloop()

from tkinter import *


from tkinter import ttk
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
from PIL import ImageTk,Image
import os,glob

class Sst(Tk):
def __init__(self):
super().__init__()
f = StringVar()
g = StringVar()
self.title("Search Student")
self.maxsize(800,500)
self.minsize(800,500)
self.iconbitmap(r'libico.ico')
l1=Label(self,text="Search Student",font=("Algerian",20,'bold')).place(x=290,y=20)
l = Label(self, text="Search By", font=("Arial", 15, 'bold')).place(x=60, y=96)
def writeTofile(data,filename):
with open(filename,'wb') as file:
file.write(data)

Page 35
def insert(data):
self.listTree.delete(*self.listTree.get_children())
for row in data:
self.listTree.insert("","end",text = row[2], values =
(row[1],row[4],row[6]))

def photo(pic):
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from students where Student_Id = ?", [pic])
pc = self.mycursor.fetchone()
if pc[5] != '':
photoPath = "Temp Images\\" + pc[1] + ".jpeg"
writeTofile(pc[5], photoPath)
self.photo = ImageTk.PhotoImage(Image.open("Temp Images\\" + pc[1] +
".jpeg"))
Label(image=self.photo, width=150, height=150).place(x=625, y=20)
filelist = glob.glob("Temp Images\*.jpeg")
for file in filelist:
os.remove(file)
else:
self.photo = ImageTk.PhotoImage(Image.open("Temp Images\\48-512.png"))
Label(image=self.photo, width=150, height=150).place(x=625, y=20)
except Error:
messagebox.showerror("Error", "Something goes wrong")

#clicking the record will open the picture


def select(a):
curItem = self.listTree.focus()
selItem = self.listTree.item(curItem)
pic = str(selItem['text'])
photo(pic)

def ge():
if (len(g.get())) == 0:
messagebox.showinfo('Error', 'First select a item')
elif (len(f.get())) == 0:
messagebox.showinfo('Error', 'Enter the '+g.get())
elif g.get() == 'Name':
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from students where name like ?",
['%'+f.get()+'%'])
pc = self.mycursor.fetchall()
if pc:
insert(pc)
else:
messagebox.showinfo("Oop's","Name not found")
except Error:
messagebox.showerror("Error", "Something goes wrong")
elif g.get() == 'ID':
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from students where Student_Id like ?",
['%' + f.get() + '%'])
pc = self.mycursor.fetchall()
if pc:
insert(pc)
else:
messagebox.showinfo("Oop's", "Id not found")

Page 36
except Error:
messagebox.showerror("Error", "Something goes wrong")

b=Button(self,text="Find",width=15,font=("Arial",10,'bold'),command=ge).place(x=460,y=148)
c=ttk.Combobox(self,textvariable=g,values=["Name","ID"],width=40,state="readonly").place(x =
180, y = 100)
en = Entry(self,textvariable=f,width=43).place(x=180,y=155)
la = Label(self, text="Enter", font=("Arial", 15, 'bold')).place(x=100, y=150)

def handle(event):
if self.listTree.identify_region(event.x,event.y) == "separator":
return "break"

self.listTree = ttk.Treeview(self, height=13,columns=('Student Name', 'Phone Number', 'No.


Of Books Issued'))
self.vsb = ttk.Scrollbar(self,orient="vertical",command=self.listTree.yview)
self.listTree.configure(yscrollcommand=self.vsb.set)
self.listTree.heading("#0", text='Student ID', anchor='w')
self.listTree.column("#0", width=100, anchor='w')
self.listTree.heading("Student Name", text='Student Name')
self.listTree.column("Student Name", width=200, anchor='center')
self.listTree.heading("Phone Number", text='Phone Number')
self.listTree.column("Phone Number", width=200, anchor='center')
self.listTree.heading("No. Of Books Issued", text='No. Of Books Issued')
self.listTree.column("No. Of Books Issued", width=200, anchor='center')
self.listTree.bind("<Button-1>", handle)
self.listTree.bind("<ButtonRelease-1>",select)
self.listTree.place(x=40, y=200)
self.vsb.place(x=743,y=200,height=287)
ttk.Style().configure("Treeview", font=('Times new Roman', 15))

Sst().mainloop()

Page 37
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import sqlite3
from sqlite3 import Error

class Sea(Tk):
def __init__(self):
super().__init__()
f = StringVar()
g = StringVar()
self.title("Search Book")
self.maxsize(800,500)
self.minsize(800,500)
self.iconbitmap(r'libico.ico')
l1=Label(self,text="Search Library",font=("Algerian",20,'bold')).place(x=290,y=20)
l = Label(self, text="Search By", font=("Arial", 15, 'bold')).place(x=60, y=96)
def insert(data):
self.listTree.delete(*self.listTree.get_children())
for row in data:
self.listTree.insert("", 'end', text=row[0], values=(row[1], row[2],
'Available' if row[3] == 1 else 'Unavailable'))
def ge():
if (len(g.get())) == 0:
messagebox.showinfo('Error', 'First select a item')
elif (len(f.get())) == 0:
messagebox.showinfo('Error', 'Enter the '+g.get())
elif g.get() == 'Book Name':
try:
self.conn = sqlite3.connect('library_administration.db')

Page 38
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from books where Book_name LIKE ?",
['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Either Book Name is incorrect or it is
not available")
except Error:
messagebox.showerror("Error","Something goes wrong")
elif g.get() == 'Author Name':
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from books where Author LIKE ?",
['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Author Name not found")
except Error:
messagebox.showerror("Error","Something goes wrong")
elif g.get() == 'Book Id':
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from books where Book_Id LIKE ?",
['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Either Book Id is incorrect or it is
not available")
except Error:
messagebox.showerror("Error","Something goes wrong")
b=Button(self,text="Find",width=15,font=("Arial",10,'bold'),command=ge).place(x=460,y=148)
c=ttk.Combobox(self,textvariable=g,values=["Book Name","Author Name","Book
Id"],width=40,state="readonly").place(x = 180, y = 100)
en = Entry(self,textvariable=f,width=43).place(x=180,y=155)
la = Label(self, text="Enter", font=("Arial", 15, 'bold')).place(x=100, y=150)

def handle(event):
if self.listTree.identify_region(event.x,event.y) == "separator":
return "break"

self.listTree = ttk.Treeview(self, height=13,columns=('Book Name', 'Book Author',


'Availability'))
self.vsb = ttk.Scrollbar(self,orient="vertical",command=self.listTree.yview)
self.listTree.configure(yscrollcommand=self.vsb.set)
self.listTree.heading("#0", text='Book ID', anchor='center')
self.listTree.column("#0", width=120, anchor='center')
self.listTree.heading("Book Name", text='Book Name')
self.listTree.column("Book Name", width=200, anchor='center')
self.listTree.heading("Book Author", text='Book Author')
self.listTree.column("Book Author", width=200, anchor='center')
self.listTree.heading("Availability", text='Availability')
self.listTree.column("Availability", width=200, anchor='center')
self.listTree.bind('<Button-1>', handle)
self.listTree.place(x=40, y=200)
self.vsb.place(x=763,y=200,height=287)

Page 39
ttk.Style().configure("Treeview", font=('Times new Roman', 15))

Sea().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys
py = sys.executable

#creating window
class issue(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.title('Library Admisintration')
self.maxsize(500, 500)
self.minsize(500, 500)
c = StringVar()
d = StringVar()

Page 40
#verifying input
def isb():
if len(c.get()) == 0 or len(d.get()) == 0:
messagebox.showinfo("Error","Please Enter The Id's")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select Availiability from books where Book_Id
= ?",[c.get()])
temp = self.mycursor.fetchone()
try:
if str(temp[0]) == '0':
messagebox.showinfo("Oop's","Book Already Issued")
else:
self.mycursor.execute("Select Fine from students where
Student_Id = ?", [d.get()])
fine = list(self.mycursor.fetchone())
self.mycursor.execute("Select Books_Issued from students where
Student_Id = ?", [d.get()])
issue = list(self.mycursor.fetchone())
if issue[0] <3:
if fine[0] >100:
messagebox.showerror('Oops', 'Cannot Issue.Please Pay
the Fine')
elif fine[0] == 0:
print("done")
self.mycursor.execute("INSERT INTO issue VALUES
(?,?,date('now'),date('now','+15 days'))",[c.get(), d.get()])
self.mycursor.execute("UPDATE books set Availiability=0
where Book_Id = ?",[c.get()])
issue[0] = issue[0] + 1
print("done2")
self.mycursor.execute("Update students set Books_Issued
= ? where Student_Id = ?",[issue[0], d.get()])
print("done3")
self.conn.commit()
self.conn.close()
messagebox.showinfo('Save', 'Successfully Issued')
conf = messagebox.askyesno("Confirm", "Do you want to
issue another book?")
if conf:
self.destroy()
os.system('%s %s' % (py, 'issueTable.py'))
else:
self.destroy()
elif fine[0] >0:
Confirm = messagebox.askyesno('Confirm','Are you sure
you want to issue.There is a fine')
if Confirm:
self.mycursor.execute("INSERT INTO issue VALUES
(?,?,date('now'),date('now','+15 days'))",[c.get(), d.get()])
self.mycursor.execute("UPDATE books set
Availiability=0 where Book_Id = ?",[c.get()])
issue[0] = issue[0] + 1
self.mycursor.execute("Update students set Books_Issued = ? where Student_Id = ?",[issue[0],
d.get()])
self.conn.commit()
self.conn.close()
messagebox.showinfo('Save', 'Successfully Issued')
conf = messagebox.askyesno("Confirm", "Do you want
to issue another book?")
if conf:

Page 41
self.destroy()
os.system('%s %s' % (py, 'issueTable.py'))
else:
self.destroy()
else:
messagebox.showinfo('Oops', 'Not Issued')
elif fine[0] >100:
messagebox.showerror('Oops', 'Cannot Issue.Please Pay
the Fine')
else:
messagebox.showerror("Can't Issue", "Maximum number of books
aleady issued")
except TypeError:
messagebox.showinfo("Oop's", "Either BookID or StudentId Not
Available")
except Error:
messagebox.showerror("Error","Something Goes Wrong")

#label and input box


Label(self, text='Book Issuing', font=('Arial Black', 35)).place(x=100, y=40)
Label(self, text='Book ID :', font=('Arial', 15), fg='red').place(x=60, y=153)
Entry(self, textvariable=c, width=40).place(x=190, y=160)
Label(self, text='Student ID :', font=('Arial', 15), fg='red').place(x=60, y=193)
Entry(self, textvariable=d, width=40).place(x=190, y=200)
Button(self, text="ISSUE", width=30, command=isb).place(x=150, y=290)
issue().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
Page 42
from datetime import datetime,date
import os
import sys
py = sys.executable

class renew(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.title("Renew")
self.maxsize(600,400)
self.minsize(600, 400)
a = StringVar()
b = StringVar()
self.cal = 0

def days_between(d1, d2):


d1 = datetime.strptime(d1, "%Y-%m-%d")
d2 = datetime.strptime(d2, "%Y-%m-%d")
return abs((d2 - d1).days)

def qui():
if len(a.get()) == 0 or len(b.get()) == 0:
messagebox.showerror("Error","Please Enter The Id's")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select BID from issue where BID = ?",[a.get()])
temp = self.mycursor.fetchone()
self.mycursor.execute("Select Fine from students where Student_Id = ?",
[b.get()])
fine = self.mycursor.fetchone()
self.mycursor.execute("Select Return_date from issue where BID = ? and
SID = ?", [a.get(), b.get()])
temp1 = self.mycursor.fetchone()
if temp1:
da = str(date.today())
ea = str(temp1[0])
if da < ea:
messagebox.showinfo("Oops", "Your Return Date Has not yet come")
else:
self.cal = days_between(ea, da)
self.cal += int(fine[0])
if int(self.cal) >= 100:
messagebox.showinfo("Fine", "Your Id is banned.Please pay the
fine")
elif int(self.cal) >0:
messagebox.showinfo('Warning','Please Return/Renew book Timely
to avoid termination of id')
self.mycursor.execute("Update students set Fine = ? where
Student_Id = ?",[int(self.cal), b.get()])
self.mycursor.execute("UPDATE issue set Issue_date = date('now')
where BID =? ", [a.get()])
self.mycursor.execute("update issue set Return_date =
date('now','+15 days') where BID = ?",[a.get()])
self.conn.commit()
self.conn.close()
messagebox.showinfo('Info', 'Succesfully Renewed')
c = messagebox.askyesno("Confirm", "Do you want to renew another
book?")
if c:
self.destroy()

Page 43
os.system('%s %s' % (py, 'renew.py'))
else:
self.destroy()
else:
messagebox.showinfo("Oop's", "The Book is not yet issued")
except TypeError:
messagebox.showerror("Error", "Check The Texts")
except Error:
messagebox.showerror("Error","Check The Fields")

Label(self, text='Renew Book', fg='red',font=('arial', 35, 'bold')).pack()


Label(self, text='Enter Book ID',font=('Comic Scan Ms', 15, 'bold')).place(x=80,
y=150)
Entry(self, textvariable=a, width=40).place(x=280, y=150)
Label(self, text="Enter Student Id",font=('Comic Scan Ms', 15, 'bold')).place(x=80,
y=200)
Entry(self, textvariable=b, width=40).place(x=280, y=200)
Button(self, text="Renew", width=25, command=qui).place(x=280, y=300)

renew().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os,sys
from datetime import datetime,date
py = sys.executable

class ret(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.title("Return")
self.maxsize(450,300)
self.minsize(450, 300)
self.cal = 0

Page 44
a = StringVar()

def days_between(d1, d2):


if d2 <= d1:
return 0
else:
d1 = datetime.strptime(d1, "%Y-%m-%d")
d2 = datetime.strptime(d2, "%Y-%m-%d")
return abs((d2 - d1).days)

def qui():
if len(a.get()) == '0':
messagebox.showerror("Error","Please Enter The Book Id")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select SID from issue where BID = ?", [a.get()])
sid = list(self.mycursor.fetchone())
self.mycursor.execute("Select Books_Issued from students where
Student_Id = ?", [sid[0]])
gsid = list(self.mycursor.fetchone())
gsid[0] = gsid[0] - 1
self.mycursor.execute("Select BID from issue where BID = ?",[a.get()])
temp = self.mycursor.fetchone()
self.mycursor.execute("Select Fine from students where Student_Id = ?",
[sid[0]])
fine = self.mycursor.fetchone()
self.mycursor.execute("Select Return_date from issue where BID = ? and
SID = ?", [a.get(), sid[0]])
temp1 = self.mycursor.fetchone()
da = str(date.today())
ea = str(temp1[0])
self.cal = days_between(ea, da)
self.cal += int(fine[0])
if da <= ea and int(self.cal) == 0:
self.mycursor.execute("DELETE FROM issue WHERE BID = ?", [a.get()])
self.mycursor.execute("update books set Availiability = 1 where
Book_Id = ?", [a.get()])
self.mycursor.execute("update students set Books_Issued = ? where
Student_Id = ?", [gsid[0],sid[0]])
self.conn.commit()
self.conn.close()
messagebox.showinfo('Info', 'Succesfully Returned')
d = messagebox.askyesno("Confirm", "Return more books?")
if d:
self.destroy()
os.system('%s %s' % (py, 'ret.py'))
else:
self.destroy()
elif len(temp) >0:
if int(self.cal) >0:
messagebox.showinfo('Warning','Please Return/Renew book Timely
to avoid termination of id')
self.mycursor.execute("Update students set Fine = ? where
Student_Id = ?",[int(self.cal), sid[0]])
self.mycursor.execute("DELETE FROM issue WHERE BID = ?",
[a.get()])
self.mycursor.execute("update books set Availiability = 1 where
Book_Id = ?", [a.get()])
self.mycursor.execute("update students set Books_Issued = ?
where Student_Id = ?", [gsid[0],sid[0]])
self.conn.commit()
self.conn.close()

Page 45
messagebox.showinfo('Info', 'Succesfully Returned')
d = messagebox.askyesno("Confirm", "Return more books?")
if d:
self.destroy()
os.system('%s %s' % (py, 'ret.py'))
else:
self.destroy()
else:
self.mycursor.execute("DELETE FROM issue WHERE BID = ?",
[a.get()])
self.mycursor.execute("update books set Availiability = 1 where
Book_Id = ?", [a.get()])
self.mycursor.execute("update students set Books_Issued = ?
where Student_Id = ?", [gsid[0],sid[0]])
self.conn.commit()
self.conn.close()
messagebox.showinfo('Info', 'Succesfully Returned')
d = messagebox.askyesno("Confirm", "Return more books?")
if d:
self.destroy()
os.system('%s %s' % (py, 'ret.py'))
else:
self.destroy()
else:
messagebox.showinfo("Oop's", "Book not yet issued")
except Error:
messagebox.showerror("Error","Something Goes Wrong")
Label(self, text='Return Book', fg='red',font=('arial', 35, 'bold')).pack()
Label(self, text='Enter Book ID', font=('Comic Scan Ms', 15, 'bold')).place(x=30,
y=120)
Entry(self, textvariable=a, width=40).place(x=180, y=124)
Button(self, text="Return", width=25, command=qui).place(x=180, y=180)
ret().mainloop()

from tkinter import *


from tkinter import messagebox
import sqlite3
from sqlite3 import Error
#creating widow
class Rem(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(400, 200)

Page 46
self.minsize(400, 200)
self.title("Remove User")
a = StringVar()
def ent():
if len(a.get()) <5:
messagebox.showinfo("Error","Please Enter A Valid Id")
else:
d = messagebox.askyesno("Confirm", "Are you sure you want to remove the
user?")
if d:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Delete from admin where id = ?",[a.get()])
temp = self.myCursor.fetchone()
if not temp:
messagebox.showinfo("Oop's","User Not Found")
a.set("")
else:
self.conn.commit()
self.myCursor.close()
self.conn.close()
messagebox.showinfo("Confirm","User Removed Successfully")
a.set("")
except:
messagebox.showerror("Error","Something goes wrong")
Label(self, text = "Enter User Id: ",font=('Arial', 15, 'bold')).place(x = 20,y =
40)
Entry(self,textvariable = a,width = 37).place(x = 160,y = 44)
Button(self, text='Remove', width=15, font=('arial', 10),command = ent).place(x=200,
y = 90)

Rem().mainloop()

Page 47
Library Management System

CHAPTER 5
CONCLUSION

This provides a computerized version of library management system which will benefit the
students as well as the staff of the library.
It makes entire process where student can search books, staff can generate reports and do book
transactions. It also has a facility for student login where student can login and can see status of
books issued as well request for book or give some suggestions. It has a facility of teacher’s
login where teachers can add lectures notes and also give necessary suggestion to library and
also add info about workshops or events happening in our college or nearby college in the online
notice board.
 Library Management System of the entire system improves the efficiency.
 It provides a friendly graphical user interface which proves to be better when compared to the
existing system.
 It gives appropriate access to the authorized users depending on their permissions.
 It effectively overcomes the delay in communications.
 Updating of information becomes so easier.
 System security, data security and reliability are the striking features.
 The System has adequate scope for modification in future if it is necessary.

Page 48
Library Management System

CHAPTER 6
REFERENCES

 https://www.python.org/downloads/
 https://sqlitebrowser.org/
 https://en.wikipedia.org/wiki/Library_management
 https://www.udemy.com/course/build-library-management-system-python-pyqt5/
 https://medium.com/better-programming/build-library-management-software-using-tkinter-from-
scratch-f595d2
 https://books.google.co.in/books/about/Library_Management.html?id=T37GFTjlYCoC&redir_esc=y

Page 49

You might also like