예제 #1
0
class OpenCheapApp(QtWidgets.QMainWindow, cheap_form.Ui_MainWindow):
    def __init__(self, db):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open_cheap)
        self.db = db
        self.table_cheap = None

        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()

    def open_cheap(self):
        spinBox = self.spinBox.text()
        money = spinBox if spinBox else None
        if not money:
            self.msg.setText("Введите максимульную цену.")
            self.msg.show()
        else:
            res, names = self.db.get_cheap_session(money)
            if res:
                self.table_cheap = Table(
                    res, names, table_title="Самое дешевое на этой неделе")
                self.table_cheap.show()
            else:
                if self.table_cheap:
                    self.table_cheap.close()
                self.msg.setText("Нет подходящих кинотеатров.")
                self.msg.show()
예제 #2
0
class OpenDescFilmApp(QtWidgets.QMainWindow, film_desc.Ui_MainWindow):
    def __init__(self, db):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open_table)
        self.db = db
        self.table_film = None

        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()

    def open_table(self):
        decsript = self.decsript.text()
        decsript = decsript if decsript else None
        if not decsript:
            self.msg.setText("Введите ключевую фразу.")
            self.msg.show()
        else:
            res, names = self.db.get_desc_film(decsript)
            if res:
                self.table_film = Table(res,
                                        names,
                                        table_title="Таблица фильмов")
                self.table_film.show()
            else:
                if self.table_film:
                    self.table_film.close()
                self.msg.setText("Нет фильмов для указанной ключевой фразы.")
                self.msg.show()
예제 #3
0
class OpenFilmGenreApp(QtWidgets.QMainWindow, film_genre.Ui_MainWindow):
    def __init__(self, db):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open_table)
        self.db = db
        self.table_film = None

        allgenre, _ = self.db.get_all_genre1()
        genre_text = []
        for c in allgenre:
            genre_text.append(c[1])
        self.genre.clear()
        self.genre.addItems(genre_text)
        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()

    def open_table(self):
        genre = self.genre.currentText()
        genre = genre if genre else None
        if not genre:
            self.msg.setText("Выберите жанр.")
            self.msg.show()
        else:
            res, names = self.db.get_genre_film2(genre)
            if res:
                self.table_film = Table(res,
                                        names,
                                        table_title="Таблица фильмов")
                self.table_film.show()
            else:
                if self.table_film:
                    self.table_film.close()
                self.msg.setText("Нет фильмов для выбранного жанра.")
                self.msg.show()
class MainApp(QtWidgets.QMainWindow, main.Ui_MainWindow):
    def __init__(self, db):
        super().__init__()
        self.setupUi(self)

        self.add_film_btn.clicked.connect(self.fadd_film)
        self.add_genre_btn.clicked.connect(self.fadd_genre)
        self.add_producer_btn.clicked.connect(self.fadd_producer)
        self.add_restrict_btn.clicked.connect(self.fadd_restrict)
        self.add_typesess_btn.clicked.connect(self.fadd_typesess)
        self.add_cinema_btn.clicked.connect(self.fadd_cinema)
        self.add_typehall_btn.clicked.connect(self.fadd_typehall)
        self.add_hall_btn.clicked.connect(self.fadd_hall)
        self.add_session_btn.clicked.connect(self.fadd_session)

        self.open_film_btn.clicked.connect(self.fopen_film)
        self.open_genre_btn.clicked.connect(self.fopen_genre)
        self.open_producer_btn.clicked.connect(self.fopen_producer)
        self.open_restrict_btn.clicked.connect(self.fopen_restrict)
        self.open_typesess_btn.clicked.connect(self.fopen_typesess)
        self.open_cinema_btn.clicked.connect(self.fopen_cinema)
        self.open_typehall_btn.clicked.connect(self.fopen_typehall)
        self.open_hall_btn.clicked.connect(self.fopen_hall)
        self.open_session_btn.clicked.connect(self.fopen_session)
        self.money_btn.clicked.connect(self.fopen_money)
        self.db = db
        self.table_film = None
        self.table_genre = None
        self.table_genre2 = None
        self.table_producer = None
        self.table_restrict = None
        self.table_typesess = None
        self.table_cinema = None
        self.table_typehall = None
        self.table_hall = None
        self.table_filmsess = None
        self.table_session = None
        self.table_session1 = None
        self.table_money = None
        self.OpenGenre = None
        self.OpenProducer = None
        self.OpenRestrict = None
        self.OpenFilm = None
        self.OpenTypesess = None
        self.OpenCinema = None
        self.OpenTypehall = None
        self.OpenHall = None
        self.OpenSession = None

        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setText("Не удалось выполнить операцию.")
        self.msg.setWindowTitle("Сообщение об ошибке")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()

    def delete_film(self, id_):
        if self.db.number_film_session(id_) > 0:
            self.msg.setText(
                "В удалении отказано. На указанный фильм уже созданы сеансы.")
            self.msg.show()
        else:
            try:
                self.db.delete_old_session()
                self.db.delete_one_film(id_)
                self.fopen_film()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()

    def delete_genre(self, id_):
        try:
            self.db.delete_one_genre(id_)
            self.fopen_genre()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()

    def delete_producer(self, id_):
        try:
            self.db.delete_one_producer(id_)
            self.fopen_producer()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()

    def delete_restrict(self, id_):
        try:
            self.db.delete_one_restrict(id_)
            self.fopen_restrict()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()

    def delete_typesess(self, id_):
        try:
            self.db.delete_one_typesess(id_)
            self.fopen_typesess()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()

    def delete_cinema(self, id_):
        if self.db.number_cinemasession(id_) > 0:
            self.msg.setText(
                "В удалении отказано. На указанный кинотеатр уже созданы сеансы."
            )
            self.msg.show()
        else:
            try:
                self.db.delete_old_session()
                self.db.delete_one_cinema(id_)
                self.fopen_cinema()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()

    def delete_typehall(self, id_):
        try:
            self.db.delete_one_typehall(id_)
            self.fopen_typehall()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()

    def delete_hall(self, id_):
        if self.db.number_hallsession(id_) > 0:
            self.msg.setText(
                "В удалении отказано. На указанный зал уже созданы сеансы.")
            self.msg.show()
        else:
            try:
                self.db.delete_old_session()
                self.db.delete_one_hall(id_)
                self.fopen_hall()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()

    def delete_session(self, id_):
        if self.db.number_bue_session(id_) > 0:
            self.msg.setText(
                "Сеанс не может быть удален. На него уже куплены билеты.")
            self.msg.show()
        else:
            try:
                self.db.delete_one_session(id_)
                self.fopen_session()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()

    def change_film(self, id_):
        try:
            self.db.delete_old_session()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()
        data = self.db.get_one_film(id_)
        self.OpenFilm = AddFilmApp(self.db, data, on_close=self.fopen_film)
        self.OpenFilm.show()

    def change_genre(self, id_):
        data = self.db.get_one_genre(id_)
        self.OpenGenre = AddGenreApp(self.db, data, on_close=self.fopen_genre)
        self.OpenGenre.show()

    def change_producer(self, id_):
        data = self.db.get_one_producer(id_)
        self.OpenProducer = AddProducerApp(self.db,
                                           data,
                                           on_close=self.fopen_producer)
        self.OpenProducer.show()

    def change_restrict(self, id_):
        data = self.db.get_one_restrict(id_)
        self.OpenRestrict = AddRestrictApp(self.db,
                                           data,
                                           on_close=self.fopen_restrict)
        self.OpenRestrict.show()

    def change_typesess(self, id_):
        data = self.db.get_one_typesess(id_)
        self.OpenTypesess = AddTypesessApp(self.db,
                                           data,
                                           on_close=self.fopen_typesess)
        self.OpenTypesess.show()

    def change_cinema(self, id_):
        data = self.db.get_one_cinema(id_)
        self.OpenCinema = AddCinemaApp(self.db,
                                       data,
                                       on_close=self.fopen_cinema)
        self.OpenCinema.show()

    def change_typehall(self, id_):
        data = self.db.get_one_typehall(id_)
        self.OpenTypehall = AddTypehallApp(self.db,
                                           data,
                                           on_close=self.fopen_typehall)
        self.OpenTypehall.show()

    def change_hall(self, id_):
        try:
            self.db.delete_old_session()
        except DBException as e:
            text, *_ = e.args
            self.msg.setText(text)
            self.msg.show()
        data = self.db.get_one_hall(id_)
        self.OpenHall = AddHallApp(self.db, data, on_close=self.fopen_hall)
        self.OpenHall.show()

    def change_session(self, id_):
        if self.db.session_is_now(id_):
            self.msg.setText("Сеанс уже идет, он не может быть изменен.")
            self.msg.show()
        else:
            data = self.db.get_one_session(id_)
            self.OpenSession = AddSessionApp(self.db,
                                             data=data,
                                             film=data[-1],
                                             on_close=self.fopen_session)
            self.OpenSession.show()

    def fopen_film(self):
        res, names = self.db.get_all_film()
        if res:
            self.table_film = Table(res, names, self.change_film, "Обновить",
                                    self.delete_film, "Удалить",
                                    "Таблица фильмов", self.ffopen_genre,
                                    "Жанры")
            self.table_film.show()
        else:
            if self.table_film:
                self.table_film.close()
            self.msg.setText("Нет фильмов для просмотра.")
            self.msg.show()

    def fopen_money(self):
        res, names = self.db.get_money()
        if res:
            self.table_money = Table(
                res,
                names,
                table_title="Ожидаемая выручка за предстоящую неделю")
            self.table_money.show()
        else:
            if self.table_money:
                self.table_money.close()
            self.msg.setText("Нет данных для расчета выручки.")
            self.msg.show()

    def ffopen_genre(self, idfilm):
        res, names = self.db.get_genre_film(idfilm)
        if res:
            self.table_genre2 = Table(res, names, table_title="Жанры фильма")
            self.table_genre2.show()
        else:
            if self.table_genre2:
                self.table_genre2.close()
            self.msg.setText("У фильма нет жанров.")
            self.msg.show()

    def fopen_genre(self):
        res, names = self.db.get_all_genre()
        if res:
            self.table_genre = Table(res, names, self.change_genre, "Обновить",
                                     self.delete_genre, "Удалить",
                                     "Таблица жанров")
            self.table_genre.show()
        else:
            if self.table_genre:
                self.table_genre.close()
            self.msg.setText("Нет жанров для просмотра.")
            self.msg.show()

    def fopen_producer(self):
        res, names = self.db.get_all_producer()
        if res:
            self.table_producer = Table(res, names, self.change_producer,
                                        "Обновить", self.delete_producer,
                                        "Удалить", "Таблица режиссеров")
            self.table_producer.show()
        else:
            if self.table_producer:
                self.table_producer.close()
            self.msg.setText("Нет режиссеров для просмотра.")
            self.msg.show()

    def fopen_restrict(self):
        res, names = self.db.get_all_restrict()
        if res:
            self.table_restrict = Table(res, names, self.change_restrict,
                                        "Обновить", self.delete_restrict,
                                        "Удалить", "Таблица ограничений")
            self.table_restrict.show()
        else:
            if self.table_restrict:
                self.table_restrict.close()
            self.msg.setText("Нет ограничений для просмотра.")
            self.msg.show()

    def fopen_typesess(self):
        res, names = self.db.get_all_typesess()
        if res:
            self.table_typesess = Table(res, names, self.change_typesess,
                                        "Обновить", self.delete_typesess,
                                        "Удалить", "Таблица типов сеансов")
            self.table_typesess.show()
        else:
            if self.table_typesess:
                self.table_typesess.close()
            self.msg.setText("Нет типов сеансов для просмотра.")
            self.msg.show()

    def fopen_cinema(self):
        res, names = self.db.get_all_cinema()
        if res:
            self.table_cinema = Table(res, names, self.change_cinema,
                                      "Обновить", self.delete_cinema,
                                      "Удалить", "Таблица кинотеатров")
            self.table_cinema.show()
        else:
            if self.table_cinema:
                self.table_cinema.close()
            self.msg.setText("Нет кинотеатров для просмотра.")
            self.msg.show()

    def fopen_typehall(self):
        res, names = self.db.get_all_typehall()
        if res:
            self.table_typehall = Table(res, names, self.change_typehall,
                                        "Обновить", self.delete_typehall,
                                        "Удалить", "Таблица типов залов")
            self.table_typehall.show()
        else:
            if self.table_typehall:
                self.table_typehall.close()
            self.msg.setText("Нет типов залов для просмотра.")
            self.msg.show()

    def fopen_hall(self):
        res, names = self.db.get_all_hall()
        if res:
            self.table_hall = Table(res, names, self.change_hall, "Обновить",
                                    self.delete_hall, "Удалить",
                                    "Таблица залов")
            self.table_hall.show()
        else:
            if self.table_hall:
                self.table_hall.close()
            self.msg.setText("Нет залов для просмотра.")
            self.msg.show()

    def fopen_session(self):
        self.db.delete_old_session()
        res, names = self.db.get_all_session()
        if res:
            self.table_session1 = Table(res,
                                        names,
                                        button_edit=self.change_session,
                                        button_edit_text="Обновить",
                                        button_delete=self.delete_session,
                                        button_delete_text="Удалить",
                                        table_title="Таблица сеансов",
                                        button_new=self.fopen_buyers,
                                        button_new_text="Покупки")
            self.table_session1.show()
        else:
            if self.table_session1:
                self.table_session1.close()
            self.msg.setText("Нет сеансов для просмотра.")
            self.msg.show()

    def fopen_buyers(self, idsess):
        res, names = self.db.get_session_buyers(idsess)
        if res:
            self.table_session = Table(res,
                                       names,
                                       table_title="Таблица покупок")
            self.table_session.show()
        else:
            if self.table_session:
                self.table_session.close()
            self.msg.setText("На данный сеанс нет купленных билетов.")
            self.msg.show()

    def fadd_film(self):
        self.OpenFilm = AddFilmApp(self.db, on_close=self.fopen_film)
        self.OpenFilm.show()

    def fadd_genre(self):
        self.OpenGenre = AddGenreApp(self.db, on_close=self.fopen_genre)
        self.OpenGenre.show()

    def fadd_producer(self):
        self.OpenProducer = AddProducerApp(self.db,
                                           on_close=self.fopen_producer)
        self.OpenProducer.show()

    def fadd_restrict(self):
        self.OpenRestrict = AddRestrictApp(self.db,
                                           on_close=self.fopen_restrict)
        self.OpenRestrict.show()

    def fadd_typesess(self):
        self.OpenTypesess = AddTypesessApp(self.db,
                                           on_close=self.fopen_typesess)
        self.OpenTypesess.show()

    def fadd_cinema(self):
        self.OpenCinema = AddCinemaApp(self.db, on_close=self.fopen_cinema)
        self.OpenCinema.show()

    def fadd_typehall(self):
        self.OpenTypehall = AddTypehallApp(self.db,
                                           on_close=self.fopen_typehall)
        self.OpenTypehall.show()

    def fadd_hall(self):
        self.OpenHall = AddHallApp(self.db, on_close=self.fopen_hall)
        self.OpenHall.show()

    def fadd_session(self):
        res, names = self.db.get_all_film()
        if res:
            self.table_filmsess = Table(res,
                                        names,
                                        self.add_session_form,
                                        "Задать сеанс",
                                        table_title="Таблица фильмов")
            self.table_filmsess.show()
        else:
            if self.table_filmsess:
                self.table_filmsess.close()
            self.msg.setText("Нет фильмов для назначения сеанса.")
            self.msg.show()

    def add_session_form(self, film):
        self.OpenSession = AddSessionApp(db=self.db,
                                         film=film,
                                         on_close=self.fopen_session)
        self.OpenSession.show()
        self.table_filmsess.close()
