-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtdatabase.py
302 lines (192 loc) · 8.27 KB
/
tdatabase.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
import mysql.connector
mydb=mysql.connector.connect(
host="localhost",
user="root",
passwd="NIKHIL@098sharma",
database="teacher"
)
mycursor=mydb.cursor()
#mycursor.execute("CREATE DATABASE teacher")
#mycursor.execute("SHOW DATABASES")
#for db in mycursor:
# print(db)
#mycursor.execute("CREATE TABLE teacher (username VARCHAR(255), pwd VARCHAR(255),user_id INTEGER AUTO_INCREMENT PRIMARY KEY)")
# mycursor.execute("SHOW TABLES")
# for table in mycursor:
# print(table[0])
# sqlStuff="INSERT INTO teacher (username,pwd) VALUES (%s,%s)"
# record1=("chavi","12345")
# mycursor.execute(sqlStuff,record1)
# mydb.commit()
# SqlStuff="INSERT INTO teacher (username,pwd) VALUES (%s,%s)"
# record1=("pooja","pooja")
# mycursor.execute(sqlStuff,record1)
# mydb.commit()
# sqlStuff="INSERT INTO teacher (username,pwd) VALUES (%s,%s)"
# record1=("gunseerat","gunseerat")
# mycursor.execute(sqlStuff,record1)
# mydb.commit()
# sqlStuff="INSERT INTO teacher (username,pwd) VALUES (%s,%s)"
# record1=("mamta","mamta")
# mycursor.execute(sqlStuff,record1)
# mydb.commit()
from tkinter import *
from tkcalendar import *
from PIL import Image, ImageTk
import tkinter.messagebox as tmsg
def geti():
count=0
var1=loginent.get() #entry box widget for username
var2=passwordent.get() #entry box widget for password
mycursor.execute("SELECT username FROM teacher")
myresult=mycursor.fetchall()
for row in myresult:
if(row[0]==var1):
count=1
mycursor.execute("SELECT pwd FROM teacher")
myresult=mycursor.fetchall()
for row in myresult:
if(row[0]==var2):
count=count+1
print(count)
if count==2:
frame1.pack_forget()
frame2.pack_forget()
f1.pack(padx=20,pady=70,side=LEFT,anchor="center")
f2.pack(padx=20,pady=(70,0),side=TOP)
f3.pack(padx=20,side=TOP)
tmsg.showinfo("user Login","Login successful")
if (count==1):
tmsg.showinfo("user login","Check user id or password again ")
if(count==0):
tmsg.showinfo("user login","Please enter valid user id or password ")
loginval.set('')
passwordval.set('')
root=Tk()
root.geometry("450x450")
root.title("Python-Project")
root.configure(bg='#F5F5F5')
p12 = PhotoImage(file = 'Online_class_Logo2_2_400x200.png')
# Setting icon of master window
root.iconphoto(False, p12)
frame2=Frame(root,borderwidth=2) #Adding Frame
frame2.pack(padx=23,pady=120,side=TOP)
photo=ImageTk.PhotoImage(file="Online_class_Logo2_2_400x200.png")
lb=Label(frame2,image=photo)
lb.pack()
frame1=Frame(frame2)
frame1.pack(pady=20,padx=30)
loginval=StringVar()
passwordval=StringVar()
label1=Label(frame1,text="Username",font="Montserrat 13 bold" )
label1.pack()
loginent=Entry(frame1,textvariable=loginval,borderwidth=4,font="Montserrat") #loginent is the
loginent.pack(pady=20,padx=30,ipady=7,ipadx=16)
label2=Label(frame1,text="Password ",font="Montserrat 13 bold")
label2.pack()
passwordent=Entry(frame1,textvariable=passwordval,show="*",borderwidth=4,font="Montserrat")
passwordent.pack(pady=20,padx=30,ipady=7,ipadx=16)
Button(frame1,text="Click to login",command=geti,borderwidth=8,font="Montserrat 10 bold").pack(pady=(10,20))
def fun1():
val=cal.get_date()
print(val)
if(val=='10/5/20' or val=='10/12/20' or val=='10/19/20' or val=='10/26/20'):
f3.pack(padx=20,side=TOP)
l1['text']="Monday"
l1['fg']="black"
l2['text']="10-11: MTH 705"
l3['text']="11-12: CSE 205"
l5['text']="04-05: CSE 000"
l6['text']="04-05: PES 319"
l4['text']="02-03: PEL 999"
l2['bg']="#E08686"
l6['bg']="#E08686"
l3['bg']="#E08686"
l4['bg']="#E08686"
l5['bg']="#E08686"
if(val=='10/6/20' or val=='10/13/20' or val=='10/20/20' or val=='10/27/20'):
f3.pack(padx=20,side=TOP)
l1['text']="Tuesday"
l1['fg']="black"
l2['text']="09-10: CSE 000"
l3['text']="10-11: CSE 999"
l4['text']="01-02: PEL 231"
l5['text']="02-04: MTH 555"
l2['bg']="#E08686"
l3['bg']="#E08686"
l4['bg']="#E08686"
l5['bg']="#E08686"
l6.pack_forget()
if(val=='10/7/20' or val=='10/14/20' or val=='10/21/20' or val=='10/28/20'):
f3.pack(padx=20,side=TOP)
l1['text']="Wednesday"
l1['fg']="black"
l2['text']="11-12: PES 319"
l3['text']="02-03: MGN 231"
l4['text']="03-04: ASP 380"
l5['text']="04-05: RES 760"
l6['text']="05-06: MTH 444"
l6.pack(padx=20,pady=20,side=TOP)
l6['bg']="#E08686"
l2['bg']="#E08686"
l3['bg']="#E08686"
l4['bg']="#E08686"
l5['bg']="#E08686"
if(val=='10/8/20' or val=='10/15/20' or val=='10/22/20' or val=='10/29/20' or val=='10/1/20'):
f3.pack(padx=20,side=TOP)
l1['text']="Thursday"
l1['fg']="black"
l2['text']="10-12: CSE 250"
l3['text']="01-02: PAS 487"
l4['text']="03-04: CSE 320"
l5['text']="04-05: CSE 211"
l2['bg']="#E08686"
l6.pack_forget()
l3['bg']="#E08686"
l4['bg']="#E08686"
l5['bg']="#E08686"
if(val=='10/9/20' or val=='10/16/20' or val=='10/23/20' or val=='10/30/20' or val=='10/2/20'):
f3.pack(padx=20,side=TOP)
l1['text']="Friday"
l1['fg']="black"
l2['text']="10-11: CSE 700"
l3['text']="11-12: CSE 999"
l4['text']="12-01: PEL 231"
l5['text']="02-04: PES 320"
l6['text']="05-06: MTH 440"
l6.pack(padx=20,pady=20,side=TOP)
l6['bg']="#E08686"
l2['bg']="#E08686"
l3['bg']="#E08686"
l4['bg']="#E08686"
l5['bg']="#E08686"
if(val=='10/10/20' or val=='10/17/20' or val=='10/24/20' or val=='10/3/20'):
f3.pack_forget()
l1['text']="Saturday"
l1['fg']="#CC5D5D"
if(val=='10/11/20' or val=='10/18/20' or val=='10/25/20' or val=='10/4/20'):
f3.pack_forget()
l1['text']="Sunday"
l1['fg']="#CC5D5D"
def openFile():
import server
f1=Frame(root,bg="#F5F5F5")
f2=Frame(root,bg="#F5F5F5")
f3=Frame(root,bg="#F5F5F5")
cal=Calendar(f1,selectmode="day",year=2020,month=10,day=5,font="Montserrat 11")
cal.pack( pady=30,padx=30)
b1= Button(f1,text="Get Timetable",fg="#000",bg="#E08686",font="Montserrat 10",borderwidth=0,command=fun1,pady=5,padx=10)
b1.pack(padx=20,pady=20)
l1=Label(f2,text="Monday", font="Montserrat 18",bg="#F5F5F5")
l1.pack(padx=20,pady=40)
l2=Button(f3,text="10-11 : MTH 705",bg="#E08686",padx=200,pady=10,command=lambda:openFile() ,borderwidth=0,font="Montserrat 11")
l2.pack(padx=20,pady=20,side=TOP)
l3=Button(f3,text="11-12 : CSE 205",bg="#E08686",padx=200,pady=10,command=lambda:openFile() ,borderwidth=0,font="Montserrat 11")
l3.pack(padx=20,pady=20,side=TOP)
l4=Button(f3,text="02-03 : PEL 999",bg="#E08686",padx=195,pady=10,command=lambda:openFile() , borderwidth=0,font="Montserrat 11")
l4.pack(padx=20,pady=20,side=TOP)
l5=Button(f3,text="04-05 : CSE 000",bg="#E08686",padx=193,pady=10,command=lambda:openFile() ,borderwidth=0,font="Montserrat 11")
l5.pack(padx=20,pady=20,side=TOP)
l6=Button(f3,text="05-06 : PES 319",bg="#E08686",padx=193,pady=10,command=lambda:openFile() ,borderwidth=0,font="Montserrat 11")
l6.pack(padx=20,pady=20,side=TOP)
root.mainloop()