-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.PY
More file actions
3893 lines (3307 loc) · 164 KB
/
Copy pathmain.PY
File metadata and controls
3893 lines (3307 loc) · 164 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
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtWidgets import QApplication, QWidget,QShortcut,QFrame, QDesktopWidget, QTableWidget, QTableWidgetItem, QGridLayout,QTableWidget, QDialog, QMainWindow, QFileDialog, QMessageBox
from PyQt5.QtGui import QPixmap, QCloseEvent,QKeySequence,QBrush,QColor
import sys
import sqlite3
import xlsxwriter
import pandas as pd
import os
from datetime import date
import time
from datetime import timedelta
import datetime
import re
import smtplib
import ssl
from email.mime.text import MIMEText
import pygame
import requests
from plyer import notification
import random
from cryptography.fernet import Fernet
import shutil
from PyQt5.QtCore import Qt,QDate
import itertools
def load():
global app
global sign_up_win
global login_win
global main_win
global today
global login_status
global PublicKey
global PrivateKey
global key
global fernet
key=b'oc7b6PWUvDNEWcdSaauMYDo-aBq0aLbKX5_7Kqk-eTQ='
fernet=Fernet(key)
app=QtWidgets.QApplication(sys.argv)
login_win = uic.loadUi("application_ui/ui/login.ui")
sign_up_win = uic.loadUi("application_ui/ui/sign_up.ui")
main_win = uic.loadUi("application_ui/ui/main.ui")
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
list_of_tables=c.execute(""" SELECT name FROM sqlite_master WHERE type='table' AND name='login_details'; """).fetchall()
if list_of_tables==[]:
login_details_table = """CREATE TABLE login_details (
user_id INTEGER(1) PRIMARY KEY,
user_name VARCHAR(64) NOT NULL,
email VARCHAR(64) NOT NULL,
password_1 VARCHAR(32) NOT NULL,
password_2 VARCHAR(32) NOT NULL,
themes VARCHAR(1) NOT NULL,
sound VARCHAR(1) NOT NULL,
student_login VARCHAR(1) NOT NULL,
backup VARCHAR(1) NOT NULL,
login_status VARCHAR(1) NOT NULL
);"""
c.execute(login_details_table)
try:
book_details_table = """CREATE TABLE book_details (
book_id INTEGER PRIMARY KEY AUTOINCREMENT,
book_title VARCHAR(256) NOT NULL,
author VARCHAR(256) NOT NULL,
isbn VARCHAR(16) NOT NULL,
available INTEGER(1024) NOT NULL,
quantity INTEGER(1024) NOT NULL,
publisher VARCHAR(256),
price VARCHAR(64),
publication_date VARCHAR(16),
tags VARCHAR(256),
description VARCHAR(2048),
total_issued INTEGER(1024)
);"""
c.execute(book_details_table)
course_details_table = """CREATE TABLE course_details (
course_id INTEGER PRIMARY KEY AUTOINCREMENT,
course_name VARCHAR(64) NOT NULL,
total_year INTEGER(1) NOT NULL,
description VARCHAR(2048)
);"""
c.execute(course_details_table)
batch_details_table = """CREATE TABLE batch_details (
batch_id INTEGER PRIMARY KEY AUTOINCREMENT,
start_year VARCHAR(4) NOT NULL,
end_year VARCHAR(4) NOT NULL,
course_id INTEGER,
description VARCHAR(2048),
FOREIGN KEY (course_id) REFERENCES course_details(course_id)
);"""
c.execute(batch_details_table)
student_details_table ="""CREATE TABLE student_details(
roll_number VARCHAR PRIMARY KEY,
register_number VARCHAR(1024),
name VARCHAR(128),
date_of_birth VARCHAR(16),
father_name VARCHAR(128),
mother_name VARCHAR(128),
phone VARCHAR(10),
email VARCHAR(128),
address VARCHAR(256),
aadhar_number VARCHAR(15),
religion VARCHAR(32),
community VARCHAR(32),
caste VARCHAR(256),
anual_income VARCHAR(16),
blood_group VARCHAR(8),
father_occupation VARCHAR(256),
mother_occupation VARCHAR(256),
area_type VARCHAR(256),
sslc_mark VARCHAR(8),
sslc_passing_year VARCHAR(32),
sslc_school_name VARCHAR(256),
sslc_medium VARCHAR(32),
sslc_school_type VARCHAR(64),
hsc_mark VARCHAR(8),
hsc_passing_year VARCHAR(32),
hsc_school_name VARCHAR(256),
hsc_medium VARCHAR(32),
hsc_school_type VARCHAR(64),
admission_date VARCHAR(16),
description VARCHAR(2048),
batch_id INTEGER,
course_id INTEGER,
FOREIGN KEY (course_id) REFERENCES course_details(course_id),
FOREIGN KEY (batch_id) REFERENCES batch_details(batch_id)
);"""
c.execute(student_details_table)
except Exception as e:
print("here")
print(e)
try:
book_quantity_details_table = """CREATE TABLE book_quantity_details (
book_quantity_id INTEGER(1024) PRIMARY KEY,
book_id INTEGER(1024),
inserted_on VARCHAR(16),
description VARCHAR(2048),
FOREIGN KEY (book_id) REFERENCES book_details(book_id)
);"""
c.execute(book_quantity_details_table)
issued_book_details_table = """CREATE TABLE issued_book_details (
issued_book_id VARCHAR(1024)PRIMARY KEY,
roll_number VARCHAR(1024),
book_quantity_id VARCHAR(1024),
issue_date VARCHAR(12),
last_date VARCHAR(12),
book_id VARCHAR(1024),
course_id VARCHAR(1024),
batch_id VARCHAR(1024),
FOREIGN KEY (roll_number) REFERENCES student_details(roll_number),
FOREIGN KEY (book_quantity_id) REFERENCES book_quantity_details(book_quantity_id),
FOREIGN KEY (book_id) REFERENCES book_details(book_id)
);"""
c.execute(issued_book_details_table)
book_history_table = """CREATE TABLE book_history (
issued_book_id VARCHAR(1024),
roll_number VARCHAR(1024),
book_quantity_id VARCHAR(1024),
issue_date VARCHAR(12),
last_date VARCHAR(12),
given_date VARCHAR(12),
book_id VARCHAR(1024),
course_id VARCHAR(1024),
batch_id VARCHAR(1024),
FOREIGN KEY (roll_number) REFERENCES student_details(roll_number),
FOREIGN KEY (book_quantity_id) REFERENCES book_quantity_details(book_quantity_id)
);"""
c.execute(book_history_table)
course_delete_trigger='''
CREATE TRIGGER IF NOT EXISTS course_delete_trigger
BEFORE DELETE ON course_details
BEGIN
DELETE FROM batch_details WHERE course_id = old.course_id ;
DELETE FROM student_details WHERE course_id = old.course_id ;
DELETE FROM book_history WHERE course_id = old.course_id ;
DELETE FROM issued_book_details WHERE course_id = old.course_id ;
END;
'''
c.execute(course_delete_trigger)#$%^&*
batch_delete_trigger='''
CREATE TRIGGER IF NOT EXISTS batch_delete_trigger
BEFORE DELETE ON batch_details
BEGIN
DELETE FROM student_details WHERE batch_id = old.batch_id ;
DELETE FROM book_history WHERE batch_id = old.batch_id ;
DELETE FROM issued_book_details WHERE batch_id = old.batch_id ;
END;
'''
c.execute(batch_delete_trigger)#$%^&*
student_delete_trigger='''
CREATE TRIGGER IF NOT EXISTS student_delete_trigger
BEFORE DELETE ON student_details
BEGIN
DELETE FROM book_history WHERE roll_number = old.roll_number ;
DELETE FROM issued_book_details WHERE roll_number = old.roll_number ;
END;
'''
c.execute(student_delete_trigger)#$%^&*
book_delete_trigger='''
CREATE TRIGGER IF NOT EXISTS book_delete_trigger
BEFORE DELETE ON book_details
BEGIN
DELETE FROM book_quantity_details WHERE book_id = old.book_id ;
DELETE FROM issued_book_details WHERE book_id = old.book_id ;
DELETE FROM book_history WHERE book_id = old.book_id ;
END;
'''
c.execute(book_delete_trigger)#$%^&*
book_qty_delete_trigger='''
CREATE TRIGGER IF NOT EXISTS book_qty_delete_trigger
BEFORE DELETE ON book_details
BEGIN
DELETE FROM issued_book_details WHERE book_id = old.book_id ;
DELETE FROM book_history WHERE book_id = old.book_id ;
END;
'''
c.execute(book_qty_delete_trigger)#$%^&*
except Exception as e:
print("s")
print(e)
conn.commit()
conn.close()
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT login_status FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
if a is None:
sign_up_ui()
exist_life()
else:
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
login_status="3"
query = ('''UPDATE login_details SET login_status = "{}" WHERE user_id=1;'''.format(login_status))
c.execute(query)
conn.commit()
conn.close()
back_up(0)
login_ui()
exist_life()
def refresh(login_status):
try:
if login_status=="1" or login_status=="2":
close_all_window()
main_ui()
except Exception as e:
print(e)
def batch_name_to_id(batch_name):
try:
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
batch_name=batch_name.replace('-',' ')
batch_name=batch_name.split(' ')
start_year=batch_name[0]
end_year=batch_name[1]
query = ('''SELECT batch_id FROM batch_details WHERE start_year="{}" and end_year="{}";'''.format(start_year,end_year))
c.execute(query)
a = c.fetchone()
conn.close()
batch_id=a[0]
return batch_id
except Exception as e:
print(e)
def batch_id_to_name(batch_id):
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT start_year,end_year FROM batch_details WHERE batch_id="{}";'''.format(batch_id))
c.execute(query)
a = c.fetchone()
conn.close()
start_year=a[0]
end_year=a[1]
batch_name=str(start_year)+"-"+str(end_year)
return batch_name
def course_name_to_id(course_name):
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT course_id FROM course_details WHERE course_name="{}";'''.format(course_name))
c.execute(query)
a = c.fetchone()
conn.close()
course_id=a[0]
return course_id
def course_id_to_name(course_id):
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT course_name FROM course_details WHERE course_id="{}";'''.format(course_id))
c.execute(query)
a = c.fetchone()
conn.close()
course_name=a[0]
return course_name
def book_quantity_id_to_book_id(qty_id):
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT book_id FROM book_quantity_details WHERE book_quantity_id="{}";'''.format(qty_id))
c.execute(query)
a = c.fetchone()
conn.close()
book_id=a[0]
return book_id
def sound_1():
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT sound FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
data=a[0]
if data=='1':
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/click.wav")
sound.play()
def sound_2():
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT sound FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
data=a[0]
if data=='1':
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/error.wav")
sound.play()
def sound_3():
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT sound FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
data=a[0]
if data=='1':
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/success.mp3")
sound.play()
def sound_4():
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT sound FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
data=a[0]
if data=='1':
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/click_2.wav")
sound.play()
def sound_5():
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/click_2.wav")
sound.play()
def sound_6():
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/error.wav")
sound.play()
def sound_7():
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT sound FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
data=a[0]
if data=='1':
pygame.mixer.init()
sound = pygame.mixer.Sound("application_ui/music/exit.wav")
sound.play()
time.sleep(0.28)
def sign_up_ui():
#get user data and save it on ###ogin_details###
#set login column true in ###staff details###
try:
sound_5()
close_all_window()
qtRectangle=sign_up_win.frameGeometry()
centerPoint=QDesktopWidget().availableGeometry().center()
qtRectangle.moveCenter(centerPoint)
sign_up_win.move(qtRectangle.topLeft())
sign_up_win.show()
sign_up_win.next_btn.clicked.connect(sign_up_process)
except Exception as e:
print(e)
def sign_up_process():
user_name=sign_up_win.user_name.text()
email=sign_up_win.email.text()
password_1=sign_up_win.password_1.text()
password_2=sign_up_win.password_2.text()
if user_name=='':
sound_6()
sign_up_win.error_message.setText("Please enter the user name !")
return
if email=='':
sound_6()
sign_up_win.error_message.setText("Please enter the email !")
return
else:
regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
if not re.fullmatch(regex, email):
sound_6()
sign_up_win.error_message.setText("Please enter the valid email !")
return
if password_1=='':
sound_6()
sign_up_win.error_message.setText("Please enter the password 1 !")
return
else:
if not len(password_1)>=3:
sound_6()
sign_up_win.error_message.setText("Please enter the password 1 atleast in 3 character !")
return
if password_2=='':
sound_6()
sign_up_win.error_message.setText("Please enter the Password 2 !")
return
else:
if not len(password_2)>=3:
sound_6()
sign_up_win.error_message.setText("Please enter the password 2 atleast in 3 character !")
return
try:
themes="1"
sound="1"
student_login="1"
backup="1"
login_status="1"
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
c.execute("insert into login_details values(?,?,?,?,?,?,?,?,?,?)",(1,user_name,email,password_1,password_2,themes,sound,student_login,backup,login_status))
conn.commit()
conn.close()
login_status="1"
refresh(login_status)
except Exception as e:
print(e)
def login_ui():
#display the ***login UI***
#get user name and password
#if user name found check password, if password match, set login column true in ###staff details###
#else print ***user name or password was not matching***
sound_4()
close_all_window()
qtRectangle=login_win.frameGeometry()
centerPoint=QDesktopWidget().availableGeometry().center()
qtRectangle.moveCenter(centerPoint)
login_win.move(qtRectangle.topLeft())
login_win.show()
set_button_color_for_active_window()
login_win.progressBar.hide()
login_win.forgot_password.clicked.connect(forgot_password_ui)
login_win.login_btn.clicked.connect(login_process)
def login_process():
try:
if login_win.user_name.text()=='' or login_win.password.text()=='':
sound_2()
reply=QMessageBox.critical(login_win,"No input given","Please input the login details",QMessageBox.Ok)
return
conn = sqlite3.connect('application_data/databases/clms_database.db')#database connect
c = conn.cursor()
query = '''SELECT * FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
user_name=a[1]
email=a[2]
password_1=a[3]
password_2=a[4]
login_status=a[9]
if login_win.password.text()=='student':
main_win.issue_book_btn.setEnabled(False)
main_win.return_book_btn.setEnabled(False)
main_win.issued_book_details_btn.setEnabled(False)
main_win.manage_students_btn.setEnabled(False)
main_win.manage_book_quantity_btn.setEnabled(False)
main_win.settings_btn.setEnabled(False)
main_win.batch_and_course_btn.setEnabled(False)
main_win.role_number_4.setText(login_win.user_name.text())
main_win.role_number_4.setEnabled(False)
main_win.add_book_pop_up_btn.setEnabled(False)
main_win.delete_book_btn.setEnabled(False)
main_win.manage_books_save_btn.setEnabled(False)
login_status="2"
else:
if login_win.user_name.text()==user_name:
if login_win.password.text()==password_1:
login_status="1"
elif login_win.password.text()==password_2:
login_status="2"
else:
sound_2()
reply=QMessageBox.critical(login_win,"Failure",("Your password or user name is invalid !"),QMessageBox.Ok)
login_status="3"
else:
sound_2()
reply=QMessageBox.critical(login_win,"Failure",("Your password or user name is invalid !"),QMessageBox.Ok)
login_status="3"
login_win.user_name.setText('')
login_win.password.setText('')
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''UPDATE login_details SET login_status = "{}" WHERE user_id=1;'''.format(login_status))
c.execute(query)
conn.commit()
conn.close()
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT login_status FROM login_details WHERE user_id=1;'''
c.execute(query)
a = c.fetchone()
conn.close()
login_status=a[0]
refresh(login_status)
except Exception as e:
sound_2()
reply=QMessageBox.critical(main_win,"Error",str(e),QMessageBox.Ok)
def forgot_password_ui():
context = ssl.create_default_context()
url = "https://www.bhphotovideo.com"
timeout = 8
sound_1()
try:
request = requests.get(url, timeout=timeout)
except (requests.ConnectionError, requests.Timeout) as exception:
sound_2()
reply=QMessageBox.critical(login_win,"Failure",("Please connecet the internet and try again ! {}".format(exception)),QMessageBox.Ok)
return
# Try to log in to server and send email
try:
login_win.progressBar.show()
login_win.progressBar.setValue(1)
server = smtplib.SMTP('smtp.gmail.com', 587)
login_win.progressBar.setValue(17)
server.ehlo() # check connection
login_win.progressBar.setValue(29)
server.starttls(context=context) # Secure the connection
login_win.progressBar.setValue(43)
server.ehlo() # check connection
login_win.progressBar.setValue(56)
server.login('pradeepdowney64@gmail.com','dsce nrao hwdx txzo')
login_win.progressBar.setValue(65)
conn = sqlite3.connect('application_data/databases/clms_database.db')#database connect
login_win.progressBar.setValue(67)
c = conn.cursor()
login_win.progressBar.setValue(70)
query = '''SELECT * FROM login_details WHERE user_id=1;'''
login_win.progressBar.setValue(73)
c.execute(query)
login_win.progressBar.setValue(75)
a = c.fetchone()
login_win.progressBar.setValue(80)
user_name=a[1]
login_win.progressBar.setValue(81)
email=a[2]
login_win.progressBar.setValue(82)
password_1=a[3]
login_win.progressBar.setValue(83)
password_2=a[4]
login_win.progressBar.setValue(85)
conn.commit()
login_win.progressBar.setValue(87)
conn.close()
login_win.progressBar.setValue(91)
# Send email here
message = MIMEText('\nHi {},\n\n User Name: {} \n password_1 (admin): {}\n password_2 (staff): {}\n\n This mail was generated by CLMS software, so please do not reply. Thank you for using CLMS!'.format(user_name,user_name,password_1,password_2,))
message['Subject'] = 'CLMS OTP Verification'
message['From'] = "pradeepdowney64@gmail.com"
message['To'] = "pradeepdowney63@gmail.com"
login_win.progressBar.setValue(94)
server.sendmail('pradeepdowney64@gmail.com', email, message.as_string())
login_win.progressBar.setValue(100)
login_win.progressBar.hide()
sound_3()
reply=QMessageBox.information(login_win,"Success",("Your login details are successfully sent to your email {} !".format(email)),QMessageBox.Ok)
except Exception as e:
# Print any error messages
sound_2()
reply=QMessageBox.critical(login_win,"Error",str(e),QMessageBox.Ok)
finally:
server.quit()
def main_ui():
#if cookie!=true:
#go to -->login_ui()
#else show ***main_ui***
qtRectangle=main_win.frameGeometry()
centerPoint=QDesktopWidget().availableGeometry().center()
centerPoint.setY(centerPoint.y()-7)
qtRectangle.moveCenter(centerPoint)
main_win.move(qtRectangle.topLeft())
main_win.show()
main_win.home_btn.clicked.connect(home_ui)
main_win.issue_book_btn.clicked.connect(issue_book_ui)
main_win.return_book_btn.clicked.connect(return_book_ui)
main_win.issued_book_details_btn.clicked.connect(issued_book_details_ui)
main_win.defaulter_btn.clicked.connect(defaulter_ui)
main_win.manage_students_btn.clicked.connect(manage_students_ui)
main_win.manage_books_btn.clicked.connect(manage_books_ui)
main_win.manage_book_quantity_btn.clicked.connect(manage_book_quantity_ui)
main_win.settings_btn.clicked.connect(settings_ui)
main_win.batch_and_course_btn.clicked.connect(manage_batch_ui)
main_win.exit_btn.clicked.connect(on_sys_exit) #PROGRAM KILL sys.exit
main_win.student_profile_btn_7.clicked.connect(student_profile_ui)
main_win.student_profile_btn_10.clicked.connect(personal_details_ui)
main_win.book_history_btn.clicked.connect(book_history_ui)
main_win.export_manage_books_btn.clicked.connect(export_manage_books_process)
main_win.roll_number.textChanged.connect(refresh_student_info)
main_win.book_qty_id.textChanged.connect(refresh_book_info)
main_win.issue_btn.clicked.connect(issue_query)
main_win.issue_book_input_clear_btn.clicked.connect(issue_book_input_clear)
main_win.manage_course_btn.clicked.connect(manage_course_ui)
main_win.manage_batch_btn.clicked.connect(manage_batch_ui)
main_win.change_user_name_btn.clicked.connect(change_user_name_ui)
main_win.change_user_name_process_btn.clicked.connect(change_user_name_process)
main_win.change_user_name_pop_up_close_btn.clicked.connect(change_user_name_pop_up_close)
main_win.change_user_name_pop_up_close_btn_2.clicked.connect(change_user_name_pop_up_close)
main_win.change_password_process_btn.clicked.connect(change_password_process)
main_win.change_email_btn.clicked.connect(change_email_ui)
main_win.change_email_process_btn.clicked.connect(change_email_process)
main_win.change_email_pop_up_close_btn.clicked.connect(change_email_pop_up_close)
main_win.change_email_pop_up_close_btn_2.clicked.connect(change_email_pop_up_close)
main_win.change_password_pop_up_close_btn.clicked.connect(change_password_pop_up_close)
main_win.change_password_pop_up_close_btn_2.clicked.connect(change_password_pop_up_close)
main_win.change_password_btn.clicked.connect(change_password_ui)
main_win.add_book_quantity_btn.clicked.connect(add_book_quantity_process)
main_win.add_book_quantity_close_btn.clicked.connect(add_book_quantity_close)
main_win.save_book_quantity_btn.clicked.connect(save_add_book_quntity_details_process)
main_win.delete_book_quantity_btn.clicked.connect(delete_book_quantity_process)
main_win.manage_student_pop_up_btn.clicked.connect(manage_student_pop_up_process)
main_win.close_manage_student_btn.clicked.connect(close_manage_student_process)
main_win.delete_manage_student_btn.clicked.connect(delete_student_process)
main_win.next_1.clicked.connect(next_2_process)
main_win.next_2.clicked.connect(next_3_process)
main_win.next_3.clicked.connect(next_4_process)
main_win.prev_2.clicked.connect(next_1_process)
main_win.prev_3.clicked.connect(next_2_process)
main_win.prev_4.clicked.connect(next_3_process)
main_win.finish.clicked.connect(finish_process)
main_win.add_course_btn.clicked.connect(add_course_process)
main_win.close_add_course_btn.clicked.connect(close_add_course_process)
main_win.save_add_course_btn.clicked.connect(save_add_course_process)
main_win.delete_course_btn.clicked.connect(delete_course_process)
main_win.add_batch_btn.clicked.connect(add_batch_pop_up)
main_win.add_batch_pop_up_close_btn.clicked.connect(close_add_batch_process)
main_win.save_add_batch_btn.clicked.connect(save_add_batch_process)
main_win.delete_batch_btn.clicked.connect(delete_batch_process)
main_win.filter_btn.clicked.connect(filter_pop_up_ui)
main_win.close_filter_pop_up_btn.clicked.connect(close_filter_pop_up)
main_win.reset_btn.clicked.connect(reset_process)
main_win.restore_btn.clicked.connect(restore_process)
main_win.delete_back_up_btn.clicked.connect(delete_back_up_process)
main_win.back_up_btn.clicked.connect(lambda:back_up(1))
main_win.add_book_pop_up_btn.clicked.connect(add_book_pop_up)
main_win.add_book_close_btn.clicked.connect(add_book_close_process)
main_win.save_add_book_details_btn.clicked.connect(save_add_book_details_process)
main_win.delete_book_btn.clicked.connect(delete_book_process)
main_win.delete_issued_book_btn.clicked.connect(delete_issued_book_row)
main_win.clear_return_book_btn.clicked.connect(clear_return_book_process_2)
main_win.clear_btn.clicked.connect(clear_book_history_process_2)
main_win.return_btn.clicked.connect(return_query)
main_win.manage_books_save_btn.clicked.connect(manage_books_table_changed)
main_win.book_filter.textChanged.connect(refresh_book_details_table)
main_win.student_filter.textChanged.connect(refresh_student_details_table)
main_win.clear_filter.clicked.connect(clear_filter_process)
main_win.save_student_btn.clicked.connect(manage_students_details_table_changed)
main_win.course_7.currentTextChanged.connect(refresh_student_details_table)
main_win.batch_6.currentTextChanged.connect(refresh_student_details_table)
main_win.clear_filter_btn.clicked.connect(clear_filter_proces)
main_win.export_student_details_list_btn.clicked.connect(export_student_details_list_process)
clear_main_ui()
home_ui()
def home_ui():
sound_4()
clear_main_ui()
pixmap1=QPixmap("application_ui/images/college_background_image.png")
main_win.home_screen_saver.setPixmap(pixmap1)
main_win.home_screen_saver.show()
lists=random.sample(range(1,20),4)
pixmap2=QPixmap("application_ui/images/{}.png".format(lists[0]))
main_win.sub_image_1.setPixmap(pixmap2)
main_win.sub_image_1.show()
pixmap3=QPixmap("application_ui/images/{}.png".format(lists[1]))
main_win.sub_image_2.setPixmap(pixmap3)
main_win.sub_image_2.show()
pixmap4=QPixmap("application_ui/images/{}.png".format(lists[2]))
main_win.sub_image_3.setPixmap(pixmap4)
main_win.sub_image_3.show()
pixmap5=QPixmap("application_ui/images/{}.png".format(lists[3]))
main_win.sub_image_4.setPixmap(pixmap5)
main_win.sub_image_4.show()
main_win.home_frame.show()
set_button_color_for_active_window()
main_win.setWindowTitle("Home - College Library Management System")
def issue_book_ui():
try:
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT roll_number FROM student_details;'''
c.execute(query)
dx = c.fetchone()
conn.close()
if dx is None:
sound_2()
reply=QMessageBox.warning(main_win,"Warning","Please add student details.\nStudent table is empty! ",QMessageBox.Ok)
return
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT book_quantity_id FROM book_quantity_details;'''
c.execute(query)
dy = c.fetchone()
conn.close()
if dy is None:
sound_2()
reply=QMessageBox.warning(main_win,"Warning","Please add book quantity details.\nBook quantity table is empty! ",QMessageBox.Ok)
return
sound_1()
clear_main_ui()
main_win.issue_book_frame.show()
set_button_color_for_active_window()
main_win.setWindowTitle("Issue Book - College Library Management System")
main_win.today_date.setDateTime(QtCore.QDateTime.currentDateTime())
main_win.today_date.setDisplayFormat("dd/MM/yyyy")
ds=datetime.datetime.now().day
ms=datetime.datetime.now().month
ys=datetime.datetime.now().year
ds=int(ds)
ms=int(ms)
ys=int(ys)
d=QDate(ys,ms,ds).addMonths(5)
main_win.last_date.setDate(d)
main_win.last_date.setDisplayFormat("dd/MM/yyyy")
except Exception as e:
print("kkke")
print(e)
def issue_query():
try:
roll_number=main_win.roll_number.text()
book_qty_id=str(main_win.book_qty_id.text())
if roll_number=='':
sound_2()
reply=QMessageBox.warning(main_win,"warning","Please enter roll number ! ",QMessageBox.Ok)
return
if book_qty_id=='':
sound_2()
reply=QMessageBox.warning(main_win,"warning","Please enter the book quantity id ! ",QMessageBox.Ok)
return
if main_win.phone_number.text()=='':
sound_2()
reply=QMessageBox.warning(main_win,"warning","Student roll number not found ! ",QMessageBox.Ok)
return
if main_win.book_number.text()=='':
sound_2()
reply=QMessageBox.warning(main_win,"warning","Book quantity id not found ! ",QMessageBox.Ok)
return
#!!!!!!!!!!!!!
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT book_quantity_id FROM issued_book_details;'''
c.execute(query)
sx = c.fetchall()
conn.close()
if sx!=None:
length_of_sx=len(sx)
for i in range(0,length_of_sx):
if sx[i][0]==book_qty_id:
sound_2()
reply=QMessageBox.warning(main_win,"warning","Book was already issued ! ",QMessageBox.Ok)
return
issued_book_id=str(roll_number)+str("-")+str(book_qty_id)
issue_date=main_win.today_date.date()
issue_date=issue_date.toString("dd/MM/yyyy")
last_date=main_win.last_date.date()
last_date=last_date.toString("dd/MM/yyyy")
ds=book_quantity_id_to_book_id(book_qty_id)
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT total_issued FROM book_details WHERE book_id="{}";'''.format(ds))
c.execute(query)
df = c.fetchone()
conn.close()
df=df[0]
df=int(df)+1
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('UPDATE book_details SET total_issued="{}" where book_id="{}"'.format(df,ds))
c.execute(query)
conn.commit()
conn.close()
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = ('''SELECT course_id,batch_id FROM student_details WHERE roll_number="{}";'''.format(roll_number))
c.execute(query)
sa = c.fetchone()
conn.close()
course_id=sa[0]
batch_id=sa[1]
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
c.execute("INSERT INTO issued_book_details (issued_book_id,roll_number,book_quantity_id,issue_date,last_date,book_id,course_id,batch_id)VALUES(?,?,?,?,?,?,?,?)",(issued_book_id,roll_number,book_qty_id,issue_date,last_date,ds,course_id,batch_id))
conn.commit()
conn.close()
sound_3()
reply=QMessageBox.information(main_win,"Success","The book was issued! ",QMessageBox.Ok)
main_win.roll_number.setText('')
main_win.book_qty_id.setText('')
refresh_student_info()
refresh_book_info()
#if data is found; save to the database
#alert success
#clear screan
#set same student id
except Exception as e:
print("uue")
print(e)
def issue_book_input_clear():
try:
sound_4()
main_win.roll_number.setText('')
main_win.book_qty_id.setText('')
refresh_student_info()
refresh_book_info()
except Exception as e:
print("eghjhg")
print(e)
def refresh_student_info():
try:
main_win.name.setText('')
main_win.course.setText('')
main_win.batch.setText('')
main_win.phone_number.setText('')
main_win.dob.setText('')
main_win.address.setText('')
main_win.student_description.setPlainText('')
roll_number=main_win.roll_number.text()
if roll_number == '':
main_win.name.setText('')
main_win.course.setText('')
main_win.batch.setText('')
main_win.phone_number.setText('')
main_win.dob.setText('')
main_win.address.setText('')
main_win.student_description.setPlainText('')
else:
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()
query = '''SELECT roll_number,name,date_of_birth,phone,address,description,batch_id,course_id FROM student_details;'''
c.execute(query)
b = c.fetchall()
conn.close()
if b==None:
return
row=()
z=()
i=0
for i,z in enumerate(b):
if z[0]==roll_number:
break
else:
z=()
i=0
if z==():
return
print(z)
name=z[1]
date_of_birth=z[2]
phone=z[3]
address=z[4]
description=z[5]
batch_id=z[6]
course_id=z[7]
conn = sqlite3.connect('application_data/databases/clms_database.db')
c = conn.cursor()