Commit 49c43446 authored by David Gustavo De La Rocha Ramirez's avatar David Gustavo De La Rocha Ramirez
Browse files

Partie Admin finie

parent 62f20dd7
......@@ -68,6 +68,27 @@ class Admin(SQL):
print("ID_horaire | ID_train | Gare_arrivee | Gare_depart | Arret | Jour | Type_horaire")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4], ' | ', row[6], ' | ', row[8])
def montrer_voyageurs(self):
sql = 'SELECT * FROM Voyageur ORDER BY type_voyageur, id_voyageur;'
rows = self._lecture_sql(sql)
print("ID | Nom | Prenom | Adresse | Telephone | ID_Carte | Type_voyageur")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4], ' | ', row[5], ' | ', row[7])
def montrer_billets(self):
sql = 'SELECT * FROM Billet ORDER BY id_voyageur;'
rows = self._lecture_sql(sql)
print("ID | Prix | Paiement | Assurance | ID_Voyageur")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4])
def montrer_trajets(self):
sql = 'SELECT * FROM Trajet ORDER BY id_billet;'
rows = self._lecture_sql(sql)
print("ID | ID_billet | Num_Place | Duree | Horaire_depart | Horaire_arrivee")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4], ' | ', row[5])
# AJOUTS DE TABLE
......@@ -195,25 +216,35 @@ class Admin(SQL):
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)
sql='''
SELECT nom_gare, count(*) AS c
FROM ((Trajet AS T JOIN Horaires AS H ON T.horaire_depart=H.id_horaires) JOIN Arret AS A ON H.arret=A.id_arret)
JOIN Gare AS G ON A.gare=G.id_gare
GROUP BY G.nom_gare
ORDER BY c DESC
LIMIT 10;
'''
gares = self._lecture_sql(sql)
print("\n* Gares les plus frequentees (MAX 10):")
print("\nNom Gare | Nb de voyageurs")
for gare in gares:
print("%s %i" % (gare[0], gare[1]))
print("%s | %i" % (gare[0], gare[1]))
def script_ligne_plus_freq(self):
sql='''
SELECT nom_ligne, count(*) AS c
FROM ((Trajet AS T JOIN Horaires AS H ON T.horaire_depart=H.id_horaires) JOIN Arret AS A ON H.arret=A.id_arret)
JOIN Ligne AS L ON A.ligne=L.id_ligne
GROUP BY L.nom_ligne
ORDER BY c DESC
LIMIT 10;
'''
lignes = self._lecture_sql(sql)
print("\n* Lignes les plus frequentees (MAX 10):")
print("\nNom Ligne | Nb de voyageurs")
for ligne in lignes:
print("%s | %i" % (ligne[0], ligne[1]))
# MENUS
......@@ -245,6 +276,10 @@ class Admin(SQL):
print("16 >> Consulter Horaires")
print("17 >> Ajouter Horaire")
print("18 >> Supprimer Horaire")
print("----------------------")
print("19 >> Consulter Voyageurs")
print("20 >> Consulter Billets")
print("21 >> Consulter Trajets")
print("\n Autre entrée >> quitter le menu")
choice=input()
if choice == '1':
......@@ -358,6 +393,18 @@ class Admin(SQL):
print("ID de l'horaire (à supprimer):")
self.supprimer_horaire(input())
menu=True
if choice == '19':
print("Voyageurs: ")
self.montrer_voyageurs()
menu=True
if choice == '20':
print("Billets: ")
self.montrer_billets()
menu=True
if choice == '21':
print("Trajets: ")
self.montrer_trajets()
menu=True
def menu_statistiques(self):
menu=True
......@@ -376,7 +423,7 @@ class Admin(SQL):
self.script_gare_plus_freq()
menu=True
if choice == '3':
self.script_ligne_plus_freq()
menu=True
def menu(self):
......
......@@ -2,9 +2,22 @@ import Admin
import Client
if __name__ == "__main__":
# Partie Admin
admin = Admin.Admin()
admin.menu()
# Partie Client
client = Client.Client()
client.menu()
\ No newline at end of file
menu=True
while menu:
menu=False
print("\n=============== MENU PRINCIPALE ===============")
print("1 >> Menu Admin")
print("2 >> Menu Client")
print("\n Autre entrée >> quitter le menu")
choice=input()
if choice == '1':
# Partie Admin
admin = Admin.Admin()
admin.menu()
menu=True
if choice == '2':
# Partie Client
client = Client.Client()
client.menu()
menu=True
\ No newline at end of file
......@@ -63,23 +63,38 @@ INSERT INTO Horaires VALUES (3, 1, '10:05:00', '10:30:00', 3, '2021-05-24', 'lun
INSERT INTO Horaires VALUES (4, 1, '12:45:00', '12:55:00', 4, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (5, 1, '15:45:00', '16:00:00', 5, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (6, 1, '7:50:00', '8:00:00', 1, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (7, 1, '9:10:00', '9:15:00', 2, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (8, 1, '10:05:00', '10:30:00', 3, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (9, 1, '12:45:00', '12:55:00', 4, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (10, 1, '15:45:00', '16:00:00', 5, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (6, 2, '7:50:00', '8:00:00', 6, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (7, 2, '9:10:00', '9:15:00', 7, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (8, 2, '10:05:00', '10:30:00', 8, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (9, 2, '12:45:00', '12:55:00', 9, '2021-05-24', 'lundi', 'régulier', NULL);
INSERT INTO Horaires VALUES (10, 2, '15:45:00', '16:00:00', 10, '2021-05-24', 'lundi', 'régulier', NULL);
---Voyageur(#id_voyageur: int, nom: varchar, prenom: varchar, adresse: varchar,
--- tel: longint, paiement: {carte, espèce, chèque}, id_carte: integer,
--- tel: longint, id_carte: integer,
--- status: {voyageur, grand, plus}, type: {occasionnel, régulier});
INSERT INTO Voyageur(id_voyageur, nom, prenom, adresse, tel, id_carte, status_voyageur, type_voyageur) VALUES (0, 'TONTON', 'Tintin', '60200 Compiègne', 0712344556, NULL, NULL, 'occasionnel');
INSERT INTO Voyageur(id_voyageur, nom, prenom, adresse, tel, id_carte, status_voyageur, type_voyageur) VALUES (1, 'DUPONT', 'Jean', '60200 Compiègne', 0712356556, NULL, NULL, 'occasionnel');
INSERT INTO Voyageur(id_voyageur, nom, prenom, adresse, tel, id_carte, status_voyageur, type_voyageur) VALUES (2, 'DURONT', 'Marie', '60200 Toulouse', 0712359556, NULL, NULL, 'régulier');
---Billet(#id_billet: int, prix : reel, assurance : bool, id_voyageur=>Voyageur, gare_depart=>Gare, gare_arrivee=>Gare) ;
INSERT INTO Billet (prix, paiement, assurance, id_voyageur, gare_depart, gare_arrivee) VALUES (15.5, 'espèce', true, 1, 3, 2);
---Billet(#id_billet: int, prix : reel, paiement: {carte, espèce, chèque}, assurance : bool, id_voyageur=>Voyageur) ;
INSERT INTO Billet (prix, paiement, assurance, id_voyageur) VALUES (15.5, 'espèce', true, 1);
INSERT INTO Billet (prix, paiement, assurance, id_voyageur) VALUES (15.5, 'carte', true, 2);
INSERT INTO Billet (prix, paiement, assurance, id_voyageur) VALUES (15.5, 'chèque', true, 0);
INSERT INTO Billet (prix, paiement, assurance, id_voyageur) VALUES (15.5, 'carte', true, 2);
---Trajet (#id_trajet : int, #id_billet=>Billet, numéro_place :integer, durée: heure,
--- horaire_départ=>Horaires, horaire_arrivée=>Horaires);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (1, 280, '00:50:00', 1, 2);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (1, 280, '00:50:00', 2, 3);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (1, 280, '00:50:00', 3, 4);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (2, 152, '00:50:00', 6, 7);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (2, 152, '00:50:00', 7, 8);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (2, 152, '00:50:00', 8, 9);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (3, 47, '00:50:00', 3, 4);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (3, 47, '00:50:00', 4, 5);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (4, 184, '00:50:00', 1, 3);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (4, 184, '00:50:00', 3, 4);
INSERT INTO Trajet (id_billet, numero_place, duree, horaire_depart, horaire_arrivee) VALUES (4, 184, '00:50:00', 4, 5);
......@@ -99,10 +99,7 @@ CREATE TABLE Billet (
paiement typePaiement NOT NULL,
assurance BOOLEAN NOT NULL,
id_voyageur INTEGER REFERENCES Voyageur(id_voyageur) NOT NULL,
gare_depart INTEGER REFERENCES Gare(id_gare) NOT NULL,
gare_arrivee INTEGER REFERENCES Gare(id_gare) NOT NULL,
PRIMARY KEY(id_billet),
CHECK (gare_depart <> gare_arrivee)
PRIMARY KEY(id_billet)
);
---Trajet (#id_trajet : int, #id_billet=>Billet, numéro_place :integer, durée: heure,
......
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