Commit 62f20dd7 authored by David Gustavo De La Rocha Ramirez's avatar David Gustavo De La Rocha Ramirez
Browse files

menu_gestion (Admin) complet

parent eada0f31
......@@ -55,6 +55,20 @@ class Admin(SQL):
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4])
def montrer_arrets(self):
sql = 'SELECT * FROM Arret ORDER BY ligne, gare;'
rows = self._lecture_sql(sql)
print("ID_arret | Position | Gare | Ligne")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3])
def montrer_horaires(self):
sql = 'SELECT * FROM Horaires ORDER BY arret, id_train;'
rows = self._lecture_sql(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])
# AJOUTS DE TABLE
def ajouter_ville(self,nom_ville):
......@@ -72,8 +86,8 @@ class Admin(SQL):
def ajouter_train(self, numero, type_train, places_max, premiere_class, vitesse_max):
self._insert_into("Train", [numero, type_train, places_max, premiere_class, vitesse_max])
def ajouter_arret(self, jour):
self._insert_into("Calendrier",[jour])
def ajouter_arret(self, id_arret, position, gare, ligne):
self._insert_into("Arret",[id_arret, position, gare, ligne])
def ajouter_horaires(self, id_horaires, id_train, arrivee_gare, depart_gare, arret, date_horaires, jour, type_horaire, type_except):
self._insert_into("Horaires(id_horaires, id_train, arrivee_gare, depart_gare, arret, date_horaires, jour, type_horaire, type_except)",[id_horaires, id_train, arrivee_gare, depart_gare, arret, date_horaires, jour, type_horaire, type_except])
......@@ -105,6 +119,14 @@ class Admin(SQL):
sql = "DELETE FROM Train WHERE numero=%s"%numero
self._ecriture_sql(sql)
def supprimer_arret(self, id_arret):
sql = "DELETE FROM Arret WHERE id_arret=%s"%id_arret
self._ecriture_sql(sql)
def supprimer_horaire(self, id_horaires):
sql = "DELETE FROM Horaires WHERE id_horaires=%s"%id_horaires
self._ecriture_sql(sql)
# STATISTIQUES
# SCRIPTS MENU
......@@ -203,18 +225,26 @@ class Admin(SQL):
print("1 >> Consulter Villes")
print("2 >> Ajouter Ville")
print("3 >> Supprimer Ville")
print(" ")
print("----------------------")
print("4 >> Consulter Gares")
print("5 >> Ajouter Gare")
print("6 >> Supprimer Gare")
print(" ")
print("----------------------")
print("7 >> Consulter Lignes")
print("8 >> Ajouter Ligne")
print("9 >> Supprimer Ligne")
print(" ")
print("----------------------")
print("10 >> Consulter Trains")
print("11 >> Ajouter Train")
print("12 >> Supprimer Train")
print("----------------------")
print("13 >> Consulter Arrêts")
print("14 >> Ajouter Arrêt")
print("15 >> Supprimer Arrêt")
print("----------------------")
print("16 >> Consulter Horaires")
print("17 >> Ajouter Horaire")
print("18 >> Supprimer Horaire")
print("\n Autre entrée >> quitter le menu")
choice=input()
if choice == '1':
......@@ -280,6 +310,54 @@ class Admin(SQL):
print("NUMERO du train (à supprimer):")
self.supprimer_train(input())
menu=True
if choice == '13':
print("Arrêts: ")
self.montrer_arrets()
menu=True
if choice == '14':
print("id_arret = ")
id_arret = input()
print("position = ")
position = input()
print("gare = ")
gare = input()
print("ligne = ")
ligne = input()
self.ajouter_arret(id_arret, position, gare, ligne)
menu=True
if choice == '15':
print("ID de l'arrêt (à supprimer):")
self.supprimer_arret(input())
menu=True
if choice == '16':
print("Horaires: ")
self.montrer_horaires()
menu=True
if choice == '17':
print("id_horaires = ")
id_horaires = input()
print("id_train = ")
id_train = input()
print("arrivee_gare = ")
arrivee_gare = input()
print("depart_gare = ")
depart_gare = input()
print("arret = ")
arret = input()
print("date_horaires = ")
date_horaires = input()
print("jour = ")
jour = input()
print("type_horaire = ")
type_horaire = input()
print("type_except = ")
type_except = input()
self.ajouter_horaire(id_horaires, id_train, arrivee_gare, depart_gare, arret, date_horaires, jour, type_horaire, type_except)
menu=True
if choice == '18':
print("ID de l'horaire (à supprimer):")
self.supprimer_horaire(input())
menu=True
def menu_statistiques(self):
menu=True
......
......@@ -63,7 +63,7 @@ CREATE TABLE Horaires (
arrivee_gare TIME NOT NULL,
depart_gare TIME NOT NULL,
arret INTEGER NOT NULL REFERENCES Arret(id_arret) NOT NULL,
date_horaires DATE NOT NULL,
date_horaires DATE,
jour typeJour REFERENCES Calendrier(jour) NOT NULL,
type_horaire typeHoraire NOT NULL,
type_except typeExcept,
......
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