Commit 297fe32d authored by Francois Mares's avatar Francois Mares
Browse files

Replace Admin.py

parent f5315880
......@@ -106,19 +106,52 @@ class Admin(SQL):
print(self._lecture_sql(sql))
print("Choisissez un train:")
numero=int(input())
print("Horaires existants:")
sql='''
SELECT COUNT(id_horaires)
FROM Horaires
WHERE id_train=%i;
SELECT * FROM Horaires
WHERE Horaires.id_train=%i;
'''% numero
horaires=self._lecture_sql(sql)
for horaire in horaires:
print(horaire)
print("Choisissez un horaire:")
id_horaire=int(input())
sql='''
SELECT COUNT(Billet.id_billet)
FROM (Billet
INNER JOIN trajet ON Trajet.id_billet=Billet.id_billet)
INNER JOIN Horaires ON (Horaires.id_horaires=horaire_depart OR Horaires.id_horaires=horaire_arrivee)
WHERE Horaires.id_train=%i;
''' % numero
places_occupées=int(self._lecture_sql(sql)[0][0]/2)
places_occupées=int(self._lecture_sql(sql)[0][0])
sql='''
SELECT places_max FROM train WHERE numero=%i;
''' % numero
places_disponnibles=self._lecture_sql(sql)[0][0]
taux=(float(places_occupées)/float(places_disponnibles))*100.0
print(">> Taux occupation train num %i: %d%% (%i/%i)" % (numero, taux, places_occupées, places_disponnibles))
print(">> Taux occupation train num %i: %.2f%% (%i/%i)" % (numero, taux, places_occupées, places_disponnibles))
return taux
# TO DO
def script_gare_plus_freq(self):
print("Nombre de gares: (default=10)")
tmp=input()
if type(tmp)==int and int(tmp)>0:
nb=int(tmp)
else:
nb=10
sql='''
SELECT gare.nom_gare, COUNT()
FROM gare
ORDER BY id_train=%i
LIMIT %i;
''' % nb
print("Période ('lundi',... ou 'semaine'")
periode=input()
gares=self._lecture_sql(sql)
for gare in gares:
print("%s %i" % (gare[0], gare[1]))
# MENUS
def menu_gestion(self):
......@@ -152,7 +185,7 @@ class Admin(SQL):
self.script_taux_remplissage_train()
menu=True
if choice == '2':
self.script_gare_plus_freq()
menu=True
if choice == '3':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment