def __init__(self): self.user = User() self.myTickets = MyTickets() self.cinema = Cinema() self.film = Film() self.time = Time() self.place = Place() self.db = DB()
def getListTime(self, cinemaID, filmID): self.listTime = [] db = DB() for db in DB().select("Times", "*", "cinema_id="+str(cinemaID)+" AND film_id="+str(filmID)): arr = {} arr["id"] = db[0] arr['time'] = db[3] arr['price'] = db[4] self.listTime.append(arr)
def getListFilm(self): self.listFilm = [] for db in DB().select("Films", "*"): arr = [] arr.append(db[0]) arr.append(db[1]) self.listFilm.append(arr)
def getListPlaces(self, timeID): self.listPlace = [] for db in DB().select("Halls", "*", "time_id=" + str(timeID)): arr = {} arr["id"] = db[0] arr['place'] = db[2] arr['status'] = db[3] self.listPlace.append(arr)
class User: def __init__(self): self.id = None self.login = None self.password = None self.name = None self.db = DB() def checkUser(self, login, password): user = None try: user = self.db.select("Users", "*", "login='******';") except: return False if user: if user[0][1]==login and user[0][2]==password: self.id = int(user[0][0]) self.name = user[0][3] self.surname = user[0][4] self.login = user[0][1] self.password = user[0][2] return True return False def createUser(self, login, password, name, surname): user = None try: user = self.db.select("Users", "*", "login='******';") except: pass if user: return False user = self.db.select("Users", "*") if user: self.id = int(user[len(user)-1][0])+1 else: self.id = 1 self.name = name self.login = login self.password = password self.surname = surname self.db.insertUser(self.id, login, password, name, surname) return True
class Model: def __init__(self): self.user = User() self.myTickets = MyTickets() self.cinema = Cinema() self.film = Film() self.time = Time() self.place = Place() self.db = DB() def setCinemaAndFilm(self, cinema, film): self.cinema.setCinema(cinema[0], cinema[1]) self.film.setFilm(film[0], film[1]) self.time.getListTime(cinema[0], film[0]) def setTime(self, time): self.time.setTime(time) self.place.getListPlaces(time['id']) def saveTicket(self, place): self.place.setPlace(place) totalPrice = self.time.price * len(self.place.place) self.db.insertTicket(self.user.id, self.cinema.name, self.film.name, self.time.time, self.place.place, self.time.price, totalPrice)
def setPlace(self, place): self.place = place for item in self.listPlace: if item['place'] in place: DB().change("Halls", "status=1", "id=" + str(item['id']))
def __init__(self): self.id = None self.login = None self.password = None self.name = None self.db = DB()
def getListCinema(self): self.listCinema = [] db = DB() data = db.select('Cinemas', ['id', 'name']) for item in data: self.listCinema.append(item)