-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
206 lines (198 loc) · 9.6 KB
/
main.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
import os
import pyttsx3
import sqlite3
import getpass
import face_recognition
import cv2
from prettytable import PrettyTable
from datetime import date
import matplotlib.pyplot as plt
import numpy as np
speak = pyttsx3.init()
conn = sqlite3.connect('attendance.db')
cursor = conn.cursor()
#cursor.execute('CREATE TABLE LOGIN_TABLE(u_id varchar(30), pass varchar(20), u_type varchar(20));')
#cursor.execute('INSERT INTO LOGIN_TABLE VALUES("admin","abcd","admin");')
#conn.commit()
speak.say("This is a system developed by Rimon, Shailesh, Vinay and Rick.")
speak.runAndWait()
login = -1
while login!=1:
username = input('Enter username: ')
print('Enter password: ')
password = getpass.getpass()
cursor.execute('SELECT * FROM LOGIN_TABLE WHERE u_id=?;',(username,))
for x in cursor:
global pass_valid
pass_valid = x[1]
global user_type
user_type = x[2]
if pass_valid == password:
login = 1
else:
speak.say("I'm afraid! You have entered a wrong password. Please try again.")
speak.runAndWait()
if user_type == 'admin':
speak.say("Hello Admin! Welcome to Attendance Marking System Using Face Detection. Hope you'll find it interesting.")
speak.runAndWait()
while login == 1:
speak.runAndWait()
print("""
|======================================================|
|==========Welcome To Attendance Marking System========|
|======================================================|
------------------------------------------------------
Welcome Admin!
Enter 1 : To Add New Student
Enter 2 : To Add New Faculty
Enter 3 : To View List of Faculty
Enter 4 : To View List of Students
Enter 5 : To Search Student
Enter 6 : To Search Faculty
Enter 7 : To Delete Student
Enter 8 : To Delete Faculty
Enter 9 : To Change Password
Enter 10 : To Logout
""")
speak.say("Choose an option please.")
speak.runAndWait()
choice = int(input('Enter your choice: '))
if choice == 1:
print('Add New Student')
s_section = input("Enter student's section: ")
s_name = input('Enter student name: ')
s_fname = input("Enter Father's name: ")
s_mname = input("Enter Mother's name: ")
s_email = input("Enter email id: ")
s_phone = input("Enter student's phone no: ")
s_pphone = input("Enter parent's phone no: ")
s_address = input("Enter address: ")
#cursor.execute("CREATE TABLE STUDENT(s_id integer PRIMARY KEY AUTOINCREMENT,s_section varchar(20), s_name varchar(30),s_fname varchar(30),s_mname varchar(30),s_email varchar(30),s_phone varchar(20),s_pphone varchar(30),s_address varchar(30));")
cursor.execute("INSERT INTO STUDENT(s_section,s_name,s_fname,s_mname,s_email,s_phone,s_pphone,s_address) VALUES(?,?,?,?,?,?,?,?);",(s_section,s_name,s_fname,s_mname,s_email,s_phone,s_pphone,s_address))
conn.commit()
print('Added to STUDENT Table')
print('Data Successfully Entered')
dummy = input('Press any key to continue...........')
elif choice == 2:
print('Add New Faculty')
f_name = input('Enter Faculty name: ')
f_subject = input("Enter subject: ")
f_email = input("Enter email id: ")
f_phone = input("Enter phone no: ")
f_address = input("Enter address: ")
f_pw = 'abcd'
ac_type = 'faculty'
#cursor.execute("CREATE TABLE FACULTY_DATA(f_id integer PRIMARY KEY AUTOINCREMENT,f_name varchar(30), f_subject varchar(30),f_email varchar(30),f_phone varchar(30),f_address varchar(30),f_pass varchar(30));")
cursor.execute("INSERT INTO FACULTY_DATA(f_name,f_subject,f_email,f_phone,f_address,f_pass) VALUES(?,?,?,?,?,?);",(f_name,f_subject,f_email,f_phone,f_address,f_pw))
conn.commit()
cursor.execute("INSERT INTO LOGIN_TABLE VALUES(?,?,?);",(f_email,f_pw,ac_type));
conn.commit()
print('Data Successfully Entered')
dummy = input('Press any key to continue...........')
elif choice == 3:
print('List of Faculties: ')
x = PrettyTable()
cursor.execute("SELECT * from FACULTY_DATA")
x.field_names = ["ID", "Name", "Subject", "Email", "Phone", "Address", "Password"]
for row in cursor:
x.add_row([row[0],row[1],row[2],row[3],row[4],row[5],row[6]]);
print(x)
dummy = input('Press any key to continue...........')
elif choice == 4:
x = PrettyTable()
cursor.execute("SELECT * from STUDENT")
x.field_names = ["ID", "Section", "Name", "Father's Name", "Mother's Name", "Email", "Phone No", "Parent's Phone", "Address"]
for row in cursor:
x.add_row([row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8]]);
print(x)
dummy = input('Press any key to continue...........')
elif choice == 5:
print("1)Search by ID")
print("2)Search by Name:")
choice = int(input('Enter 1 or 2......'))
if choice == 1:
key = input('Enter ID: ')
x = PrettyTable()
cursor.execute("SELECT * from STUDENT_DATA WHERE s_id = ?;", key)
x.field_names = ["ID", "Section", "Name", "Father's Name", "Mother's Name", "Email", "Phone No", "Parent's Phone", "Address"]
for row in cursor:
x.add_row([row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8]]);
print(x)
dummy = input('Press any key to continue...........')
if choice == 2:
key = input('Enter Name: ')
key = key+'%'
x = PrettyTable()
cursor.execute("SELECT * from STUDENT_DATA WHERE s_name LIKE ?;", (key,))
x.field_names = ["ID", "Section", "Name", "Father's Name", "Mother's Name", "Email", "Phone No", "Parent's Phone", "Address"]
for row in cursor:
x.add_row([row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8]]);
print(x)
dummy = input('Press any key to continue...........')
elif choice == 6:
print("Search Faculty")
key = input('Enter Name: ')
x = PrettyTable()
cursor.execute("SELECT * from FACULTY_DATA where f_name LIKE ?;", key)
x.field_names = ["ID", "Name", "Subject", "Email", "Phone", "Address", "Password"]
for row in cursor:
x.add_row([row[0],row[1],row[2],row[3],row[4],row[5],row[6]]);
print(x)
dummy = input('Press any key to continue...........')
elif choice == 7:
print('Delete Student: ')
key = input('Enter ID: ')
cursor.execute("DELETE from STUDENT WHERE s_id = ?;", (key,))
conn.commit()
print('Success')
dummy = input('Press any key to continue...........')
elif choice == 8:
print('Delete Faculty: ')
key = input('Enter email ID: ')
cursor.execute("DELETE from FACULTY_DATA WHERE f_email = ?;", (key,))
print('Deleted from FACULTY_DATA')
conn.commit()
cursor.execute("DELETE from LOGIN_TABLE WHERE u_id = ?;", (key,))
print('Deleted from LOGIN_TABLE')
conn.commit()
dummy = input('Press any key to continue...........')
elif choice == 9:
success = -1
while success!=1:
print('Enter password: ')
password = getpass.getpass()
cursor.execute('SELECT * FROM LOGIN_TABLE WHERE u_id=?;',(username,))
for x in cursor:
pass_val = x[1]
if pass_val == password:
newp = input('Please enter new password: ')
cursor.execute("UPDATE LOGIN_TABLE set pass=? where u_id=?;",(newp,username))
conn.commit()
success = 1
print('Password Changed')
login = 0
else:
print("I'm afraid! You have entered a wrong password. Please try again.")
elif choice == 10:
login = 0
print('You are successfully logged out')
elif user_type == 'faculty':
speak.say("Hello Faculty! Welcome to Attendance Marking System Using Face Detection. Hope you'll find it interesting.")
speak.runAndWait()
print("""
|======================================================|
|==========Welcome To Attendance Marking System========|
|======================================================|
------------------------------------------------------
Welcome Faculty!
Enter 1 : To View List of Students
Enter 2 : To Search Student
Enter 3 : To Mark Attendance
Enter 4 : To View Attendance
Enter 5 : To Visualize Attendance
Enter 6 : To Change Password
Enter 7 : To Logout
""")
speak.say("Choose an option please.")
speak.runAndWait()
choice = int(input('Enter your choice: '))