コード例 #1
0
 def search_dish(self):
     self.dishesList.clear()
     if self.searchLineEdit.text() == "":
         self.refresh_dishes_list()
         return
     dishes = connection.get_dishes()
     for dish in dishes:
         if self.searchLineEdit.text().lower() in dish.get('name').lower():
             self.dishesList.addItem(dish.get('name'))
コード例 #2
0
    def show_dish_details(self):
        for dish in connection.get_dishes():
            if dish.get("name") == self.dishesList.currentItem().text():
                self.dishDetailsTextEdit.setText(f"""
Назва - {dish.get("name")}
Ціна - {dish.get("price")} ГРН
Опис - {dish.get("description")}
                """)
                return
コード例 #3
0
    def show_dish_details(self):
        for dish in connection.get_dishes():
            if dish.get('name') == self.dishesList.currentItem().text():
                self.dishDetailsTextEdit.setText(f"""
Назва - {dish.get('name')}
Ціна - {dish.get('price')} ГРН
Опис - {dish.get('description')}
                    """)
                self.addToCartButton.setDisabled(False)
                return
コード例 #4
0
    def add_to_cart(self):

        self.msgBox = QMessageBox()
        self.msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        self.msgBox.setText("Подтверждение")
        result = self.msgBox.exec_()
        if QMessageBox.Yes == result:
            for dish in connection.get_dishes():
                if dish.get("name") == self.dishesList.currentItem().text():
                    for i in range(int(self.dishesCountSpinBox.text())):
                        connection.insert_dish_in_cart(self.current_user, dish)
                    if self.cart_window is not None:
                        self.cart_window.refresh_cart()
        else:
            pass
コード例 #5
0
    def add_dish(self):
        if len(self.dishNameLineEdit.text()) < 1 or len(self.dishPriceLineEdit.text()) < 1 or len(
                self.dishDescriptionPlainTextEdit.toPlainText()) < 1:
            self.info("Ви заповнили не всі поля")
            return

        for dish in connection.get_dishes():
            if dish.get('name') == self.dishNameLineEdit.text():
                self.dishNameLineEdit.clear()
                self.info("Блюдо з такою назвою\nвже існує")
                return

        connection.insert_dish({"name": self.dishNameLineEdit.text(), "price": int(self.dishPriceLineEdit.text()),
                                "description": self.dishDescriptionPlainTextEdit.toPlainText()})
        self.info("")
コード例 #6
0
 def refresh_dishes_list(self):
     dishes = connection.get_dishes()
     for dish in dishes:
         self.dishesList.addItem(dish.get("name"))