def get_shoots(self): try: shootID = self.sql.execute_command( Operation.SELECT, main_table_name='DrinkCategory', column_names=['DrinkCategoryID'], where_condition={'DrinkCategoryName': 'Tömények'}) print(shootID[0][0]) rows = self.sql.execute_command( Operation.SELECT, main_table_name='DrinkItem', where_condition={'DrinkCategory': f"{shootID[0][0]}"}) pass for index_i, row in enumerate(rows): drink_item = DrinkItem( *[str(inf) if type(inf) == int else inf for inf in row]) drink_item.drink_category_id = 'Tömények' if drink_item not in self.shoot_list: self.shoot_list.append(drink_item) self.table_shoot_list.insertRow(index_i) for index_j, data in enumerate(row): if data == None: data = '' self.table_shoot_list.setItem( index_i, index_j, QTableWidgetItem(str(data))) self.table_shoot_list.resizeColumnsToContents() except Exception as e: self.message_box.window_execution( f'Hiba a tábla feltöltésénél: \n{e}', MessageBoxType.ERROR) self.table_shoot_list.resizeColumnsToContents()
def get_selected_item_details(self): if self.comboBox_item_types.currentText() == 'Ételek': if self.comboBox_items: datas = self.sql.execute_command( Operation.SELECT, main_table_name='FoodItem', where_condition={ 'FoodName': self.comboBox_items.currentText() })[0] food_item = FoodItem(*datas) self.lineEdit_item_name.setText(food_item.food_item_name) self.lineEdit_description.setText(food_item.food_description) self.lineEdit_item_unitprice.setText(str(food_item.food_price)) self.lineEdit_item_discount.setText( str(food_item.food_discount)) self.selected_item = food_item if self.comboBox_item_types.currentText() == 'Italok': if self.comboBox_items: datas = self.sql.execute_command( Operation.SELECT, main_table_name='DrinkItem', where_condition={ 'DrinkItemName': self.comboBox_items.currentText() })[0] drink_item = DrinkItem(*datas) self.lineEdit_item_name.setText(drink_item.drink_item_name) self.lineEdit_description.setText(drink_item.drink_description) self.lineEdit_item_unitprice.setText( str(drink_item.drink_price)) self.lineEdit_item_discount.setText( str(drink_item.drink_discount)) self.selected_item = drink_item
def get_drinks(self): self.clear_item_table_list() self.actual_list_type = ItemType.DRINK try: rows = self.sql.execute_command(Operation.SELECT, 'DrinkItem', []) for index_i, row in enumerate(rows): drink_item = DrinkItem( *[str(inf) if type(inf) == int else inf for inf in row]) if drink_item not in self.drinks_list: self.drinks_list.append(drink_item) self.table_item_list.insertRow(index_i) for index_j, data in enumerate(row): if data == None: data = '' self.table_item_list.setItem( index_i, index_j, QTableWidgetItem(str(data))) self.table_item_list.resizeColumnsToContents() except Exception as e: self.message_box.window_execution( f'Hiba a tábla feltöltésénél: \n{e}', MessageBoxType.ERROR)
def get_selected_order_details(self, row=None, column=None): self.clear_item_table_list() if not row: row = 0 if self.table_orders.item(row, 0): self.selected_order_id = self.table_orders.item(row, 0).text() drink_tuple_list = self.sql.execute_command( Operation.SELECT, main_table_name='RestaurantDrinkOrderItem', where_condition={ 'RestaurantOrderID': str(self.table_orders.item(row, 0).text()) }) drink_itemID_count_pairs = [ tuple(y for y in x[2:]) for x in drink_tuple_list ] food_tuple_list = self.sql.execute_command( Operation.SELECT, main_table_name='RestaurantFoodOrderItem', where_condition={ 'RestaurantOrderID': str(self.table_orders.item(row, 0).text()) }) food_itemID_count_pairs = [ tuple(y for y in x[2:]) for x in food_tuple_list ] self.label_order_id.setText(self.selected_order_id) self.label_order_status.setText( self.table_orders.item(row, 4).text()) self.label_result.setText(self.table_orders.item(row, 3).text()) self.label_order_time.setText( self.table_orders.item(row, 1).text()) self.check_status() for index, tuple_data in enumerate(drink_itemID_count_pairs): self.table_order_details.insertRow(index) drink_obj = DrinkItem(*list( self.sql.execute_command( Operation.SELECT, main_table_name='DrinkItem', where_condition={'DrinkItemID': str(tuple_data[0])}) [0])) self.table_order_details.setItem( index, 0, QTableWidgetItem(str(tuple_data[1]))) self.table_order_details.setItem( index, 1, QTableWidgetItem(drink_obj.drink_item_name)) self.table_order_details.setItem( index, 2, QTableWidgetItem(str(drink_obj.drink_price * tuple_data[1]))) for index, tuple_data in enumerate(food_itemID_count_pairs): shifted_index = index + len(drink_itemID_count_pairs) self.table_order_details.insertRow(shifted_index) food_obj = FoodItem(*list( self.sql.execute_command( Operation.SELECT, main_table_name='FoodItem', where_condition={'FoodItemID': str(tuple_data[0])}) [0])) self.table_order_details.setItem( shifted_index, 0, QTableWidgetItem(str(tuple_data[1]))) self.table_order_details.setItem( shifted_index, 1, QTableWidgetItem(food_obj.food_item_name)) self.table_order_details.setItem( shifted_index, 2, QTableWidgetItem(str(food_obj.food_price * tuple_data[1])))