-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserrure.py
More file actions
47 lines (41 loc) · 1.86 KB
/
serrure.py
File metadata and controls
47 lines (41 loc) · 1.86 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
from tkinter import *
from datetime import *
from sqlite3 import *
window = Tk()
window.title("Simulateur de serrure")
def comparer():
test=0
jour=["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]
now = time.localtime(time.time())
hour=now[3]
identifiant = entry_id.get()
salle = entry_salle.get()
conn=connect('serveur.db')
c=conn.cursor()
#Les responsables peuvent ouvrir toutes les portes à toute heure, et possèdent '*' au debut de leur id(voir interface administrateur)
if identifiant[0]=='*':
print("Vous pouvez entrer.")
print("Bienvenue")
else:
for row in c.execute('SELECT * FROM utilisateur INNER JOIN horaire ON utilisateur.id=horaire.id WHERE utilisateur.id="'+identifiant+'";'):
if row[6]==jour[date.weekday(date.today())]:
if hour>=row[4] and hour<row[5]:
if str(row[7])==salle:
test+=1
if test>0:
print("Vous pouvez entrer.")
print("Bienvenue")
else:
print("Vous n'êtes pas autorisé à entrer, pour tout problème, veuillez contacter le :XX.XX.XX.XX.XX.")
conn.commit()
conn.close()
entry_id=StringVar()
label = Label( window, text="Entrez votre id.").pack(padx=10, pady=5)
passEntry = Entry(window, textvariable=entry_id).pack(padx=10, pady=5)
"""Entrer la salle ne serait pas utile sur une serrure, mais il faudrait comparer grace à l'id de la serrure pour
savoir si la salle en particulier peut etre ouverte, et non toutes.
"""
entry_salle = StringVar()
label = Label(window, text="Entrez le numéro de la salle à ouvrir.").pack(padx=10, pady=5)
passEntry = Entry(window, textvariable=entry_salle).pack(padx=10, pady=5)
submit = Button(window, text='valider', command=comparer).pack(padx=10, pady=5)