예제 #5
0
class LKApp(QtWidgets.QMainWindow, lk_form.Ui_MainWindow):
    def __init__(self, db, uid):
        super().__init__()
        self.setupUi(self)
        self.db = db
        self.uid = uid
        self.name = self.db.get_user_name_by_id(uid)
        self.label.setText(f'Приветствуем Вас, {self.name}')
        self.cinema_btn.clicked.connect(self.buy_bycinema)
        self.cinema2_btn.clicked.connect(self.open_cinema)
        self.film_btn.clicked.connect(self.buy_onfilm)
        self.tickets.clicked.connect(self.show_tickets)
        self.filmgenre_btn.clicked.connect(self.open_filmgenre)
        self.filmdesc_btn.clicked.connect(self.open_descfilm)
        self.variety_btn.clicked.connect(self.open_variety)
        self.cheap_btn.clicked.connect(self.open_cheap)

        self.OpenBuyCinema = None
        self.OpenDate = None
        self.OpenFilmGenre = None
        self.OpenDescFilm = None
        self.OpenCheap = None
        self.table_film = None
        self.table_tickets = None
        self.table_buy = None
        self.table_genre = None
        self.table_variety = None

        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setText("Не удалось выполнить операцию.")
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()

    def open_cinema(self):
        self.db.delete_old_session()
        res, names = self.db.get_all_cinema2()
        if res:
            self.table_cinema = Table(res,
                                      names,
                                      table_title="Таблица кинотеатров")
            self.table_cinema.show()
        else:
            if self.table_cinema:
                self.table_cinema.close()
            self.msg.setText("У нас пока нет кинотеатров.")
            self.msg.show()

    def open_variety(self):
        self.db.delete_old_session()
        res, names = self.db.get_variety()
        if res:
            self.table_variety = Table(
                res, names, table_title="Информация на ближайшую неделю")
            self.table_variety.show()
        else:
            if self.table_variety:
                self.table_variety.close()
            self.msg.setText("У нас пока нет сеансов.")
            self.msg.show()

    def show_tickets(self):
        self.db.delete_old_session()
        res, names = self.db.get_user_tikets(self.uid)
        if res:
            self.table_buy = Table(res, names, table_title="Таблица покупок")
            self.table_buy.show()
        else:
            if self.table_buy:
                self.table_buy.close()
            self.msg.setText("У Вас еще нет покупок.")
            self.msg.show()

    def buy_onfilm(self):
        self.db.delete_old_session()
        res, names = self.db.get_allsession_film()
        if res:
            self.table_film = Table(res,
                                    names,
                                    self.open_genre,
                                    "Жанры",
                                    self.open_date,
                                    "Выбрать",
                                    table_title="Таблица фильмов")
            self.table_film.show()
        else:
            if self.table_film:
                self.table_film.close()
            self.msg.setText("Нет фильмов для просмотра.")
            self.msg.show()

    def open_genre(self, idfilm):
        res, names = self.db.get_genre_film(idfilm)
        if res:
            self.table_genre = Table(res, names, table_title="Жанры фильма")
            self.table_genre.show()
        else:
            if self.table_genre:
                self.table_genre.close()
            self.msg.setText("У фильма нет жанров.")
            self.msg.show()

    def open_date(self, idfilm):
        self.db.delete_old_session()
        if not len(self.db.get_all_session()[0]):
            self.msg.setText("Нет сеансов для просмотра.")
            self.msg.show()
        else:
            self.OpenDate = OpenDateApp(self.db, self.uid, idfilm)
            self.OpenDate.show()

    def open_cheap(self):
        self.db.delete_old_session()
        if not len(self.db.get_all_session()[0]):
            self.msg.setText("На этой неделе нет сеансов.")
            self.msg.show()
        else:
            self.OpenCheap = OpenCheapApp(self.db)
            self.OpenCheap.show()

    def buy_bycinema(self):
        self.db.delete_old_session()
        if not len(self.db.get_all_session()[0]):
            self.msg.setText("Нет сеансов для просмотра.")
            self.msg.show()
        else:
            self.OpenBuyCinema = OpenBuyCinemaApp(self.db, self.uid)
            self.OpenBuyCinema.show()

    def open_filmgenre(self):
        self.db.delete_old_session()
        if not len(self.db.get_all_film()[0]):
            self.msg.setText("Нет фильмов для подбора.")
            self.msg.show()
        else:
            self.OpenFilmGenre = OpenFilmGenreApp(self.db)
            self.OpenFilmGenre.show()

    def open_descfilm(self):
        self.db.delete_old_session()
        if not len(self.db.get_all_film()[0]):
            self.msg.setText("Нет фильмов для подбора.")
            self.msg.show()
        else:
            self.OpenDescFilm = OpenDescFilmApp(self.db)
            self.OpenDescFilm.show()
