-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue.py
More file actions
112 lines (94 loc) · 3.91 KB
/
issue.py
File metadata and controls
112 lines (94 loc) · 3.91 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from tkinter import *
from tkinter import messagebox
import mysql.connector
from datetime import timedelta, date
class issue:
def issue_db(self):
global id
global StudentName
bid=id.get()
bStudentName=StudentName.get()
db = mysql.connector.connect(host ="localhost",user = "root",password = 'sanal',database='library',charset="utf8")
cursor = db.cursor(buffered=True)
try:
checkavailability=" select * from books where available='YES';"
print(checkavailability)
cursor.execute(checkavailability)
flag=0
for i in cursor:
print(i[0])
if(i[0]==bid):
flag=1
break;
if flag==1:
try:
sqlquery= "insert into issue(bid,bStudentName,issue_date,due_date) values('" + bid +"','" +bStudentName+"','"+ str(date.today())+"','"+str(date.today() + timedelta(days=5))+"' );"
print(sqlquery)
cursor.execute(sqlquery)
db.commit()
updatequery="update books set available='NO' where bid='"+bid +"';"
print(updatequery)
cursor.execute(updatequery)
db.commit()
messagebox.showinfo('Success',"Book issued Successfully")
except:
messagebox.showinfo('Error',"No such user")
else:
messagebox.showinfo("Error","Required Book is not available")
except mysql.connector.Error as err:
print("Something went wrong: {}".format(err))
self.issueBooks()
def issueBooks(self):
global id
global StudentName
for widgets in self.Frame1.winfo_children():
widgets.destroy()
greet = Label(self.Frame1)
greet.place(relx=0.314, rely=0.071, height=31, width=174)
greet.configure(background="#d9d9d9")
greet.configure(disabledforeground="#a3a3a3")
greet.configure(font="-family {Poppins Medium} -size 24")
greet.configure(foreground="#000000")
greet.configure(text='''Issue Book''')
L = Label(self.Frame1)
L.place(relx=0.098, rely=0.225, height=41, width=94)
L.configure(background="#d9d9d9")
L.configure(disabledforeground="#a3a3a3")
L.configure(font="-family {Segoe UI} -size 10")
L.configure(foreground="#000000")
L.configure(text='''Book ID''')
id = Entry(self.Frame1)
id.place(relx=0.294, rely=0.237, height=30, relwidth=0.38)
id.configure(background="white")
id.configure(disabledforeground="#a3a3a3")
id.configure(font="TkFixedFont")
id.configure(foreground="#000000")
id.configure(insertbackground="black")
StudentName = Entry(self.Frame1)
StudentName.place(relx=0.294, rely=0.367, height=30, relwidth=0.38)
StudentName.configure(background="white")
StudentName.configure(disabledforeground="#a3a3a3")
StudentName.configure(font="TkFixedFont")
StudentName.configure(foreground="#000000")
StudentName.configure(highlightbackground="#d9d9d9")
StudentName.configure(highlightcolor="black")
StudentName.configure(insertbackground="black")
StudentName.configure(selectbackground="blue")
StudentName.configure(selectforeground="white")
Label2_1 = Label(self.Frame1)
Label2_1.place(relx=0.102, rely=0.351, height=41, width=94)
Label2_1.configure(activebackground="#f9f9f9")
Label2_1.configure(activeforeground="black")
Label2_1.configure(background="#d9d9d9")
Label2_1.configure(disabledforeground="#a3a3a3")
Label2_1.configure(font="-family {Segoe UI} -size 10")
Label2_1.configure(foreground="#000000")
Label2_1.configure(highlightbackground="#d9d9d9")
Label2_1.configure(highlightcolor="black")
Label2_1.configure(text='''Member ID''')
submitbtn = Button(self.Frame1)
submitbtn.place(relx=0.42, rely=0.526, height=25, width=76)
submitbtn.configure(takefocus="")
submitbtn.configure(text='''Submit''')
submitbtn.configure(command=self.issue_db)
pass