-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturnBook.py
58 lines (44 loc) · 1.96 KB
/
returnBook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from tkinter import *
from tkinter import messagebox
import sqlite3
con = sqlite3.connect('library.db')
cur = con.cursor()
class returnBook(Toplevel):
def __init__(self):
Toplevel.__init__(self)
self.geometry("650x750+550+200")
self.title("Return Book")
self.resizable(False, False)
###############################Frames################
# Top Frame
self.topFrame = Frame(self, height=150, bg='white')
self.topFrame.pack(fill=X)
# bottom frame
self.bottomFrame = Frame(self, height=600, bg='#708d8d')
self.bottomFrame.pack(fill=X)
# heading,image
heading = Label(self.topFrame, text=' Return', font=' arial 30 bold', fg="#51702c", bg='white')
heading.place(x=210, y=60)
################################################entries and labels########3
# member name
self.lbl_name = Label(self.bottomFrame, text='Name:', font='arial 10 bold', bg="#c4b48c", fg="black")
self.lbl_name.place(x=40, y=40)
self.ent_name = Entry(self.bottomFrame, width=30, bd=4)
self.ent_name.insert(0, 'PLEASE ENTER BOOK NAME')
self.ent_name.place(x=150, y=45)
# button
button = Button(self.bottomFrame, text='Return', command=self.delmember, fg='white', bg="#51702c")
button.place(x=270, y=200)
def delmember(self):
name = self.ent_name.get()
phone = self.ent_phone.get()
if name and phone != "":
try:
query = "DELETE FROM 'MEMBERS' (member_name,member_phone) VALUES(?,? )"
cur.execute(query, (name, phone))
con.commit()
messagebox.showinfo("Success", "Successfully removed from database")
except:
messagebox.showerror("ERROR", "Can delete from database")
else:
messagebox.showerror("ERROR", "Fields cant be empty")