def remove(self, date_time: datetime, movie_hall_name: str, movie_title: str):
     movie_title_id, *_ = super().get_by_field('movie', FieldPair('title', movie_title))
     movie_hall_id, *_ = super().get_by_field('movie_hall', FieldPair('name', movie_hall_name))
     date, time = date_time.strftime('%d.%m.%Y'), date_time.strftime('%H:%M')
     request = """
         DELETE FROM session
         WHERE date = ?
         AND time = ?
         AND movie_title_id = ?
         AND movie_hall_id = ?
     """
     self.data_base.execute(request, (date, time, movie_title_id, movie_hall_id))
Пример #2
0
 def add(self, first_name: str, last_name: str, login: str, password: str,
         role: str):
     role_id, _ = super().get_by_field('role', FieldPair('name', role))
     request = """
         INSERT INTO user (first_name, last_name, login, password, role_id) VALUES(?, ?, ?, ?, ?)
     """
     self.data_base.execute(
         request, (first_name, last_name, login, password, role_id))
Пример #3
0
 def delete_movie(self):
     title = self.delete_movie_cbox.currentText()
     movie_id, *_ = self.app_db.movie.get_by_field(
         'movie', FieldPair('title', title))
     movie_title_ids = [
         session[0] for session in self.app_db.session.get_all('session')
     ]
     if movie_id not in movie_title_ids:
         self.app_db.movie.remove(title)
         self.fill_movie_cbox()
     else:
         QMessageBox.information(
             self, 'Warning',
             'Cannot remove movie because it currently used in session!',
             QMessageBox.Ok)
Пример #4
0
    def update_seats_buttons(self, session: Session):
        self.remove_seats_buttons()
        seats = self.app_db.session.get_all_seats(session)
        seat_iter = iter(seats)
        booked_seats = self.app_db.ticket.get_booked_seats(session)
        _, _, rows, seats = self.app_db.movie_hall.get_by_field(
            'movie_hall', FieldPair('id', session.movie_hall_id))
        spacerItem1 = QtWidgets.QSpacerItem(20, 40,
                                            QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem1, 0, 0)
        for row in range(1, rows + 1):
            label = QtWidgets.QLabel()
            label.setMaximumSize(QtCore.QSize(10, 50))
            font = QtGui.QFont()
            font.setPointSize(10)
            font.setBold(True)
            label.setFont(font)
            label.setStyleSheet("QLabel { color : red; }")
            label.setText(str(row))
            self.gridLayout.addWidget(label, row, 0)
            for seat in range(1, seats + 1):
                btn = SeatPushButton(Seat(*next(seat_iter)), self)
                btn.setToolTip(
                    f"Row: {btn.seat.row_number}\nSeat: {btn.seat.seat_number}"
                )
                btn.setStyleSheet(
                    "QToolTip { background-color: #ffffca; color: #000023; }")
                if btn.seat in booked_seats:
                    btn.setStyleSheet("QPushButton { background-color: red; }")
                    btn.setEnabled(False)
                btn.clicked.connect(self.clicked_seats_buttons)
                self.gridLayout.addWidget(btn, row, seat)
            label2 = QtWidgets.QLabel()
            label2.setMaximumSize(QtCore.QSize(10, 50))
            font = QtGui.QFont()
            font.setPointSize(10)
            font.setBold(True)
            label2.setFont(font)
            label2.setStyleSheet("QLabel { color : red; }")
            label2.setText(str(row))
            self.gridLayout.addWidget(label2, row, seats + 1)

        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, rows + 1, 0)
Пример #5
0
 def update_user(self, login: str, role: str):
     role_id, _ = super().get_by_field('role', FieldPair('name', role))
     self.update(FieldPair('role_id', role_id), FieldPair('login', login))
 def add(self, date_time: datetime, movie_hall_name: str, movie_title: str):
     movie_title_id, *_ = super().get_by_field('movie', FieldPair('title', movie_title))
     movie_hall_id, *_ = super().get_by_field('movie_hall', FieldPair('name', movie_hall_name))
     self.add_by_id(date_time, movie_hall_id, movie_title_id)
Пример #7
0
 def update_genre(self, title: str, genre: str):
     genre_id, _ = super().get_by_field('genre', FieldPair('name', genre))
     self.update(FieldPair('genre_id', genre_id), FieldPair('title', title))
Пример #8
0
 def add(self, title: str, year: int, description: str, duration: int, genre: str):
     genre_id, _ = super().get_by_field('genre', FieldPair('name', genre))
     request = """
         INSERT INTO movie (title, year, description, duration, genre_id) VALUES(?, ?, ?, ?, ?)
     """
     self.data_base.execute(request, (title, year, description, duration, genre_id))
Пример #9
0
 def get_movie_hall_id(self, movie_hall: str) -> int:
     movie_hall_id, *_ = super().get_by_field('movie_hall',
                                              FieldPair('name', movie_hall))
     return movie_hall_id