-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateEntryFile.py
145 lines (120 loc) · 4.91 KB
/
updateEntryFile.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from tkinter import *
import mysql.connector
import tkinter.messagebox as tmsg
import pyfiglet
from ttkthemes import themed_tk as t
from tkinter import ttk
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="deepraj02",
database="schoolmanagement"
)
mycursor = mydb.cursor()
def clear1():
roll.delete(0, END)
nam.delete(0, END)
clas.delete(0, END)
phon.delete(0, END)
addr.delete(0, END)
def updateThatName():
global mycursor, roll, nam
sql = "UPDATE Student SET Name =(%s) WHERE RollNo = %s"
valls=(nam.get(),roll.get())
mycursor.execute(sql,valls)
mydb.commit()
tmsg.showinfo("INFO", "Data Updated Successfully\n")
clear1()
def updateThatClass():
global mycursor, clas, roll
sql = f"UPDATE Student SET Class = {clas.get()} WHERE RollNo = {roll.get()}"
mycursor.execute(sql)
mydb.commit()
tmsg.showinfo("INFO", "Data Updated Successfully\n")
clear1()
def updateThatPhone():
global mycursor, phon, roll
sql = f"UPDATE Student SET Phone = {phon.get()} WHERE RollNo = {roll.get()}"
mycursor.execute(sql)
mydb.commit()
tmsg.showinfo("INFO", "Data Updated Successfully\n")
clear1()
def updateThatAddress():
global mycursor, addr, roll
sql = "UPDATE Student SET Address = %s WHERE RollNo = %s"
vall=(addr.get(),roll.get())
mycursor.execute(sql,vall)
mydb.commit()
tmsg.showinfo("INFO", "Data Updated Successfully\n")
clear1()
def updateThatSucker():
global mycursor, roll, nam, clas, phon, addr
sql = "UPDATE Student SET Name = %s, Class= %s, Phone= %s, Address= %s WHERE RollNo = %s"
val=(nam.get(),clas.get(),phon.get(),addr.get(),roll.get())
mycursor.execute(sql,val)
mydb.commit()
tmsg.showinfo("INFO", "Data Updated Successfully\n")
clear1()
roll = ""
nam = ""
clas = ""
phon = ""
addr = ""
def updateEntry():
global roll, nam, clas, phon, addr
root = t.ThemedTk(theme="adapta")
root.title("Data Update Portal")
root.wm_iconbitmap(r"res/update.ico")
root.geometry("750x600")
root.config(bg="#2C3335")
Canvas1 = Canvas(root)
Canvas1.config(bg="#2C3335")
Canvas1.pack(expand=True, fill=BOTH)
headingFrame1 = Frame(root, bg="#FFBB00", bd=5)
headingFrame1.place(relx=0.25, rely=0.1, relwidth=0.5, relheight=0.13)
headingLabel = Label(headingFrame1, text="Update Entry",
bg='black', fg='white', font=("hack 20"))
headingLabel.place(relx=0, rely=0, relwidth=1, relheight=1)
labelFrame = Frame(root, bg='black')
labelFrame.place(relx=0.1, rely=0.3, relwidth=0.8, relheight=0.5)
lb2 = Label(labelFrame, text="Roll NO : ", bg='black',
fg='white', font="hack 14")
lb2.place(relx=0.08, rely=0.2)
lb2 = Label(labelFrame, text="Name : ", bg='black',
fg='white', font="hack 14")
lb2.place(relx=0.08, rely=0.3)
lb2 = Label(labelFrame, text="Class : ", bg='black',
fg='white', font="hack 14")
lb2.place(relx=0.08, rely=0.4)
lb2 = Label(labelFrame, text="Phone No.",
bg='black', fg='white', font="hack 14")
lb2.place(relx=0.08, rely=0.5)
lb2 = Label(labelFrame, text="Address : ", bg='black',
fg='white', font="hack 14")
lb2.place(relx=0.08, rely=0.6)
roll = Entry(labelFrame, width=8, font="hack 17")
roll.place(relx=0.28, rely=0.2, relwidth=0.62)
nam = Entry(labelFrame, width=8, font="hack 17")
nam.place(relx=0.28, rely=0.3, relwidth=0.62)
clas = Entry(labelFrame, width=8, font="hack 17")
clas.place(relx=0.28, rely=0.4, relwidth=0.62)
phon = Entry(labelFrame, width=8, font="hack 17")
phon.place(relx=0.28, rely=0.5, relwidth=0.62)
addr = Entry(labelFrame, width=8, font="hack 17")
addr.place(relx=0.28, rely=0.6, relwidth=0.62)
s = ttk.Style().configure('my.TButton', font="hack 11")
ttk.Button(root, text="U.Name", style="my.TButton",
command=updateThatName, width=6).place(relx=0.06, rely=0.87)
ttk.Button(root, text="U.Class", style="my.TButton",
command=updateThatClass, width=6).place(relx=0.179, rely=0.87)
ttk.Button(root, text="U.PhoneNo.", style="my.TButton",
command=updateThatPhone, width=6).place(relx=0.299, rely=0.87)
ttk.Button(root, text="U.Addr", style="my.TButton",
command=updateThatAddress, width=6).place(relx=0.419, rely=0.87)
ttk.Button(root, text="U.All", style="my.TButton",
command=updateThatSucker, width=6).place(relx=0.535, rely=0.87)
ttk.Button(root, text="Clear", style="my.TButton",
command=clear1, width=6).place(relx=0.755, rely=0.87)
ttk.Button(root, text="Exit", style="my.TButton",
command=root.destroy, width=6).place(relx=0.869, rely=0.87)
root.mainloop()