From 2a1099c4505686cdee0dda79b3988e5e6e2dd28b Mon Sep 17 00:00:00 2001 From: sidya82 Date: Wed, 4 Feb 2015 15:33:15 +0100 Subject: [PATCH] gg! --- src/c/Borne.py | 34 +++++++++++++++++++++------------- src/c/Main.py | 24 ++++++++++++++---------- src/c/Teleporteur.py | 6 +++--- src/c/log/log.py | 3 --- src/m/Client.py | 2 +- src/m/Parking.py | 17 +++++++++++++---- src/m/Service.py | 15 ++++++++------- src/m/table.sql | 4 ++-- src/v/MyQMainWindow.py | 4 +--- 9 files changed, 63 insertions(+), 46 deletions(-) diff --git a/src/c/Borne.py b/src/c/Borne.py index e51403a..e663c9b 100644 --- a/src/c/Borne.py +++ b/src/c/Borne.py @@ -20,7 +20,12 @@ class Borne: bornes = [] @staticmethod def MajBornes(): - pass + print(Borne.bornes) + for b in Borne.bornes: + b.MajBorne() + + def MajBorne(self): + self.__ui.lcdNumber.display(self.__parking.nbPlacesLibresParking) def __init__(self, main, parking): self.__parking = parking @@ -41,6 +46,7 @@ class Borne: self.__ui.btn_recuperer.clicked.connect(self.recuperer) + # Validator @@ -50,6 +56,8 @@ class Borne: self.nonVoiture() self.showWindow() self.__ui.nomParking.setText("Borne " + str(len(self.bornes)+1) + " - Parking : " +parking.nom) + Borne.bornes.append(self) + Borne.MajBornes() def blockAll(self): @@ -84,6 +92,7 @@ class Borne: self.__ui.lineEdit_id.setText("") self.__ui.numeroTicketLineEdit.setText("") self.__ui.labIdClient.setText("Non identifier") + Borne.MajBornes() def newVoiture(self): """ @@ -105,13 +114,13 @@ class Borne: :return: """ try : - self.__c = Client.get(self.__ui.lineEdit_id.text()) + self.__c = Client(self.__ui.lineEdit_id.text()) self.__ui.label_aff.setText("Bonjour " + str(self.__c.nom) + " " + str(self.__c.prenom)) self.__ui.labIdClient.setText("Vous étes identifier") self.__ui.box_id.setDisabled(True) self.__ui.box_service.setDisabled(False) self.__ui.btn_desabo.setDisabled(False) - except IndexError : + except Exception : self.__ui.label_aff.setText("Echec identification") self.__ui.labIdClient.setText("Non identifier") @@ -139,7 +148,6 @@ class Borne: str(self.__ui.prenomLineEdit.text()), "", TypeAbonnement.ABONNE) - print(self.__c) self.__ui.label_aff.setText("Votre id membre est : " + self.__c.id) self.__ui.lineEdit_id.setText(self.__c.id) self.identification() @@ -153,25 +161,25 @@ class Borne: if self.__c is None: p = self.__parking.recherchePlace(self.__v_actuel) if p is not None: - id = Teleporteur.teleporterVoiture(self.__v_actuel, p) + placement = Teleporteur.teleporterVoiture(self.__v_actuel, p) else: if self.__c.abonnement != TypeAbonnement.SUPER_ABONNE: p = self.__parking.recherchePlace(self.__v_actuel) if p is not None : - id = Teleporteur.teleporterVoiture(self.__v_actuel, p) + placement = Teleporteur.teleporterVoiture(self.__v_actuel, p) if self.__ui.checkBox_Livraison_2.isChecked(): - Service(None, self.__c, p, TypeService.LIVRAISON) + Service(None, self.__c, placement, TypeService.LIVRAISON) if self.__ui.checkBox_Entretien_2.isChecked(): - Service(None, self.__c, p, TypeService.ENTRETIEN) + Service(None, self.__c, placement, TypeService.ENTRETIEN) if self.__ui.checkBox_Maintenance_2.isChecked(): - Service(None, self.__c, p, TypeService.MAINTENANCE) + Service(None, self.__c, placement, TypeService.MAINTENANCE) else: - Teleporteur.teleporterVoitureSuperAbonne(self.__v_actuel) - if id is not None: + placement = Teleporteur.teleporterVoitureSuperAbonne(self.__v_actuel, self.__parking) + if placement is not None: self.nonVoiture() - self.ticketDepot(id) + self.ticketDepot(placement.id) else: - self.__ui.label_aff.setText("Aucune Place Disponible Pour Votre Véhicule. Devenez Super Abonné!") + self.__ui.label_aff.setText("Aucune Place Correspondante. Devenez Super Abonné!") def recuperer(self): diff --git a/src/c/Main.py b/src/c/Main.py index a8b454e..6958db5 100644 --- a/src/c/Main.py +++ b/src/c/Main.py @@ -98,15 +98,19 @@ class Main: self.__ui.btn_borne.setDisabled(True) #onglet Service - for s in Service.serviceEnCours: - if s.typeService == TypeService.LIVRAISON : - self.__ui.comboBox_livraison.addItem(str(s.id)) - if s.typeService == TypeService.ENTRETIEN : - self.__ui.comboBox_entretien.addItem(str(s.id)) - if s.typeService == TypeService.MAINTENANCE : - self.__ui.comboBox_maintenance.addItem(str(s.id)) + self.__ui.comboBox_livraison.clear() + self.__ui.comboBox_entretien.clear() + self.__ui.comboBox_maintenance.clear() + if self.__ui.comboBox.count() > 1: + for s in Service.getAllEnCours(p[self.__ui.comboBox.currentIndex() - 1]): + if s.typeService == TypeService.LIVRAISON : + self.__ui.comboBox_livraison.addItem(str(s.id)) + if s.typeService == TypeService.ENTRETIEN : + self.__ui.comboBox_entretien.addItem(str(s.id)) + if s.typeService == TypeService.MAINTENANCE : + self.__ui.comboBox_maintenance.addItem(str(s.id)) - #Onglet Stats + #Onglet Stats def creerParking(self): @@ -136,8 +140,8 @@ class Main: def afficherBornes(self): if self.__ui.comboBox.currentIndex() != 0: self.__view.hide() - Borne.bornes.append(Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1])) - Borne.bornes.append(Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1])) + Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1]) + Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1]) def nouveau(self): result = QtGui.QMessageBox.question(self.__view, diff --git a/src/c/Teleporteur.py b/src/c/Teleporteur.py index e042462..823aee0 100644 --- a/src/c/Teleporteur.py +++ b/src/c/Teleporteur.py @@ -8,13 +8,13 @@ class Teleporteur: def teleporterVoiture(voiture, place): p = Placement(None,voiture, place) place.prendre() - return p.id + return p @staticmethod def teleporterVoitureSuperAbonne(voiture, parking): - place = parking.addPlaceSuperAbo() + place = parking.addPlaceSuperAbo(parking) p = Placement(None, voiture, place) - return p.id + return p @staticmethod def teleporterVersSortie(placement): diff --git a/src/c/log/log.py b/src/c/log/log.py index faf7104..3a1a8a8 100644 --- a/src/c/log/log.py +++ b/src/c/log/log.py @@ -1,5 +1,3 @@ -__author__ = 'sidya' - import logging from logging.handlers import RotatingFileHandler @@ -50,7 +48,6 @@ class Log(object): """ Log Manager """ - def __init__(self): """ Define 3 differents log : diff --git a/src/m/Client.py b/src/m/Client.py index e9d7c73..a82a0bd 100644 --- a/src/m/Client.py +++ b/src/m/Client.py @@ -6,7 +6,7 @@ from src.m.connexionBDD import connexionBDD __author__ = 'sidya' class Client: - def __init__(self,id, nom, prenom, adresse, typeAbonnement): + def __init__(self,id, nom=None, prenom=None, adresse=None, typeAbonnement=None): if id is None: self.__nom = nom self.__prenom = prenom diff --git a/src/m/Parking.py b/src/m/Parking.py index e8ea595..46615aa 100644 --- a/src/m/Parking.py +++ b/src/m/Parking.py @@ -3,6 +3,11 @@ import string import time from src.m.Voiture import Voiture from src.m.connexionBDD import connexionBDD +import random +import string +import time +from src.m.Voiture import Voiture +from src.m.connexionBDD import connexionBDD __author__ = 'sidya' @@ -101,10 +106,14 @@ class Place: self.__niveau = niveau self.__estLibre = estLibre self.__estSuperAbo = estSuperAbo + if self.__typePlace is None: + t = "NULL" + else : + t = self.__typePlace.id c = connexionBDD() c.execute("INSERT INTO place (idParking, idTypePlace, numero, estLibre, estSuperAbo) " "VALUES (?,?,?,?,?)", - (self.__parking.id, self.__typePlace.id, + (self.__parking.id, t, self.__numero, int(self.__estLibre), int(self.__estSuperAbo))) self.__id = c.lastId() c.seDeconnecter() @@ -289,7 +298,7 @@ class Placement: id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(random.randint(1, 10))) try: - Placement.get(id) + Placement(id) except IndexError: break c = connexionBDD() @@ -304,8 +313,8 @@ class Placement: if row is None : raise IndexError("Invalid id") c.seDeconnecter() - self.__voiture = row["voiture"] - self.__place = row["place"] + self.__voiture = Voiture(row["idVoiture"]) + self.__place = Place(row["idPlace"]) self.__id = id self.__debut = debut self.__fin = fin diff --git a/src/m/Service.py b/src/m/Service.py index fdf90cf..4cde15b 100644 --- a/src/m/Service.py +++ b/src/m/Service.py @@ -1,5 +1,5 @@ import time -from src.m import Client +from src.m.Client import Client from src.m.Parking import Placement from src.m.connexionBDD import connexionBDD @@ -9,15 +9,16 @@ class Service: @staticmethod def getAllEnCours(parking): c = connexionBDD() - r = c.execute("SELECT * FROM service WHERE dateRealisation = NULL " - "AND idPlacement = (SELECT idPlacement FORM PLACEMENT WHERE " - "idPlace = (SELECT idPlace FROM Place WHERE idParking '"+str(parking.id)+"'))") + r = c.execute("SELECT * FROM service WHERE dateRealisation is NULL " + "AND idPlacement IN (SELECT idPlacement FROM PLACEMENT WHERE " + "idPlace IN (SELECT idPlace FROM Place WHERE idParking = '"+str(parking.id)+"'))") rows = r.fetchall() c.seDeconnecter() l =[] for row in rows: - l.append(Service(row["idService"], Client.get(row["idClient"]), Placement.get(row["idPlacement"]), + l.append(Service(row["idService"], Client(row["idClient"]), Placement(row["idPlacement"]), row["typeService"], row["dateDemande"], row["dateService"], row["dateRealisation"])) + print("l = " + str(l)) return l def __init__(self, id, client= None, placement= None, typeService= None, @@ -42,8 +43,8 @@ class Service: raise IndexError("Invalid id") c.seDeconnecter() self.__id = id - self.__client = row["client"] - self.__placement = row["placement"] + self.__client = Client(row["idClient"]) + self.__placement = Placement(row["idPlacement"]) self.__typeService = row["typeService"] self.__dateDemande = row["dateDemande"] self.__dateService = row["dateService"] diff --git a/src/m/table.sql b/src/m/table.sql index f77882c..d12ca92 100644 --- a/src/m/table.sql +++ b/src/m/table.sql @@ -70,8 +70,8 @@ CREATE TABLE service ( idPlacement VARCHAR(10), typeService INTEGER, dateDemande TIMESTAMP, - dateService TIMESTAMP, - dateRealisation TIMESTAMP + dateService TIMESTAMP DEFAULT NULL, + dateRealisation TIMESTAMP DEFAULT NULL, FOREIGN KEY (idClient) REFERENCES client(idClient), FOREIGN KEY (idPlacement) REFERENCES placement(idPlacement) ); \ No newline at end of file diff --git a/src/v/MyQMainWindow.py b/src/v/MyQMainWindow.py index c1c4427..1b278bc 100644 --- a/src/v/MyQMainWindow.py +++ b/src/v/MyQMainWindow.py @@ -7,10 +7,8 @@ class MyQMainWindow(QtGui.QMainWindow): def closeEvent(self, event): result = QtGui.QMessageBox.question(self, "Confirmer Fermeture...", - "Etes vous sur de vouloir quitter ?\n" - "(Toute modification non enregistrée seras perdu)", + "Etes vous sur de vouloir quitter ?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) event.ignore() - if result == QtGui.QMessageBox.Yes: event.accept() \ No newline at end of file