-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfine.py
57 lines (55 loc) · 2.59 KB
/
fine.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
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import re
import sys,os
py = sys.executable
#creating window
class Fine(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(500, 300)
self.minsize(500, 300)
self.title("Clear Fine")
#creating variables
a = StringVar()
def clear():
if len(a.get()) == 0:
messagebox.showerror("Error","Please Enter The Id")
elif a.get().isdigit():
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Select Student_Id from students")
student = self.myCursor.fetchall()
listStudent = list(student)
if listStudent:
for sid in listStudent:
if int(a.get()) in sid:
con = messagebox.askyesno("Confirm","Are You Sure you want to clear the fine?")
if con:
self.myCursor.execute("Update students set Fine = 0 where Student_Id = ?",[a.get()])
self.conn.commit()
self.conn.close()
messagebox.showinfo("Successful","All Fine Cleared")
d = messagebox.askyesno("Confirm","Do you want to clear another fine?")
if d:
self.destroy()
os.system('%s %s'% (py,'fine.py'))
else:
self.destroy()
else:
messagebox.showinfo("Oops","The Id you entered is not found")
else:
messagebox.showerror("Error","Please Check The Id")
except:
messagebox.showinfo("Oops","Something Goes Wrong")
else:
messagebox.showerror("Error","Please Check The Id")
Label(self,text="Enter Student Id", font = ('arial',15,'bold')).place(x=50,y=100)
Entry(self,textvariable=a,width=40).place(x=230,y=105)
Button(self, text='Clear Fine', width=20,command = clear).place(x=230, y=155)
Fine().mainloop()