-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuition.py
More file actions
1525 lines (1077 loc) · 56.5 KB
/
Tuition.py
File metadata and controls
1525 lines (1077 loc) · 56.5 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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Tuition Management Website
#Author:- Navika Agarwal
#Email:- navikaag20@gmail.com
#Date:- 27-01-2024
try:
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk,Image
import mysql.connector as mysql
from tkinter import messagebox
from Std_Info import Student_Info
import datetime
import time
import threading
import os
import sys
from fpdf import FPDF
except ImportError as r:
tk.messagebox.showerror("Error!",r)
print('Module not found!',r)
class Teacher_Register(tk.Frame):
"""Teacher Registration frame for registering the teachers"""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
font_size=14
saveimg=Image.open('images/floppy-disk.png')
save_img=ImageTk.PhotoImage(saveimg)
load1 = Image.open("images/man-icon.png")
render_load1 = ImageTk.PhotoImage(load1)
load2 = Image.open("images/App-password-icon (1).png")
render_load2 = ImageTk.PhotoImage(load2)
load3 = Image.open("images/42496-school-icon (1).png")
render_load3 = ImageTk.PhotoImage(load3)
regisimg=Image.open('images/register.jpg')
regisimg = regisimg.resize((400, 180), Image.ANTIALIAS)
regis_img=ImageTk.PhotoImage(regisimg)
regis = ttk.Label(self,image=regis_img)
regis.render=regis_img
inst_l = ttk.Label(self, text="Institute Name",image=render_load3,compound=tk.LEFT,font=("TkDefaultFont", font_size))
inst_l.image=render_load3
username_l = ttk.Label(self, text="Username",image=render_load1,compound=tk.LEFT,font=("TkDefaultFont", font_size))
username_l.image =render_load1
password_l = ttk.Label(self, text="Password",image=render_load2,compound=tk.LEFT,font=("TkDefaultFont", font_size))
password_l.image=render_load2
self.inst = ttk.Entry(self,width=20)
self.username = ttk.Entry(self)
self.password = ttk.Entry(self,show="*")
self.save_button = ttk.Button(self, text="Save",image=save_img,compound=tk.LEFT,command=self.save_teacher)
self.save_button.render=save_img
regis.grid(row=0, column=0,columnspan=2,pady=20)
inst_l.grid(row=1, column=0,sticky=tk.W)
username_l.grid(row=2, column=0,sticky=tk.W)
password_l.grid(row=3, column=0,sticky=tk.W)
self.inst.grid(row=1, column=1,ipadx=20,padx=10)
self.username.grid(row=2, column=1,ipadx=20,padx=10)
self.password.grid(row=3, column=1,ipadx=20,padx=10)
self.save_button.grid(row=4, column=0)
def save_teacher(self):
"""Function to save teacher details"""
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
if self.username.get() == "" or self.password.get()=="":
tk.messagebox.showerror("Error!","Fill username and password!")
else:
try:
c.execute("""
CREATE TABLE IF NOT EXISTS teacher
( institute VARCHAR(40) NOT NULL ,
username VARCHAR(20) NOT NULL ,
password VARCHAR(20) NOT NULL ,
PRIMARY KEY (username)) ENGINE = InnoDB;""")
c.execute("INSERT INTO teacher VALUES(%s,%s,%s)",(self.inst.get(),self.username.get(),self.password.get()))
tk.messagebox.showinfo("Success!","Record Successfully inserted!")
conn.commit()
c.close()
conn.close()
except:
tk.messagebox.showwarning("Warning!","Username already taken!")
c.close()
conn.close()
class Teacher_login(tk.Frame):
"""Frame for teacher login window"""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
usr_img=Image.open('images/user (2).png')
pass_img=Image.open('images/key (1).png')
banner_img=Image.open('images/login.png')
banner_img=banner_img.resize((300, 120), Image.ANTIALIAS)
usr_img_ren=ImageTk.PhotoImage(usr_img)
pas_img_ren=ImageTk.PhotoImage(pass_img)
banner_img_ren=ImageTk.PhotoImage(banner_img)
banner=ttk.Label(self,image=banner_img_ren)
banner.grid(row=0,column=0,columnspan=2)
banner.render=banner_img_ren
usrlt=ttk.Label(self,text="Username",image=usr_img_ren,compound=tk.LEFT,font=("TkDefaultFont", 14))
usrlt.grid(row=1,column=0)
usrlt.render=usr_img_ren
passlt=ttk.Label(self,text="Password",image=pas_img_ren,compound=tk.LEFT,font=("TkDefaultFont",14))
passlt.grid(row=2,column=0)
passlt.render=pas_img_ren
self.usrl=ttk.Entry(self)
self.passl=ttk.Entry(self,show="*")
self.usrl.grid(row=1,column=1)
self.passl.grid(row=2,column=1)
class Student_Edit_Ask(tk.Frame):
"""Frame to ask for roll no to edit student details and fees"""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
bannerimg=Image.open('images/undraw_Checklist__re_2w7v.png')
bannerimg = bannerimg.resize((360, 300), Image.ANTIALIAS)
bannerimgr=ImageTk.PhotoImage(bannerimg)
bannerl=ttk.Label(self,image=bannerimgr)
bannerl.grid(row=0,column=0,columnspan=2)
bannerl.render=bannerimgr
rolledit=ttk.Label(self,text="Enter Roll No. for Editing",font=("TkDefaultFont", 18))
rolledit.grid(row=1,column=0,columnspan=2)
roll=ttk.Label(self,text="Roll No",font=("TkDefaultFont", 14))
self.rolle=ttk.Entry(self)
roll.grid(row=2,column=0,pady=20)
self.rolle.grid(row=2,column=1,ipadx=40,pady=20)
class Student_Registeration_Image(tk.Frame):
""" Frame that contains Bokks Image In student registration window """
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
class Student_Registeration_Image_Main(tk.Frame):
""" Main Frame that contains Student Registration Frame and Student Registration Main Frame """
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
class Student_Registeration(tk.Frame):
"""Frame for student registeration window"""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
font_size=13
#image for labels start
roll_img=Image.open('images/ID-2-icon.png')
render_roll_img=ImageTk.PhotoImage(roll_img)
name_img=Image.open('images/man-icon.png')
render_name=ImageTk.PhotoImage(name_img)
class_img=Image.open('images/Science-Class-icon.png')
render_class=ImageTk.PhotoImage(class_img)
section_img=Image.open('images/Science-Classroom-icon.png')
render_section=ImageTk.PhotoImage(section_img)
school_img=Image.open('images/school-bus-icon.png')
render_school=ImageTk.PhotoImage(school_img)
address_img=Image.open('images/42496-school-icon (1).png')
render_address=ImageTk.PhotoImage(address_img)
father_img=Image.open('images/Office-Customer.png')
render_father=ImageTk.PhotoImage(father_img)
father_no_img=Image.open('images/phone-icon.png')
render_father_no=ImageTk.PhotoImage(father_no_img)
mobile_img=Image.open('images/WhatsApp-icon.png')
render_mobile=ImageTk.PhotoImage(mobile_img)
doj_img=Image.open('images/Calendar-icon.png')
render_doj=ImageTk.PhotoImage(doj_img)
reg_img=Image.open('images/regis1.png')
reg_img = reg_img.resize((340, 140), Image.ANTIALIAS)
render_reg=ImageTk.PhotoImage(reg_img)
button_img=Image.open('images/save_i.jpg')
button_img = button_img.resize((45, 25), Image.ANTIALIAS)
render_button=ImageTk.PhotoImage(button_img)
#image for labels end
#registration image
reg_l= ttk.Label(self,image=render_reg)
reg_l.image=render_reg
reg_l.grid(row=0,column=0,columnspan=2)
# student registration labels
roll_l= ttk.Label(self,text="Roll No",image=render_roll_img,compound=tk.LEFT,font=("TkDefaultFont", font_size))
roll_l.image=render_roll_img
name_l= ttk.Label(self,text="Name *",image=render_name,compound=tk.LEFT,font=("TkDefaultFont", font_size))
name_l.image=render_name
class_l= ttk.Label(self,text="Class *",image=render_class,compound=tk.LEFT,font=("TkDefaultFont", font_size))
class_l.image=render_class
section_l= ttk.Label(self,text="Section",image=render_section,compound=tk.LEFT,font=("TkDefaultFont", font_size))
section_l.image=render_section
school_l= ttk.Label(self,text="School *",image=render_school,compound=tk.LEFT,font=("TkDefaultFont", font_size))
school_l.image=render_school
address_l= ttk.Label(self,text="Address *",image=render_address,compound=tk.LEFT,font=("TkDefaultFont", font_size))
address_l.image=render_address
father_l= ttk.Label(self,text="Father",image=render_father,compound=tk.LEFT,font=("TkDefaultFont", font_size))
father_l.image=render_father
father_no_l= ttk.Label(self,text="Father's No. *",image=render_father_no,compound=tk.LEFT,font=("TkDefaultFont", font_size))
father_no_l.image=render_father_no
mobile_l= ttk.Label(self,text="Mobile *",image=render_mobile,compound=tk.LEFT,font=("TkDefaultFont", font_size))
mobile_l.image=render_mobile
doj_l= ttk.Label(self,text="DOJ *",image=render_doj,compound=tk.LEFT,font=("TkDefaultFont", font_size))
doj_l.image=render_doj
roll_l.grid(row=1,column=0,padx=10)
name_l.grid(row=2,column=0,padx=10)
class_l.grid(row=3,column=0,padx=10)
section_l.grid(row=4,column=0,padx=10)
school_l.grid(row=5,column=0,padx=10)
address_l.grid(row=6,column=0,padx=10)
father_l.grid(row=7,column=0,padx=10)
father_no_l.grid(row=8,column=0,padx=10)
mobile_l.grid(row=9,column=0,padx=10)
doj_l.grid(row=10,column=0,padx=10)
#student registration entry widgets
self.roll_e= ttk.Label(self,text="Auto Assigned",font=("TkDefaultFont", font_size))
self.name_e= ttk.Entry(self)
self.class_e= ttk.Entry(self)
self.section_e= ttk.Entry(self)
self.school_e= ttk.Entry(self)
self.address_e= ttk.Entry(self)
self.father_e= ttk.Entry(self)
self.father_no_e= ttk.Entry(self)
self.mobile_e= ttk.Entry(self)
self.doj_e= ttk.Entry(self)
self.roll_e.grid(row=1,column=1,ipadx=30,padx=10)
self.name_e.grid(row=2,column=1,ipadx=30,padx=10)
self.class_e.grid(row=3,column=1,ipadx=30,padx=10)
self.section_e.grid(row=4,column=1,ipadx=30,padx=10)
self.school_e.grid(row=5,column=1,ipadx=30,padx=10)
self.address_e.grid(row=6,column=1,ipadx=30,padx=10)
self.father_e.grid(row=7,column=1,ipadx=30,padx=10)
self.father_no_e.grid(row=8,column=1,ipadx=30,padx=10)
self.mobile_e.grid(row=9,column=1,ipadx=30,padx=10)
self.doj_e.grid(row=10,column=1,ipadx=30,padx=10)
# button to register the students
self.save=ttk.Button(self,text="Save",image=render_button,compound=tk.LEFT,command=self.save_student)
self.save.image=render_button
self.save.grid(row=11,column=0,columnspan=2)
def clear_student_fields(self):
self.name_e.delete(0,tk.END)
self.class_e.delete(0,tk.END)
self.section_e.delete(0,tk.END)
self.school_e.delete(0,tk.END)
self.address_e.delete(0,tk.END)
self.father_e.delete(0,tk.END)
self.father_no_e.delete(0,tk.END)
self.mobile_e.delete(0,tk.END)
self.doj_e.delete(0,tk.END)
def save_student(self):
"""Function to save student"""
datever=Date_Verify()
if self.name_e.get()=="" or self.class_e.get()=="" or self.school_e.get()=="" or self.address_e.get()=="" or self.father_no_e.get()=="" or self.mobile_e.get()=="" or self.doj_e.get()=="":
tk.messagebox.showerror("Error!","It is compulsory to fill mandatory details!")
elif self.mobile_e.get().isalpha() and self.father_no_e.get().isalpha():
tk.messagebox.showerror("Error!","Check Phone Number fields!")
elif not datever.isValid(self.doj_e.get()):
tk.messagebox.showerror("Error!","Date format(yyyy-mm-dd)")
else:
try:
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("INSERT INTO student(name,class,section,school,address,father,father_no,mobile,doj) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)",(self.name_e.get(),self.class_e.get(),self.section_e.get(),self.school_e.get(),self.address_e.get(),self.father_e.get(),self.father_no_e.get(),self.mobile_e.get(),self.doj_e.get()))
tk.messagebox.showinfo("Success!","Record Successfully inserted!")
conn.commit()
c.close()
conn.close()
self.clear_student_fields()
except Exception as e:
tk.messagebox.showerror("Error!",e)
class Student_Edit(Student_Registeration):
"""Frame to open student edit window inherited from student registeration"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
#c.execute("INSERT INTO teacher VALUES('"+self.inst.get()+"','"+self.username.get()+"','"+self.password.get()+"')")
c.execute("SELECT * FROM student WHERE rollno={}".format(asas.rolle.get()))
rec=c.fetchall()
rollu=rec[0][0]
nameu=rec[0][1]
classu=rec[0][2]
sectionu=rec[0][3]
schoolu=rec[0][4]
addressu=rec[0][5]
fatheru=rec[0][6]
fathernou=rec[0][7]
mobileu=rec[0][8]
doju=rec[0][9]
self.roll_e.configure(text=rollu)
self.name_e.insert(0,nameu)
self.class_e.insert(0,classu)
self.section_e.insert(0,sectionu)
self.school_e.insert(0,schoolu)
self.address_e.insert(0,addressu)
self.father_e.insert(0,fatheru)
self.father_no_e.insert(0,fathernou)
self.mobile_e.insert(0,mobileu)
self.doj_e.insert(0,doju)
c.close()
conn.close()
def save_student(self):
"""Overide save_student method to update student details"""
if self.name_e.get()=="" or self.class_e.get()=="" or self.school_e.get()=="" or self.address_e.get()=="" or self.father_no_e.get()=="" or self.mobile_e.get()=="" or self.doj_e.get()=="":
tk.messagebox.showerror("Error!","It is compulsory to fill mandatory details!")
elif self.mobile_e.get().isalpha() and self.father_no_e.get().isalpha():
tk.messagebox.showerror("Error!","Check Phone Number fields!")
else:
try:
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("UPDATE student SET name=%s,class=%s,section=%s,school=%s,address=%s,father=%s,father_no=%s,mobile=%s,doj=%s WHERE rollno=%s",(self.name_e.get(),self.class_e.get(),self.section_e.get(),self.school_e.get(),self.address_e.get(),self.father_e.get(),self.father_no_e.get(),self.mobile_e.get(),self.doj_e.get(),asas.rolle.get()))
#c.execute("UPDATE {} SET name=self.name_e.get() class=self.class_e.get() ,section=self.section_e.get(),school=self.school_e.get(), address=self.address_e.get(), father=self.father_e.get(),father_no=self.father_no_e.get(),mobile=self.mobile_e.get(),doj=self.doj_e.get() WHERE rollno='"+asas.rolle.get()+"' ")
tk.messagebox.showinfo("Success!","Record Successfully Updated!")
conn.commit()
c.close()
conn.close()
except Exception as e:
tk.messagebox.showerror("Error!",e)
#####################################################################################################
## Fees Window Frames ##
feesin=None
class Fees_Main_Frame(tk.Frame):
"""Main Fees Frame to hold Fees frame,Fees Info Frame, Del_Fees Frame """
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class Date_Verify:
"""Common class to verify date"""
def isValid(self,date1):
"""Funtion to return True if date1 is valid"""
try:
if datetime.datetime.strptime(date1,'%Y-%m-%d'):
return True
else:
return False
except ValueError:
return False
class Fees(tk.Frame):
"""Frame to show basic details of student for submitting fees"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
dateimg=Image.open('images/Calendar-icon.png')
rollimg=Image.open('images/ID-2-icon.png')
feesimg=Image.open('images/money-bag.png')
nameim=Image.open('images/id-card.png')
classim=Image.open('images/online-class.png')
secim=Image.open('images/videoconference.png')
addimg=Image.open('images/add.png')
addimgr=ImageTk.PhotoImage(addimg)
feesimgr=ImageTk.PhotoImage(feesimg)
dateimgr=ImageTk.PhotoImage(dateimg)
rollimgr=ImageTk.PhotoImage(rollimg)
nameimg=ImageTk.PhotoImage(nameim)
classimg=ImageTk.PhotoImage(classim)
secimg=ImageTk.PhotoImage(secim)
main_label=tk.Label(self,text="Add Fees",font=("TkDefaultFont", 20))
main_label.grid(row=0,column=0,columnspan=2)
rollno=ttk.Label(self,text="Roll No",image=rollimgr,compound=tk.LEFT,font=("TkDefaultFont", 12))
rollno.render=rollimgr
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT name,class,section FROM student WHERE rollno={}".format(asas.rolle.get()))
details=c.fetchall()
c.close()
conn.close()
name_fees=ttk.Label(self,text="Name",font=("TkDefaultFont",12),image=nameimg,compound=tk.LEFT)
name_fees.render=nameimg
name_fees.grid(row=2,column=0)
name_fees1=ttk.Label(self,text=details[0][0],font=("TkDefaultFont",12))
name_fees1.grid(row=2,column=1)
class_fees=ttk.Label(self,text="Class",font=("TkDefaultFont",12),image=classimg,compound=tk.LEFT)
class_fees.render=classimg
class_fees.grid(row=3,column=0)
class_fees1=ttk.Label(self,text=details[0][1],font=("TkDefaultFont",12))
class_fees1.grid(row=3,column=1)
section_fees=ttk.Label(self,text="Section",font=("TkDefaultFont",12),image=secimg,compound=tk.LEFT)
section_fees.render=secimg
section_fees.grid(row=4,column=0)
section_fees1=ttk.Label(self,text=details[0][2],font=("TkDefaultFont",12))
section_fees1.grid(row=4,column=1)
rollnol=ttk.Label(self,text=asas.rolle.get(),font=("TkDefaultFont", 12))
amt=ttk.Label(self,text="Amount",image=feesimgr,compound=tk.LEFT,font=("TkDefaultFont",12))
amt.render=feesimgr
dos=ttk.Label(self,text="Date",image=dateimgr,compound=tk.LEFT,font=("TkDefaultFont", 12))
dos.render=dateimgr
fsave=ttk.Button(self,text="Add",image=addimgr,compound=tk.LEFT,command=self.save_fees)
fsave.render=addimgr
fsave.grid(row=7,column=0,columnspan=2)
self.amt_e=ttk.Entry(self)
self.dos_e=ttk.Entry(self)
curdate=datetime.datetime.now()
curdate1=curdate.date()
self.dos_e.insert(0,curdate1)
rollno.grid(row=1,column=0)
rollnol.grid(row=1,column=1)
amt.grid(row=5,column=0)
self.amt_e.grid(row=5,column=1,padx=10)
dos.grid(row=6,column=0,ipadx=10)
self.dos_e.grid(row=6,column=1,padx=10)
def save_fees(self):
"""Function to save fees"""
date_ver=Date_Verify()
if self.amt_e.get() =="" or self.dos_e.get() == "":
tk.messagebox.showerror("Error!","Fill Amount and Date!")
elif self.amt_e.get().isalpha():
tk.messagebox.showerror("Error!","Fill Correct Amount!")
elif not date_ver.isValid(self.dos_e.get()):
tk.messagebox.showerror("Error!","Correct Date Format(YYYY-MM-DD)")
elif self.amt_e.get().isdigit() and date_ver.isValid(self.dos_e.get()):
try:
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("INSERT INTO fees(rollno,amount,date) VALUES(%s,%s,%s)",(asas.rolle.get(),self.amt_e.get(),self.dos_e.get()))
feesin.append() #temporarily update fees slips
tk.messagebox.showinfo("Success!","Fees Successfully inserted!")
conn.commit()
c.close()
self.amt_e.delete(0,tk.END)
except Exception as e:
tk.messagebox.showerro("Error!",e)
else:
tk.messagebox.showerror("Error!","Check Amount!")
class Del_Fees(tk.Frame):
"""Frame to show Del Fees widgets"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
idimg=Image.open('images/driver-license.png')
idimgr=ImageTk.PhotoImage(idimg)
delimg=Image.open('images/delete.png')
delimgr=ImageTk.PhotoImage(delimg)
dell=ttk.Label(self,text="Delete Fees Slip",font=("TkDefaultFont", 20))
dell.grid(row=1,column=0,columnspan=3)
feeid=ttk.Label(self,text="Fees Id",image=idimgr,compound=tk.LEFT)
feeid.render=idimgr
feeid.grid(row=2,column=0)
self.feeid_e=ttk.Entry(self)
self.feeid_e.grid(row=2,column=1)
del_but=ttk.Button(self,text="Delete",image=delimgr,compound=tk.LEFT,command=self.del_fee)
del_but.render=delimgr
del_but.grid(row=3,column=0,columnspan=2)
def getDelfee(self):
"""Function to get fees related to fees id"""
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT amount FROM fees WHERE fees_id={}".format(self.feeid_e.get()))
f=c.fetchone()
c.close()
conn.close()
return f[0]
def getdeldata(self):
"""Function to get total fees submitted by student"""
try:
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT CAST(SUM(amount) AS SIGNED) FROM fees WHERE rollno={}".format(asas.rolle.get()))
rec=c.fetchone()
total=rec[0]
return total
c.close()
conn.close()
except Exception as e:
tk.messagebox.showerro("Error!",e)
def del_fee(self):
"""Function to delete fees by using its fees id"""
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT rollno FROM fees WHERE fees_id={}".format(self.feeid_e.get()))
check_feeid=c.fetchall()
if check_feeid:
del_amt=self.getDelfee()
prev_data=self.getdeldata()
try:
c.execute("DELETE FROM fees WHERE fees_id={}".format(self.feeid_e.get()))
conn.commit()
total_amt.configure(text=prev_data-int(del_amt))
tk.messagebox.showinfo("Success!","Fees Successfully deleted!")
self.feeid_e.delete(0,tk.END)
c.close()
conn.close()
except Exception as e:
tk.messagebox.showerro("Error!",e)
else:
tk.messagebox.showerror("Error!","Invalid Id!")
feesw=None
class Fees_Info(tk.Frame):
"""Frame to show fees Slips in fees window"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def show_fees(self):
"""function to show fees slips"""
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT * FROM fees WHERE rollno={}".format(asas.rolle.get()))
rec=c.fetchall()
self.r=3
for a in rec:
self.c=0
feesidi=ttk.Label(self,text=a[0],font=("TkDefaultFont",11))
feesidi.grid(row=self.r,column=self.c,padx=10)
self.c+=1
amti=ttk.Label(self,text=a[2],font=("TkDefaultFont", 11))
amti.grid(row=self.r,column=self.c,padx=55)
self.c+=1
dateii=ttk.Label(self,text=a[3],font=("TkDefaultFont",11))
dateii.grid(row=self.r,column=self.c)
self.r+=1
def append(self):
"""Function to temporarily add fees slips"""
if (feesw.amt_e.get() and feesw.dos_e.get()) !="":
def fees_up():
conn=mysql.connect(host='localhost',database='tuition',user='app_admin',password='app_admin@12345')
c=conn.cursor()
c.execute("SELECT CAST(SUM(amount) AS SIGNED) FROM fees WHERE rollno={}".format(asas.rolle.get()))
rec=c.fetchone()
total=rec[0]
return total
c.close()
conn.close()
self.c=0
feesidi=ttk.Label(self,text='AA',font=("TkDefaultFont",11))
feesidi.grid(row=self.r,column=self.c,padx=10)
self.c+=1
amti=ttk.Label(self,text=feesw.amt_e.get(),font=("TkDefaultFont", 11))
amti.grid(row=self.r,column=self.c,padx=45)
self.c+=1
dateii=ttk.Label(self,text=feesw.dos_e.get(),font=("TkDefaultFont",11))
dateii.grid(row=self.r,column=self.c)
self.r+=1
#update total fees paid amount temporarily
data11=fees_up()
if data11==None:
data11=0
total_amt.configure(text=(data11+int(feesw.amt_e.get())))
#####################################################################################################
## Fees Window Frames ##
month = 0
days = 0
class Due_Fees(tk.Frame):
"""fRame to show window with students that have pending fees"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def info(self):
"""Function to display students with pending fees"""
conn = mysql.connect(
host='localhost', database='tuition', user='app_admin', password='app_admin@12345')
c = conn.cursor()
c.execute("SELECT rollno,name,doj,class,section FROM student")
rec1 = c.fetchall()
r = 2
roll2 = ttk.Label(self,text="Roll No", font=("TkDefaultFont",12,"bold"))
roll2.grid(row=1, column=0)
name3 = ttk.Label(self,text="Name", font=("TkDefaultFont",12,"bold"))
name3.grid(row=1, column=1)
class2 = ttk.Label(self,text="Class", font=("TkDefaultFont", 12,"bold"))
class2.grid(row=1, column=2)
section2= ttk.Label(self,text="Section", font=("TkDefaultFont",12,"bold"))
section2.grid(row=1, column=3)
doj2= ttk.Label(self,text="DOJ", font=("TkDefaultFont",12,"bold"))
doj2.grid(row=1, column=4)
for a in rec1:
c = 0
if a[2] is not None:
y, m, d = str(a[2]).split('-')
if self.isdue(y, m, d, a[0]):
due_date = month, "month", days, "days"
roll1 = ttk.Label(
self, text=a[0], font=("TkDefaultFont", 11))
roll1.grid(row=r, column=c,padx=10)
c += 1
name1 = ttk.Label(
self, text=a[1], font=("TkDefaultFont", 11))
name1.grid(row=r, column=c,padx=30)
c += 1
class11 = ttk.Label(
self, text=a[3], font=("TkDefaultFont", 11))
class11.grid(row=r, column=c,padx=15)
c += 1
section1 = ttk.Label(
self, text=a[4], font=("TkDefaultFont", 11))
section1.grid(row=r, column=c,padx=15)
c += 1
month1 = ttk.Label(self, text=due_date,
font=("TkDefaultFont", 11))
month1.grid(row=r, column=c,padx=22)
r += 1
def isdue(self, y, m, d, roll):
self.y = int(y)
self.m = int(m)
self.d = int(d)
self.roll = roll
import datetime
conn = mysql.connect(
host='localhost', database='tuition', user='app_admin', password='app_admin@12345')
d = conn.cursor()
d.execute("SELECT rollno,date FROM fees WHERE rollno={}".format(self.roll))
rec2 = d.fetchall()
date1 = datetime.datetime.now()
curdate = date1 #current date
jdate = datetime.datetime(self.y, self.m, self.d) #date of joining of student
difference = (curdate-jdate) #difference between their dates
data = difference.days #total number of days
data1=difference.days
global month,days
month = 0
days = 0
datedif = ((difference.days//30)-len(rec2))
data1=(data1-(30*len(rec2)))
while data1 > 0:
if data1 >= 30:
data1 -= 30
month += 1
else:
days = data1
break
if datedif >= 0:
return True
else:
return False
class Student_Edit_Main(tk.Frame):
"""Empty Frame to Hold Student Edit frame and Student Edit Image Frame"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class Student_Edit_Image(tk.Frame):
"""Frame for placing banner in Student Edit Main Frame"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
sri_canvas=None
sri=None
class Quotes_Animation:
"""Class for animation of quotes"""
def __init__(self):
self.y_cord=180
self.x_cord=250
self.change_time=3000
self.q1='Change is the end result of all true learning. – Leo Buscaglia'
self.q2='An investment in knowledge pays the best interest. – Benjamin Franklin'
self.q3='Live as if you were to die tomorrow. Learn as if you were to live forever. ― Mahatma Gandhi'
self.q4='The learning process continues until the day you die. – Kirk Douglas'
self.q5='Education is not preparation for life; education is life itself. – John Dewey'
self.q6='They know enough who know how to learn. – Henry Adams'
self.q7='All power is within you; You can do anything and everything. - Swami Vivekananda'
self.q8='Books are the means by which we build bridges between cultures. - Sarvepalli Radhakrishnan'
def chnge(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q2,justify=tk.CENTER,font=('Purisa',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge1)
def chnge1(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q3,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge2)
def chnge2(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q4,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge3)
def chnge3(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q5,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge4)
def chnge4(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q6,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge5)
def chnge5(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q7,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge6)
def chnge6(self):
sri_canvas.delete('abc')
sri_canvas.create_text(self.x_cord,self.y_cord,text=self.q8,justify=tk.CENTER,font=('Arial',20),width=400,tags="abc",fill="red")
sri.after(self.change_time,self.chnge)
class PDF_gen:
"""Class to create pdf for individual students with their details and fees details"""
def __init(self):
pass
def get_total_amt(self,r):
conn = mysql.connect(host='localhost', database='tuition',user='app_admin', password='app_admin@12345')
c = conn.cursor()
c.execute('SELECT CAST(SUM(amount) AS SIGNED) FROM fees WHERE rollno={}'.format(r))
rec = c.fetchall()
return rec[0][0]
def generate_pdf(self,r,ins):
conn = mysql.connect(host='localhost', database='tuition',user='app_admin', password='app_admin@12345')
c = conn.cursor()
c.execute('SELECT * FROM student WHERE rollno={}'.format(r))
rec1 = c.fetchall()
pdf = FPDF(orientation='P')
pdf.add_page()
pdf.set_font('Arial', "B", 30)
pdf.set_text_color(156,33,33)
pdf.cell(180, 10,ins, align="C")
pdf.ln(30)
pdf.line(10, 30, 200,30)
pdf.set_font('Arial', "B", 15)
line_space=14
x1=30
x2=10
pdf.set_text_color(0,0,0)
pdf.cell(x1, 10,"Roll No", align="L")
pdf.cell(x2+60, 10,str(rec1[0][0]), align="L")
pdf.cell(x1, 10,"Address", align="L")
pdf.cell(x2, 10,str(rec1[0][5]), align="L")
pdf.ln(line_space)
pdf.cell(x1, 10,"Name", align="L")
pdf.cell(x2+60, 10,str(rec1[0][1]), align="L")
pdf.cell(x1, 10,"Father", align="L")
pdf.cell(x2, 10,str(rec1[0][6]), align="L")
pdf.ln(line_space)
pdf.cell(x1, 10,"Class", align="L")
pdf.cell(x2+60, 10,str(rec1[0][2]), align="L")
pdf.cell(x1, 10,"Phone", align="L")
pdf.cell(x2, 10,str(rec1[0][7]), align="L")
pdf.ln(line_space)
pdf.cell(x1, 10,"Section", align="L")
pdf.cell(x2+60, 10,str(rec1[0][3]), align="L")
pdf.cell(x1, 10,"DOJ", align="L")
pdf.cell(x2, 10,str(rec1[0][9]), align="L")
pdf.ln(line_space)
pdf.cell(x1, 10,"School", align="L")
pdf.cell(x2, 10,str(rec1[0][4]), align="L")
pdf.line(10, 110, 200, 110)
c.close()
conn.close()
pdf.ln(line_space)
pdf.set_font('Arial', "B", 20)
pdf.set_text_color(3,115,252)
pdf.cell(180, 40,"Fees Details", align="C")