예제 #6
0
class OpenDateApp(QtWidgets.QMainWindow, day_form.Ui_MainWindow):
    def __init__(self, db, uid, idfilm):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open_cinema_session)
        self.db = db
        self.uid = uid
        self.idfilm = idfilm
        self.table_places = None
        self.table_session1 = None

        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()
        self.open_cinema_session()

    def open_cinema_session(self):
        date = self.date.selectedDate().toString('yyyy-MM-dd')
        if not date:
            self.msg.setText("Выберите дату.")
            self.msg.show()
        else:
            self.db.delete_old_session()
            res, names = self.db.get_all_session_byfilmtime(self.idfilm, date)
            if res:
                self.table_session1 = Table(res,
                                            names,
                                            button_edit=self.buy_form,
                                            button_edit_text="Выбрать места",
                                            table_title="Выбор сеансов")
                self.table_session1.show()
            else:
                if self.table_session1:
                    self.table_session1.close()
                self.msg.setText(
                    "На указанную дату нет сеансов выбранного фильма.")
                self.msg.show()

    def buy_form(self, idsess):
        self.idsess = idsess
        row, col = self.db.get_session_rowcol(idsess)
        res = self.db.get_sessionplaces(idsess)
        self.table_places = PlacesTable(row, col, res, self.message)
        self.table_places.show()

    def message(self, places):
        if not len(places):
            self.msg.setText('Выберите места.')
            self.msg.show()
        else:
            self.table_places.close()
            try:
                self.db.buy_places(self.idsess, places, self.uid)
                self.msg.setText(
                    "Билеты успешно забронированы. Счет на оплату поступит на Вашу почту."
                )
                self.msg.show()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()
