├── .gitattributes ├── Icon.ico ├── library.jpg ├── README.md ├── tset.py ├── ViewBooks.py ├── DeleteBook.py ├── AddBooks.py ├── SearchBook.py ├── IssueBook.py └── main.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/Library-Management-System/master/Icon.ico -------------------------------------------------------------------------------- /library.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/Library-Management-System/master/library.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Library-Manager-in-Python 2 | Mini Project of Library Book Issue, Record and Renewal Application Built in Python 3 | -------------------------------------------------------------------------------- /tset.py: -------------------------------------------------------------------------------- 1 | import pymysql 2 | 3 | con = pymysql.connect('localhost', 'root', 4 | 'root', 'rcpl_db') 5 | 6 | with con: 7 | 8 | cur = con.cursor() 9 | cur.execute("SELECT VERSION()") 10 | 11 | version = cur.fetchone() 12 | 13 | print("Database version: {}".format(version[0])) -------------------------------------------------------------------------------- /ViewBooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: Ashlesh 4 | """ 5 | 6 | from tkinter import * 7 | from PIL import ImageTk,Image 8 | from tkinter import messagebox 9 | import pymysql 10 | 11 | # Add your own database name and password here to reflect in the code 12 | mypass = "root" 13 | mydatabase="rcpl_db" 14 | 15 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 16 | cur = con.cursor() 17 | 18 | # Enter Table Names here 19 | bookTable = "books" #Book Table 20 | 21 | def View(): 22 | 23 | root = Tk() 24 | root.title("Library") 25 | root.minsize(width=400,height=400) 26 | root.geometry("600x500") 27 | 28 | 29 | same=True 30 | n=0.3 31 | 32 | # Adding a background image 33 | background_image =Image.open("library.jpg") 34 | [imageSizeWidth, imageSizeHeight] = background_image.size 35 | 36 | newImageSizeWidth = int(imageSizeWidth*n) 37 | if same: 38 | newImageSizeHeight = int(imageSizeHeight*n) 39 | else: 40 | newImageSizeHeight = int(imageSizeHeight/n) 41 | 42 | 43 | Canvas1 = Canvas(root) 44 | 45 | Canvas1.config(bg="#F8EFBA",width = newImageSizeWidth, height = newImageSizeHeight) 46 | Canvas1.pack(expand=True,fill=BOTH) 47 | 48 | labelFrame = Frame(root,bg='black') 49 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5) 50 | 51 | headingFrame1 = Frame(root,bg="#333945",bd=5) 52 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 53 | 54 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 55 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 56 | 57 | headingLabel = Label(headingFrame2, text="VIEW BOOKs", fg='black') 58 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 59 | 60 | y = 0.25 61 | 62 | Label(labelFrame, text="%-10s%-30s%-20s%-30s%-20s"%('BID','Title','Subject','Author','Status'),bg='black',fg='white').place(relx=0.07,rely=0.1) 63 | Label(labelFrame, text="----------------------------------------------------------------------------",bg='black',fg='white').place(relx=0.05,rely=0.2) 64 | getBooks = "select * from "+bookTable 65 | try: 66 | cur.execute(getBooks) 67 | con.commit() 68 | for i in cur: 69 | Label(labelFrame, text="%-10s%-30s%-20s%-30s%-20s"%(i[0],i[1],i[2],i[3],i[4]),bg='black',fg='white').place(relx=0.07,rely=y) 70 | y += 0.1 71 | except: 72 | messagebox.showinfo("Bad Format","Can't fetch files from database") 73 | 74 | root.mainloop() -------------------------------------------------------------------------------- /DeleteBook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | J.A.R.V.I.S Says Hello 4 | 5 | @author: Ashlesh 6 | """ 7 | 8 | from tkinter import * 9 | from PIL import ImageTk,Image 10 | from tkinter import messagebox 11 | import pymysql 12 | 13 | # Add your own database name and password here to reflect in the code 14 | mypass = "root" 15 | mydatabase="rcpl_db" 16 | 17 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 18 | cur = con.cursor() 19 | 20 | # Enter Table Names here 21 | bookTable = "books" #Book Table 22 | 23 | 24 | def deleteBook(): 25 | 26 | bid = en1.get() 27 | 28 | deleteSql = "delete from "+bookTable+" where bid = '"+bid+"'" 29 | try: 30 | cur.execute(deleteSql) 31 | con.commit() 32 | except: 33 | messagebox.showinfo("Check Credentials","Please check Book ID") 34 | 35 | print(bid) 36 | 37 | en1.delete(0, END) 38 | 39 | 40 | def delete(): 41 | 42 | global en1,en2,en3,en4,en5,Canvas1,con,cur,bookTable,root 43 | 44 | root = Tk() 45 | root.title("Library") 46 | root.minsize(width=400,height=400) 47 | root.geometry("600x500") 48 | 49 | 50 | same=True 51 | n=0.3 52 | 53 | # Adding a background image 54 | background_image =Image.open("library.jpg") 55 | [imageSizeWidth, imageSizeHeight] = background_image.size 56 | 57 | newImageSizeWidth = int(imageSizeWidth*n) 58 | if same: 59 | newImageSizeHeight = int(imageSizeHeight*n) 60 | else: 61 | newImageSizeHeight = int(imageSizeHeight/n) 62 | 63 | 64 | Canvas1 = Canvas(root) 65 | 66 | Canvas1.config(bg="#636e72",width = newImageSizeWidth, height = newImageSizeHeight) 67 | Canvas1.pack(expand=True,fill=BOTH) 68 | 69 | labelFrame = Frame(root,bg='black') 70 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.3) 71 | 72 | headingFrame1 = Frame(root,bg="#333945",bd=5) 73 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 74 | 75 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 76 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 77 | 78 | headingLabel = Label(headingFrame2, text="DELETE BOOK", fg='black') 79 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 80 | 81 | # Book ID to Delete 82 | lb2 = Label(labelFrame,text="Book ID : ", bg='black', fg='white') 83 | lb2.place(relx=0.05,rely=0.5) 84 | 85 | en1 = Entry(labelFrame) 86 | en1.place(relx=0.3,rely=0.5, relwidth=0.62) 87 | 88 | #Submit Button 89 | SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0', fg='black',command=deleteBook) 90 | SubmitBtn.place(relx=0.28,rely=0.75, relwidth=0.18,relheight=0.08) 91 | 92 | quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black', command=root.quit) 93 | quitBtn.place(relx=0.53,rely=0.75, relwidth=0.18,relheight=0.08) 94 | 95 | root.mainloop() -------------------------------------------------------------------------------- /AddBooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | J.A.R.V.I.S Says Hello 4 | 5 | @author: Ashlesh 6 | """ 7 | 8 | from tkinter import * 9 | from PIL import ImageTk,Image 10 | from tkinter import messagebox 11 | import pymysql 12 | 13 | 14 | 15 | def bookRegister(): 16 | 17 | bid = en1.get() 18 | title = en2.get() 19 | subject = en3.get() 20 | author = en4.get() 21 | status = en5.get() 22 | status = status.lower() 23 | 24 | insertBooks = "insert into "+bookTable+" values('"+bid+"','"+title+"','"+subject+"','"+author+"','"+status+"')" 25 | try: 26 | cur.execute(insertBooks) 27 | con.commit() 28 | except: 29 | messagebox.showinfo("Error","Can't add data into Database") 30 | 31 | print(bid) 32 | print(title) 33 | print(subject) 34 | print(author) 35 | print(status) 36 | 37 | en1.delete(0, END) 38 | en2.delete(0, END) 39 | en3.delete(0, END) 40 | en4.delete(0, END) 41 | en5.delete(0, END) 42 | 43 | 44 | def addBooks(): 45 | 46 | global en1,en2,en3,en4,en5,Canvas1,con,cur,bookTable,root 47 | 48 | root = Tk() 49 | root.title("Library") 50 | root.minsize(width=400,height=400) 51 | root.geometry("600x500") 52 | 53 | # Add your own database name and password here to reflect in the code 54 | mypass = "root" 55 | mydatabase="rcpl_db" 56 | 57 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 58 | cur = con.cursor() 59 | 60 | # Enter Table Names here 61 | bookTable = "books" # Book Table 62 | 63 | same=True 64 | n=0.3 65 | 66 | # Adding a background image 67 | background_image =Image.open("library.jpg") 68 | [imageSizeWidth, imageSizeHeight] = background_image.size 69 | 70 | newImageSizeWidth = int(imageSizeWidth*n) 71 | if same: 72 | newImageSizeHeight = int(imageSizeHeight*n) 73 | else: 74 | newImageSizeHeight = int(imageSizeHeight/n) 75 | 76 | 77 | Canvas1 = Canvas(root) 78 | 79 | Canvas1.config(bg="#74b9ff",width = newImageSizeWidth, height = newImageSizeHeight) 80 | Canvas1.pack(expand=True,fill=BOTH) 81 | 82 | labelFrame = Frame(root,bg='black') 83 | labelFrame.place(relx=0.1,rely=0.1,relwidth=0.8,relheight=0.7) 84 | 85 | # Book ID 86 | lb1 = Label(labelFrame,text="Book ID : ", bg='black', fg='white') 87 | lb1.place(relx=0.05,rely=0.1) 88 | 89 | en1 = Entry(labelFrame) 90 | en1.place(relx=0.3,rely=0.1, relwidth=0.62) 91 | 92 | # Title 93 | lb2 = Label(labelFrame,text="Title : ", bg='black', fg='white') 94 | lb2.place(relx=0.05,rely=0.25) 95 | 96 | en2 = Entry(labelFrame) 97 | en2.place(relx=0.3,rely=0.25, relwidth=0.62) 98 | 99 | # Book Subject 100 | lb3 = Label(labelFrame,text="Subject : ", bg='black', fg='white') 101 | lb3.place(relx=0.05,rely=0.4) 102 | 103 | en3 = Entry(labelFrame) 104 | en3.place(relx=0.3,rely=0.4, relwidth=0.62) 105 | 106 | # Book Author 107 | lb4 = Label(labelFrame,text="Author : ", bg='black', fg='white') 108 | lb4.place(relx=0.05,rely=0.55) 109 | 110 | en4 = Entry(labelFrame) 111 | en4.place(relx=0.3,rely=0.55, relwidth=0.62) 112 | 113 | # Book Status 114 | lb5 = Label(labelFrame,text="Status(Avail/issued) : ", bg='black', fg='white') 115 | lb5.place(relx=0.05,rely=0.75) 116 | 117 | en5 = Entry(labelFrame) 118 | en5.place(relx=0.3,rely=0.75, relwidth=0.62) 119 | 120 | #Submit Button 121 | SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0', fg='black',command=bookRegister) 122 | SubmitBtn.place(relx=0.28,rely=0.9, relwidth=0.18,relheight=0.08) 123 | 124 | quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black', command=root.quit) 125 | quitBtn.place(relx=0.53,rely=0.9, relwidth=0.18,relheight=0.08) 126 | 127 | root.mainloop() -------------------------------------------------------------------------------- /SearchBook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: Ashlesh 4 | """ 5 | 6 | from tkinter import * 7 | from PIL import ImageTk,Image 8 | from tkinter import messagebox 9 | import pymysql 10 | 11 | # Add your own database name and password here to reflect in the code 12 | mypass = "root" 13 | mydatabase="rcpl_db" 14 | 15 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 16 | cur = con.cursor() 17 | 18 | # Enter Table Names here 19 | bookTable = "books" #Book Table 20 | 21 | 22 | def search(): 23 | 24 | global SearchBtn,labelFrame,lb1,en1,quitBtn,root,Canvas1 25 | 26 | sub = en1.get() 27 | 28 | SearchBtn.destroy() 29 | quitBtn.destroy() 30 | lb1.destroy() 31 | en1.destroy() 32 | 33 | 34 | labelFrame = Frame(root,bg='black') 35 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5) 36 | 37 | y = 0.25 38 | 39 | Label(labelFrame, text="%-10s%-30s%-20s%-30s%-20s"%('BID','Title','Subject','Author','Status'),bg='black',fg='white').place(relx=0.07,rely=0.1) 40 | Label(labelFrame, text="----------------------------------------------------------------------------",bg='black',fg='white').place(relx=0.05,rely=0.2) 41 | 42 | searchSql = "select * from "+bookTable+" where subject = '"+sub+"'" 43 | try: 44 | cur.execute(searchSql) 45 | con.commit() 46 | for i in cur: 47 | Label(labelFrame, text="%-10s%-30s%-20s%-30s%-20s"%(i[0],i[1],i[2],i[3],i[4]),bg='black',fg='white').place(relx=0.07,rely=y) 48 | y += 0.1 49 | print(i) 50 | except: 51 | messagebox.showinfo("Search Error","The value entered is wrong, Try again") 52 | 53 | print(sub) 54 | 55 | quitBtn = Button(root,text="< Back",bg='#455A64', fg='white', command=searchBook) 56 | quitBtn.place(relx=0.53,rely=0.85, relwidth=0.18,relheight=0.08) 57 | 58 | 59 | def searchBook(): 60 | 61 | global en1,SearchBtn,lb1,labelFrame,quitBtn,Canvas1,root 62 | 63 | root = Tk() 64 | root.title("Library") 65 | root.minsize(width=400,height=400) 66 | root.geometry("600x500") 67 | 68 | 69 | same=True 70 | n=0.3 71 | 72 | # Adding a background image 73 | background_image =Image.open("library.jpg") 74 | [imageSizeWidth, imageSizeHeight] = background_image.size 75 | 76 | newImageSizeWidth = int(imageSizeWidth*n) 77 | if same: 78 | newImageSizeHeight = int(imageSizeHeight*n) 79 | else: 80 | newImageSizeHeight = int(imageSizeHeight/n) 81 | 82 | 83 | Canvas1 = Canvas(root) 84 | 85 | Canvas1.config(bg="white",width = newImageSizeWidth, height = newImageSizeHeight) 86 | Canvas1.pack(expand=True,fill=BOTH) 87 | 88 | labelFrame = Frame(root,bg='black') 89 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.3) 90 | 91 | headingFrame1 = Frame(root,bg="#333945",bd=5) 92 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 93 | 94 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 95 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 96 | 97 | headingLabel = Label(headingFrame2, text="SEARCH BOOK", fg='black') 98 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 99 | 100 | # Book ID to Delete 101 | lb1 = Label(labelFrame,text="Enter Subject : ", bg='black', fg='white') 102 | lb1.place(relx=0.05,rely=0.5) 103 | 104 | en1 = Entry(labelFrame) 105 | en1.place(relx=0.3,rely=0.5, relwidth=0.62) 106 | 107 | #Submit Button 108 | SearchBtn = Button(root,text="Search",bg='#264348', fg='white',command=search) 109 | SearchBtn.place(relx=0.28,rely=0.75, relwidth=0.18,relheight=0.08) 110 | 111 | quitBtn = Button(root,text="Quit",bg='#455A64', fg='white', command=root.quit) 112 | quitBtn.place(relx=0.53,rely=0.75, relwidth=0.18,relheight=0.08) 113 | 114 | root.mainloop() -------------------------------------------------------------------------------- /IssueBook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | J.A.R.V.I.S Says Hello 4 | 5 | @author: Ashlesh 6 | """ 7 | 8 | from tkinter import * 9 | from PIL import ImageTk,Image 10 | from tkinter import messagebox 11 | import pymysql 12 | 13 | # Add your own database name and password here to reflect in the code 14 | mypass = "root" 15 | mydatabase="rcpl_db" 16 | 17 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 18 | cur = con.cursor() 19 | 20 | # Enter Table Names here 21 | issueTable = "issuedetail" #Issue Table 22 | bookTable = "books" #Book Table 23 | stuTable = "studetail" #Student Table 24 | empTable = "empdetail" #Employee Table 25 | 26 | allRoll = [] #List To store all Roll Numbers 27 | allEmpId = [] #List To store all Employee IDs 28 | allBid = [] #List To store all Book IDs 29 | 30 | def issue(): 31 | 32 | global issueBtn,labelFrame,lb1,en1,en2,en3,quitBtn,root,Canvas1,status 33 | 34 | bid = en1.get() 35 | issueto = en2.get() 36 | issueby = en3.get() 37 | 38 | issueBtn.destroy() 39 | quitBtn.destroy() 40 | labelFrame.destroy() 41 | lb1.destroy() 42 | en1.destroy() 43 | en2.destroy() 44 | en3.destroy() 45 | 46 | 47 | extractBid = "select bid from "+bookTable 48 | try: 49 | cur.execute(extractBid) 50 | con.commit() 51 | for i in cur: 52 | allBid.append(i[0]) 53 | 54 | if bid in allBid: 55 | checkAvail = "select status from "+bookTable+" where bid = '"+bid+"'" 56 | cur.execute(checkAvail) 57 | con.commit() 58 | for i in cur: 59 | check = i[0] 60 | 61 | if check == 'avail': 62 | status = True 63 | else: 64 | status = False 65 | else: 66 | messagebox.showinfo("Error","Book ID not present") 67 | except: 68 | messagebox.showinfo("Error","Can't fetch Book IDs") 69 | 70 | extractRollno = "select rollno from "+stuTable 71 | try: 72 | cur.execute(extractRollno) 73 | con.commit() 74 | for i in cur: 75 | allRoll.append(i[0]) 76 | 77 | if issueto in allRoll: 78 | pass 79 | else: 80 | messagebox.showinfo("Error","Roll No not present") 81 | except: 82 | messagebox.showinfo("Error","Can't fetch Roll No") 83 | 84 | extractEmpID = "select empid from "+empTable 85 | try: 86 | cur.execute(extractEmpID) 87 | con.commit() 88 | for i in cur: 89 | allEmpId.append(i[0]) 90 | 91 | if issueby in allEmpId: 92 | pass 93 | else: 94 | messagebox.showinfo("Error","Emp ID not present") 95 | except: 96 | messagebox.showinfo("Error","Can't fetch Emp IDs") 97 | 98 | labelFrame = Frame(root,bg='black') 99 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5) 100 | 101 | y = 0.25 102 | 103 | Label(labelFrame, text="%-20s%-30s%-30s"%('BID','Issued To','Issued By'),bg='black',fg='white').place(relx=0.27,rely=0.1) 104 | Label(labelFrame, text="---------------------------------------------------------",bg='black',fg='white').place(relx=0.2,rely=0.2) 105 | 106 | issueSql = "insert into "+issueTable+" values ('"+bid+"','"+issueto+"','"+issueby+"')" 107 | show = "select * from "+issueTable 108 | 109 | updateStatus = "update "+bookTable+" set status = 'issued' where bid = '"+bid+"'" 110 | try: 111 | if bid in allBid and issueto in allRoll and issueby in allEmpId and status == True: 112 | cur.execute(issueSql) 113 | con.commit() 114 | cur.execute(updateStatus) 115 | con.commit() 116 | else: 117 | allBid.clear() 118 | allEmpId.clear() 119 | allRoll.clear() 120 | return 121 | con.commit() 122 | cur.execute(show) 123 | con.commit() 124 | for i in cur: 125 | Label(labelFrame, text="%-20s%-30s%-30s"%(i[0],i[1],i[2]),bg='black',fg='white').place(relx=0.27,rely=y) 126 | y += 0.1 127 | print(i) 128 | except: 129 | messagebox.showinfo("Search Error","The value entered is wrong, Try again") 130 | 131 | print(bid) 132 | print(issueto) 133 | print(issueby) 134 | 135 | allBid.clear() 136 | allEmpId.clear() 137 | allRoll.clear() 138 | 139 | backBtn = Button(root,text="< Back",bg='#455A64', fg='white', command=issueBook) 140 | backBtn.place(relx=0.53,rely=0.85, relwidth=0.18,relheight=0.08) 141 | 142 | 143 | def issueBook(): 144 | 145 | global en1,en2,en3,issueBtn,lb1,labelFrame,quitBtn,Canvas1,root,status 146 | 147 | root = Tk() 148 | root.title("Library") 149 | root.minsize(width=400,height=400) 150 | root.geometry("600x500") 151 | 152 | 153 | same=True 154 | n=0.3 155 | 156 | # Adding a background image 157 | background_image =Image.open("library.jpg") 158 | [imageSizeWidth, imageSizeHeight] = background_image.size 159 | 160 | newImageSizeWidth = int(imageSizeWidth*n) 161 | if same: 162 | newImageSizeHeight = int(imageSizeHeight*n) 163 | else: 164 | newImageSizeHeight = int(imageSizeHeight/n) 165 | 166 | 167 | Canvas1 = Canvas(root) 168 | 169 | Canvas1.config(bg="#706fd3",width = newImageSizeWidth, height = newImageSizeHeight) 170 | Canvas1.pack(expand=True,fill=BOTH) 171 | 172 | labelFrame = Frame(root,bg='black') 173 | labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.3) 174 | 175 | headingFrame1 = Frame(root,bg="#333945",bd=5) 176 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 177 | 178 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 179 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 180 | 181 | headingLabel = Label(headingFrame2, text="ISSUE BOOK", fg='black') 182 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 183 | 184 | # Book ID 185 | lb1 = Label(labelFrame,text="Book ID : ", bg='black', fg='white') 186 | lb1.place(relx=0.05,rely=0.2) 187 | 188 | en1 = Entry(labelFrame) 189 | en1.place(relx=0.3,rely=0.2, relwidth=0.62) 190 | 191 | # Issued To Roll Number 192 | lb2 = Label(labelFrame,text="Issued To(rollno) : ", bg='black', fg='white') 193 | lb2.place(relx=0.05,rely=0.4) 194 | 195 | en2 = Entry(labelFrame) 196 | en2.place(relx=0.3,rely=0.4, relwidth=0.62) 197 | 198 | # Issued By Employee Number 199 | lb3 = Label(labelFrame,text="Issued By(empid) : ", bg='black', fg='white') 200 | lb3.place(relx=0.05,rely=0.6) 201 | 202 | en3 = Entry(labelFrame) 203 | en3.place(relx=0.3,rely=0.6, relwidth=0.62) 204 | 205 | #Issue Button 206 | issueBtn = Button(root,text="Issue",bg='#d1ccc0', fg='black',command=issue) 207 | issueBtn.place(relx=0.28,rely=0.75, relwidth=0.18,relheight=0.08) 208 | 209 | quitBtn = Button(root,text="Quit",bg='#aaa69d', fg='black', command=root.quit) 210 | quitBtn.place(relx=0.53,rely=0.75, relwidth=0.18,relheight=0.08) 211 | 212 | root.mainloop() -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: Ashlesh 4 | """ 5 | 6 | from tkinter import * 7 | from PIL import ImageTk,Image 8 | import pymysql 9 | from tkinter import messagebox 10 | from AddBooks import * 11 | from DeleteBook import * 12 | from ViewBooks import * 13 | from SearchBook import * 14 | from IssueBook import * 15 | 16 | # Add your own database name and password here to reflect in the code 17 | mypass = "root" 18 | mydatabase="rcpl_db" 19 | 20 | # Enter Table Names here 21 | empTable = "empdetail" #Employee Table 22 | stuTable = "studetail" #Student Table 23 | 24 | root = Tk() 25 | root.title("Library") 26 | root.minsize(width=400,height=400) 27 | root.geometry("600x500") 28 | count = 0 29 | empFrameCount = 0 30 | 31 | con = pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase) 32 | cur = con.cursor() 33 | 34 | 35 | ''' 36 | This are the menus after logging in 37 | ''' 38 | def empMenu(): 39 | 40 | global headingFrame1,headingFrame2,headingLabel,SubmitBtn,Canvas1,labelFrame,backBtn 41 | headingFrame1.destroy() 42 | headingFrame2.destroy() 43 | headingLabel.destroy() 44 | Canvas1.destroy() 45 | SubmitBtn.destroy() 46 | 47 | Canvas1 = Canvas(root) 48 | 49 | Canvas1.config(bg="#f7f1e3",width = newImageSizeWidth, height = newImageSizeHeight) 50 | Canvas1.pack(expand=True,fill=BOTH) 51 | 52 | headingFrame1 = Frame(root,bg="#333945",bd=5) 53 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 54 | 55 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 56 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 57 | 58 | headingLabel = Label(headingFrame2, text="Employee MENU", fg='black') 59 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 60 | 61 | btn1 = Button(root,text="Add Book Details",bg='black', fg='white', command=addBooks) 62 | btn1.place(relx=0.28,rely=0.3, relwidth=0.45,relheight=0.1) 63 | 64 | btn2 = Button(root,text="Delete Book",bg='black', fg='white', command=delete) 65 | btn2.place(relx=0.28,rely=0.4, relwidth=0.45,relheight=0.1) 66 | 67 | btn3 = Button(root,text="View Book List",bg='black', fg='white', command=View) 68 | btn3.place(relx=0.28,rely=0.5, relwidth=0.45,relheight=0.1) 69 | 70 | btn4 = Button(root,text="Search Book",bg='black', fg='white', command=searchBook) 71 | btn4.place(relx=0.28,rely=0.6, relwidth=0.45,relheight=0.1) 72 | 73 | btn5 = Button(root,text="Issue Book to Student",bg='black', fg='white', command = issueBook) 74 | btn5.place(relx=0.28,rely=0.7, relwidth=0.45,relheight=0.1) 75 | 76 | backBtn = Button(root,text="< BACK",bg='#455A64', fg='white', command=Employee) 77 | backBtn.place(relx=0.5,rely=0.9, relwidth=0.18,relheight=0.08) 78 | 79 | def stuMenu(): 80 | 81 | global headingFrame1,headingFrame2,headingLabel,SubmitBtn,Canvas1,btn1,btn2,btn3,btn4,btn5,backBtn 82 | headingFrame1.destroy() 83 | headingFrame2.destroy() 84 | headingLabel.destroy() 85 | Canvas1.destroy() 86 | SubmitBtn.destroy() 87 | 88 | Canvas1 = Canvas(root) 89 | 90 | Canvas1.config(bg="#dff9fb",width = newImageSizeWidth, height = newImageSizeHeight) 91 | Canvas1.pack(expand=True,fill=BOTH) 92 | 93 | headingFrame1 = Frame(root,bg="#333945",bd=5) 94 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 95 | 96 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 97 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 98 | 99 | headingLabel = Label(headingFrame2, text="Student MENU", fg='black') 100 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 101 | 102 | btn1 = Button(root,text="View Book List",bg='black', fg='white',command=View) 103 | btn1.place(relx=0.28,rely=0.35, relwidth=0.45,relheight=0.1) 104 | 105 | btn2 = Button(root,text="Search Book",bg='black', fg='white',command=searchBook) 106 | btn2.place(relx=0.28,rely=0.45, relwidth=0.45,relheight=0.1) 107 | 108 | backBtn = Button(root,text="< BACK",bg='#455A64', fg='white', command=Student) 109 | backBtn.place(relx=0.5,rely=0.9, relwidth=0.18,relheight=0.08) 110 | 111 | 112 | ''' 113 | This Section handles the database 114 | ''' 115 | def gettingEmpDetails(): 116 | 117 | EmpId = en1.get() 118 | name = en2.get() 119 | password = en3.get() 120 | dept = en4.get() 121 | doj = en5.get() 122 | sal = en6.get() 123 | 124 | try: 125 | if (type(int(EmpId)) == int): 126 | pass 127 | else: 128 | messagebox.showinfo("Invalid Value","Employee ID should be an integer") 129 | return 130 | except: 131 | messagebox.showinfo("Invalid Value","Employee ID should be an integer") 132 | return 133 | 134 | try: 135 | if (type(float(sal)) == float or type(int(sal)) == int): 136 | pass 137 | else: 138 | messagebox.showinfo("Invalid Value","Salary should be a float/int value") 139 | return 140 | except: 141 | messagebox.showinfo("Invalid Value","Salary should be a float/int value") 142 | return 143 | 144 | sql = "insert into "+empTable+" values ('"+EmpId+"','"+name+"','"+password+"','"+dept+"','"+doj+"','"+sal+"')" 145 | try: 146 | cur.execute(sql) 147 | con.commit() 148 | except: 149 | messagebox.showinfo("Error inserting","Cannot add data to Database") 150 | 151 | print(EmpId) 152 | print(name) 153 | print(password) 154 | print(dept) 155 | print(doj) 156 | print(sal) 157 | en1.delete(0, END) 158 | en2.delete(0, END) 159 | en3.delete(0, END) 160 | en4.delete(0, END) 161 | en5.delete(0, END) 162 | en6.delete(0, END) 163 | 164 | def gettingStuDetails(): 165 | 166 | Rollno = en1.get() 167 | name = en2.get() 168 | password = en3.get() 169 | dept = en4.get() 170 | sem = en5.get() 171 | batch = en6.get() 172 | 173 | try: 174 | if (type(int(Rollno)) == int): 175 | pass 176 | else: 177 | messagebox.showinfo("Invalid Value","Roll number should be an integer") 178 | return 179 | except: 180 | messagebox.showinfo("Invalid Value","Roll number should be an integer") 181 | return 182 | 183 | 184 | sql = "insert into "+stuTable+" values ('"+Rollno+"','"+name+"','"+password+"','"+dept+"','"+sem+"','"+batch+"')" 185 | try: 186 | cur.execute(sql) 187 | con.commit() 188 | except: 189 | messagebox.showinfo("Error inserting","Cannot add data to Database") 190 | 191 | print(Rollno) 192 | print(name) 193 | print(password) 194 | print(dept) 195 | print(sem) 196 | print(batch) 197 | en1.delete(0, END) 198 | en2.delete(0, END) 199 | en3.delete(0, END) 200 | en4.delete(0, END) 201 | en5.delete(0, END) 202 | en6.delete(0, END) 203 | 204 | def gettingLoginDetails(): 205 | 206 | login = en1.get() 207 | name = en2.get() 208 | password = en3.get() 209 | role = en4.get() 210 | role.lower() 211 | 212 | if (role == 'emp'): 213 | sqlLoginID = "select empid from "+empTable+" where password = '"+password+"'" 214 | sqlName = "select name from "+empTable+" where password = '"+password+"'" 215 | 216 | try: 217 | cur.execute(sqlLoginID) 218 | for i in cur: 219 | getLoginID = i[0] 220 | cur.execute(sqlName) 221 | for i in cur: 222 | getName = i[0] 223 | 224 | if(getLoginID == login and getName == name): 225 | empMenu() 226 | messagebox.showinfo("SUCCESS","You have successfully logged in") 227 | else: 228 | messagebox.showerror("Failure","Can't log in, check your credentials") 229 | except: 230 | messagebox.showinfo("FAILED","Please check your credentials") 231 | elif (role == 'stu'): 232 | sqlLoginID = "select rollno from "+stuTable+" where password = '"+password+"'" 233 | sqlName = "select name from "+stuTable+" where password = '"+password+"'" 234 | 235 | try: 236 | cur.execute(sqlLoginID) 237 | for i in cur: 238 | getLoginID = i[0] 239 | cur.execute(sqlName) 240 | for i in cur: 241 | getName = i[0] 242 | 243 | if(getLoginID == login and getName == name): 244 | stuMenu() 245 | messagebox.showinfo("SUCCESS","You have successfully logged in") 246 | else: 247 | messagebox.showerror("Failure","Can't log in, check your credentials") 248 | except: 249 | messagebox.showinfo("FAILED","Please check your credentials") 250 | else: 251 | messagebox.showinfo("EXCEPTION","Role can only be emp or stu") 252 | return 253 | 254 | print(login) 255 | print(name) 256 | print(password) 257 | print(role) 258 | en1.delete(0, END) 259 | en2.delete(0, END) 260 | en3.delete(0, END) 261 | en4.delete(0, END) 262 | 263 | def EmpRegister(): 264 | 265 | global labelFrame 266 | 267 | global count 268 | count += 1 269 | 270 | if(count>=2): 271 | labelFrame.destroy() 272 | 273 | global en1,en2,en3,en4,en5,en6 274 | 275 | labelFrame = Frame(root,bg='#044F67') 276 | labelFrame.place(relx=0.2,rely=0.44,relwidth=0.6,relheight=0.42) 277 | 278 | # Employee ID 279 | lb1 = Label(labelFrame,text="Emp ID : ", bg='#044F67', fg='white') 280 | lb1.place(relx=0.05,rely=0.05) 281 | 282 | en1 = Entry(labelFrame) 283 | en1.place(relx=0.3,rely=0.05, relwidth=0.62) 284 | 285 | #Employee Name 286 | lb2 = Label(labelFrame,text="Name : ", bg='#044F67', fg='white') 287 | lb2.place(relx=0.05,rely=0.2) 288 | 289 | en2 = Entry(labelFrame) 290 | en2.place(relx=0.3,rely=0.2, relwidth=0.62) 291 | 292 | #Employee Paswword 293 | lb3 = Label(labelFrame,text="Password : ", bg='#044F67', fg='white') 294 | lb3.place(relx=0.05,rely=0.35) 295 | 296 | en3 = Entry(labelFrame) 297 | en3.place(relx=0.3,rely=0.35, relwidth=0.62) 298 | 299 | #Employee Department 300 | lb4 = Label(labelFrame,text="Department : ", bg='#044F67', fg='white') 301 | lb4.place(relx=0.05,rely=0.5) 302 | 303 | en4 = Entry(labelFrame) 304 | en4.place(relx=0.3,rely=0.5, relwidth=0.62) 305 | 306 | #Employee Date of Joining 307 | lb5 = Label(labelFrame,text="DOJ : ", bg='#044F67', fg='white') 308 | lb5.place(relx=0.05,rely=0.65) 309 | 310 | en5 = Entry(labelFrame) 311 | en5.place(relx=0.3,rely=0.65, relwidth=0.62) 312 | 313 | # Employee Salary 314 | lb5 = Label(labelFrame,text="Salary : ", bg='#044F67', fg='white') 315 | lb5.place(relx=0.05,rely=0.8) 316 | 317 | en6 = Entry(labelFrame) 318 | en6.place(relx=0.3,rely=0.8, relwidth=0.62) 319 | 320 | #Submit Button 321 | SubmitBtn = Button(root,text="SUBMIT",bg='#264348', fg='white',command=gettingEmpDetails) 322 | SubmitBtn.place(relx=0.28,rely=0.9, relwidth=0.18,relheight=0.08) 323 | 324 | 325 | # Login both for Employee and Student 326 | def Login(): 327 | 328 | global labelFrame 329 | 330 | global count 331 | count += 1 332 | 333 | if(count>=2): 334 | labelFrame.destroy() 335 | 336 | global en1,en2,en3,en4,SubmitBtn,btn1,btn2 337 | 338 | labelFrame = Frame(root,bg='#044F67') 339 | labelFrame.place(relx=0.2,rely=0.44,relwidth=0.6,relheight=0.3) 340 | 341 | # Login ID 342 | lb1 = Label(labelFrame,text="Login ID : ", bg='#044F67', fg='white') 343 | lb1.place(relx=0.05,rely=0.1) 344 | 345 | en1 = Entry(labelFrame) 346 | en1.place(relx=0.3,rely=0.1, relwidth=0.62) 347 | 348 | # Name 349 | lb2 = Label(labelFrame,text="Name : ", bg='#044F67', fg='white') 350 | lb2.place(relx=0.05,rely=0.3) 351 | 352 | en2 = Entry(labelFrame) 353 | en2.place(relx=0.3,rely=0.3, relwidth=0.62) 354 | 355 | # Paswword 356 | lb3 = Label(labelFrame,text="Password : ", bg='#044F67', fg='white') 357 | lb3.place(relx=0.05,rely=0.5) 358 | 359 | en3 = Entry(labelFrame) 360 | en3.place(relx=0.3,rely=0.5, relwidth=0.62) 361 | 362 | # Role 363 | lb4 = Label(labelFrame,text="Role : ", bg='#044F67', fg='white') 364 | lb4.place(relx=0.05,rely=0.7) 365 | 366 | en4 = Entry(labelFrame) 367 | en4.place(relx=0.3,rely=0.7, relwidth=0.62) 368 | 369 | #Submit Button 370 | SubmitBtn = Button(root,text="SUBMIT",bg='#264348', fg='white',command=gettingLoginDetails) 371 | SubmitBtn.place(relx=0.28,rely=0.9, relwidth=0.18,relheight=0.08) 372 | 373 | # Student Registration 374 | def studentRegister(): 375 | 376 | global labelFrame 377 | 378 | global count 379 | count += 1 380 | 381 | if(count>=2): 382 | labelFrame.destroy() 383 | 384 | global en1,en2,en3,en4,en5,en6 385 | 386 | labelFrame = Frame(root,bg='#044F67') 387 | labelFrame.place(relx=0.2,rely=0.44,relwidth=0.6,relheight=0.42) 388 | 389 | # Student Roll no 390 | lb1 = Label(labelFrame,text="Roll No : ", bg='#044F67', fg='white') 391 | lb1.place(relx=0.05,rely=0.05) 392 | 393 | en1 = Entry(labelFrame) 394 | en1.place(relx=0.3,rely=0.05, relwidth=0.62) 395 | 396 | # Sudent Name 397 | lb2 = Label(labelFrame,text="Name : ", bg='#044F67', fg='white') 398 | lb2.place(relx=0.05,rely=0.2) 399 | 400 | en2 = Entry(labelFrame) 401 | en2.place(relx=0.3,rely=0.2, relwidth=0.62) 402 | 403 | # Student Password 404 | lb3 = Label(labelFrame,text="Password : ", bg='#044F67', fg='white') 405 | lb3.place(relx=0.05,rely=0.35) 406 | 407 | en3 = Entry(labelFrame) 408 | en3.place(relx=0.3,rely=0.35, relwidth=0.62) 409 | 410 | # Student Department 411 | lb4 = Label(labelFrame,text="Dept : ", bg='#044F67', fg='white') 412 | lb4.place(relx=0.05,rely=0.5) 413 | 414 | en4 = Entry(labelFrame) 415 | en4.place(relx=0.3,rely=0.5, relwidth=0.62) 416 | 417 | # Student Semester 418 | lb5 = Label(labelFrame,text="Semester : ", bg='#044F67', fg='white') 419 | lb5.place(relx=0.05,rely=0.65) 420 | 421 | en5 = Entry(labelFrame) 422 | en5.place(relx=0.3,rely=0.65, relwidth=0.62) 423 | 424 | # Student Batch 425 | lb6 = Label(labelFrame,text="Batch : ", bg='#044F67', fg='white') 426 | lb6.place(relx=0.05,rely=0.8) 427 | 428 | en6 = Entry(labelFrame) 429 | en6.place(relx=0.3,rely=0.8, relwidth=0.62) 430 | 431 | #Submit Button 432 | SubmitBtn = Button(root,text="SUBMIT",bg='#264348', fg='white',command=gettingStuDetails) 433 | SubmitBtn.place(relx=0.28,rely=0.9, relwidth=0.18,relheight=0.08) 434 | 435 | # Employee Home Page 436 | def Employee(): 437 | 438 | global headingFrame1,headingFrame2,headingLabel,btn1,btn2,Canvas1 439 | headingFrame1.destroy() 440 | headingFrame2.destroy() 441 | headingLabel.destroy() 442 | Canvas1.destroy() 443 | btn1.destroy() 444 | btn2.destroy() 445 | 446 | Canvas1 = Canvas(root) 447 | 448 | Canvas1.config(bg="#FFF9C4",width = newImageSizeWidth, height = newImageSizeHeight) 449 | Canvas1.pack(expand=True,fill=BOTH) 450 | 451 | 452 | headingFrame1 = Frame(root,bg="#333945",bd=5) 453 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 454 | 455 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 456 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 457 | 458 | headingLabel = Label(headingFrame2, text="Hello, Employee", fg='black') 459 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 460 | 461 | btn1 = Button(root,text="Register",bg='black', fg='white',command=EmpRegister) 462 | btn1.place(relx=0.28,rely=0.3, relwidth=0.2,relheight=0.1) 463 | 464 | btn2 = Button(root,text="Login",bg='black', fg='white', command=Login) 465 | btn2.place(relx=0.53,rely=0.3, relwidth=0.2,relheight=0.1) 466 | 467 | btn3 = Button(root,text="Quit",bg='#455A64', fg='white', command=root.quit) 468 | btn3.place(relx=0.53,rely=0.9, relwidth=0.18,relheight=0.08) 469 | 470 | # Student Home Page 471 | def Student(): 472 | 473 | global headingFrame1,headingFrame2,headingLabel,btn1,btn2,Canvas1 474 | headingFrame1.destroy() 475 | headingFrame2.destroy() 476 | headingLabel.destroy() 477 | Canvas1.destroy() 478 | btn1.destroy() 479 | btn2.destroy() 480 | 481 | Canvas1 = Canvas(root) 482 | 483 | Canvas1.config(bg="#FFF9C4",width = newImageSizeWidth, height = newImageSizeHeight) 484 | Canvas1.pack(expand=True,fill=BOTH) 485 | 486 | 487 | headingFrame1 = Frame(root,bg="#333945",bd=5) 488 | headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13) 489 | 490 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 491 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 492 | 493 | headingLabel = Label(headingFrame2, text="Hello, Student", fg='black') 494 | headingLabel.place(relx=0.25,rely=0.15, relwidth=0.5, relheight=0.5) 495 | 496 | btn1 = Button(root,text="Register",bg='black', fg='white', command=studentRegister) 497 | btn1.place(relx=0.28,rely=0.3, relwidth=0.2,relheight=0.1) 498 | 499 | btn2 = Button(root,text="Login",bg='black', fg='white', command=Login) 500 | btn2.place(relx=0.53,rely=0.3, relwidth=0.2,relheight=0.1) 501 | 502 | btn3 = Button(root,text="Quit",bg='#455A64', fg='white', command=root.quit) 503 | btn3.place(relx=0.53,rely=0.9, relwidth=0.18,relheight=0.08) 504 | 505 | # Take n greater than 0.25 and less than 5 506 | same=True 507 | n=0.3 508 | 509 | # Adding a background image 510 | background_image =Image.open("library.jpg") 511 | [imageSizeWidth, imageSizeHeight] = background_image.size 512 | 513 | newImageSizeWidth = int(imageSizeWidth*n) 514 | if same: 515 | newImageSizeHeight = int(imageSizeHeight*n) 516 | else: 517 | newImageSizeHeight = int(imageSizeHeight/n) 518 | 519 | background_image = background_image.resize((newImageSizeWidth,newImageSizeHeight),Image.ANTIALIAS) 520 | img = ImageTk.PhotoImage(background_image) 521 | 522 | Canvas1 = Canvas(root) 523 | 524 | Canvas1.create_image(300,340,image = img) 525 | Canvas1.config(bg="white",width = newImageSizeWidth, height = newImageSizeHeight) 526 | Canvas1.pack(expand=True,fill=BOTH) 527 | 528 | headingFrame1 = Frame(root,bg="#333945",bd=5) 529 | headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16) 530 | 531 | headingFrame2 = Frame(headingFrame1,bg="#EAF0F1") 532 | headingFrame2.place(relx=0.01,rely=0.05,relwidth=0.98,relheight=0.9) 533 | 534 | headingLabel = Label(headingFrame2, text="Welcome to RCPL Library", fg='black') 535 | headingLabel.place(relx=0.25,rely=0.1, relwidth=0.5, relheight=0.5) 536 | 537 | btn1 = Button(root,text="Employee",bg='black', fg='white', command=Employee) 538 | btn1.place(relx=0.25,rely=0.3, relwidth=0.2,relheight=0.1) 539 | 540 | btn2 = Button(root,text="Student",bg='black', fg='white', command=Student) 541 | btn2.place(relx=0.55,rely=0.3, relwidth=0.2,relheight=0.1) 542 | 543 | root.mainloop() 544 | --------------------------------------------------------------------------------