-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemove_student.py
45 lines (41 loc) · 1.81 KB
/
Remove_student.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
from tkinter import *
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys
py = sys.executable
class Rem(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(450,250)
self.minsize(450,250)
self.title("Remove Student")
a = StringVar()
def iii():
if len(a.get()) == 0:
messagebox.showerror("Error", "Please Enter The Student Id")
else:
c = messagebox.askyesno('Remove Book', 'Are You Sure You Want To Remove The Student')
if c:
try:
self.conn = sqlite3.connect('library_administration.db')
self.mycursor = self.conn.cursor()
self.mycursor.execute("DELETE FROM students WHERE Student_Id = ?", [a.get()])
messagebox.showinfo('Remove', 'Succesfully Removed')
self.conn.commit()
self.conn.close()
d = messagebox.askyesno("Confirm", "Do you want to remove another student")
if d:
self.destroy()
os.system('%s %s' % (py, 'Remove_student.py'))
else:
self.destroy()
except Error:
messagebox.showerror("Error", "Something Goes Wrong")
self.lb = Label(self, text="Enter Student Id", font=('Comic Scan Ms', 15, 'bold'))
self.lb.place(x=30, y=70)
self.e1 = Entry(self, textvariable=a, width=30).place(x=230, y=77)
self.butt1234 = Button(self, text="Remove", width=20, command=iii).place(x=230, y=120)
Rem().mainloop()