예제 #7
0
class OpenBuyCinemaApp(QtWidgets.QMainWindow, buy_on_cinema.Ui_MainWindow):
    def __init__(self, db, uid):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open_cinema_session)
        self.db = db
        self.uid = uid
        self.table_session1 = None
        self.table_places = None

        allcinema, _ = self.db.get_all_cinema()
        cinema_text = []
        for c in allcinema:
            cinema_text.append(c[2])
        self.cinema.clear()
        self.cinema.addItems(cinema_text)
        self.msg = QtWidgets.QMessageBox()
        self.msg.setIcon(QtWidgets.QMessageBox.Information)
        self.msg.setWindowTitle("Информирование")
        self.msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        self.msg.buttonClicked.connect(self.ok)

    def ok(self):
        self.msg.close()
        self.open_cinema_session()

    def open_cinema_session(self):
        cinema = self.cinema.currentText()
        cinema = cinema if cinema else None
        date = self.date.text()
        if not cinema:
            self.msg.setText("Выберите кинотеатр.")
            self.msg.show()
        elif not date:
            self.msg.setText("Выберите дату.")
            self.msg.show()
        else:
            self.db.delete_old_session()
            res, names = self.db.get_all_session_bycinematime(cinema, date)
            if res:
                self.table_session1 = Table(res,
                                            names,
                                            button_edit=self.buy_form,
                                            button_edit_text="Выбрать места",
                                            table_title="Выбор сеансов")
                self.table_session1.show()
            else:
                if self.table_session1:
                    self.table_session1.close()
                self.msg.setText(
                    "В указанном кинотеатре нет сеансов на выбранную дату.")
                self.msg.show()

    def buy_form(self, idsess):
        self.idsess = idsess
        row, col = self.db.get_session_rowcol(idsess)
        res = self.db.get_sessionplaces(idsess)
        self.table_places = PlacesTable(row, col, res, self.message)
        self.table_places.show()

    def message(self, places):
        if not len(places):
            self.msg.setText('Выберите места.')
            self.msg.show()
        else:
            self.table_places.close()
            try:
                self.db.buy_places(self.idsess, places, self.uid)
                self.msg.setText(
                    "Билеты успешно забронированы. Счет на оплату поступит на Вашу почту."
                )
                self.msg.show()
            except DBException as e:
                text, *_ = e.args
                self.msg.setText(text)
                self.msg.show()