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

Update Admin: consulter/supprimer (+ main.py)

parent 4eabf56d
......@@ -25,6 +25,35 @@ class Admin(SQL):
def _suppression_bdd(self):
self._execute_sql("../SQL/DELETE.sql")
# SELECTS DE TABLE
def montrer_villes(self):
sql = 'SELECT * FROM Ville;'
rows = self._lecture_sql(sql)
print("| Nom_ville |")
for row in rows:
print(row[0])
def montrer_gares(self):
sql = 'SELECT * FROM Gare;'
rows = self._lecture_sql(sql)
print("Id_gare | Nom_gare | Ville | Adresse | Zone Horaire ")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4])
def montrer_lignes(self):
sql = 'SELECT * FROM Ligne;'
rows = self._lecture_sql(sql)
print("Id_ligne | Nom_ligne | Gare_Origine | Gare_Terminus")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3])
def montrer_trains(self):
sql = 'SELECT * FROM Train;'
rows = self._lecture_sql(sql)
print("Numero | Type | Places_max | Premier_class | Vitesse_max")
for row in rows:
print(row[0], ' | ', row[1], ' | ', row[2], ' | ', row[3], ' | ', row[4])
# AJOUTS DE TABLE
......@@ -58,6 +87,23 @@ class Admin(SQL):
def ajouter_trajet(self, id_billet, numero_place, duree, horaire_depart, horaire_arrivee):
self._insert_into("Trajet(id_billet, numero_place, duree, horaire_depart, horaire_arrivee)", [id_billet, numero_place, duree, horaire_depart, horaire_arrivee])
# SUPPRESION
def supprimer_ville(self, nom_ville):
sql = "DELETE FROM Ville WHERE nom_ville='%s'"%nom_ville
self._ecriture_sql(sql)
def supprimer_gare(self, id_gare):
sql = "DELETE FROM Gare WHERE id_gare=%s"%id_gare
self._ecriture_sql(sql)
def supprimer_ligne(self, id_ligne):
sql = "DELETE FROM Ligne WHERE id_ligne=%s"%id_ligne
self._ecriture_sql(sql)
def supprimer_train(self, numero):
sql = "DELETE FROM Train WHERE numero=%s"%numero
self._ecriture_sql(sql)
# STATISTIQUES
......@@ -72,11 +118,6 @@ class Admin(SQL):
def script_new_gare(self):
print("id_gare=")
#tmp=input()
#if tmp=="":
# id_gare=None
#else:
# id_gare=int(tmp)
id_gare=int(input())
print("nom_ville=")
nom_ville=input()
......@@ -159,16 +200,85 @@ class Admin(SQL):
while menu:
menu=False
print("\n=============== MENU GESTION (ADMIN) ===============")
print("1 >> ajouter ville")
print("2 >> ajouter gare")
print("1 >> Consulter Villes")
print("2 >> Ajouter Ville")
print("3 >> Supprimer Ville")
print(" ")
print("4 >> Consulter Gares")
print("5 >> Ajouter Gare")
print("6 >> Supprimer Gare")
print(" ")
print("7 >> Consulter Lignes")
print("8 >> Ajouter Ligne")
print("9 >> Supprimer Ligne")
print(" ")
print("10 >> Consulter Trains")
print("11 >> Ajouter Train")
print("12 >> Supprimer Train")
print("\n Autre entrée >> quitter le menu")
choice=input()
if choice == '1':
print("Villes: ")
self.montrer_villes()
menu=True
if choice == '2':
print("nom_ville=")
self.ajouter_ville(input())
menu=True
if choice == '2':
self.menu_new_gare()
if choice == '3':
print("NOM de la ville (à supprimer):")
self.supprimer_ville(input())
menu=True
if choice == '4':
print("Gares: ")
self.montrer_gares()
menu=True
if choice == '5':
self.script_new_gare()
menu=True
if choice == '6':
print("ID de la gare (à supprimer):")
self.supprimer_gare(input())
menu=True
if choice == '7':
print("Lignes: ")
self.montrer_lignes()
menu=True
if choice == '8':
print('id_ligne = ')
id_ligne = input()
print('nom_ligne = ')
nom_ligne = input()
print('gare_origine = ')
origine = input()
print('gare_terminus = ')
terminus = input()
self.ajouter_ligne(id_ligne, nom_ligne, origine, terminus)
menu=True
if choice == '9':
print("ID de la ligne (à supprimer):")
self.supprimer_ligne(input())
menu=True
if choice == '10':
print("Trains: ")
self.montrer_trains()
menu=True
if choice == '11':
print("numero = ")
numero = input()
print("type_train {TGV, TER} = ")
type_train = input()
print("places_max = ")
places_max = input()
print("premier_class = ")
premier_class = input()
print("vitesse_max = ")
vitesse_max = input()
self.ajouter_train(numero, type_train, places_max, premier_class, vitesse_max)
menu=True
if choice == '12':
print("NUMERO du train (à supprimer):")
self.supprimer_train(input())
menu=True
def menu_statistiques(self):
......
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
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