This commit is contained in:
sidya82
2015-02-04 15:33:15 +01:00
parent 952b215c0c
commit 2a1099c450
9 changed files with 63 additions and 46 deletions

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -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)
);