-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn_book.py
More file actions
40 lines (36 loc) · 1.19 KB
/
return_book.py
File metadata and controls
40 lines (36 loc) · 1.19 KB
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
from tkinter import *
from tkinter import messagebox
import datetime
from connect_db import connect
import pymysql
def return_books(home, return_book):
return_book.configure(background="black")
Label(
return_book, text="Return Book", bg="black", fg="white", font=("Courier", 35)
).pack(pady=15)
Label(
return_book, text="Issue Id", bg="black", fg="white", font=("Courier", 25)
).pack(pady=5)
issue_id = Text(return_book, height=1, width=30, font=("Courier", 25))
issue_id.pack(pady=5)
return_book.pack(expand=1, fill=X)
Button(
return_book,
text="Submit",
command=lambda: returnbook(issue_id),
bg="black",
fg="white",
font=("Courier", 25),
).pack(pady=12)
home.pack_forget()
def returnbook(issue_id):
issue_id = issue_id.get(1.0, "end-1c")
today = datetime.date.today()
returned_date = str(today)
query = f'update Issue set returned_date="{str(returned_date)}" where issue_id={issue_id}'
print(query)
try:
connect(query)
messagebox.showinfo("Success", "Book returned")
except (pymysql.Error, pymysql.Warning) as e:
messagebox.showinfo("Error", str(e))