Example #1
0
    def apply():
        """Вносит изменения в калькуляцию текущего акционного товара, добавляя
        выбранный в списке товаров/ингредиентов товар в количестве, указанном
        в Entry"""

        select = listbox_goods.curselection()
        if select:
            index = int(select[0])
            ingredient = assortiment[index]

            if ingredient and show_sales_goods.sales_index <> None:
                item = sales_assortiment[show_sales_goods.sales_index]
                try:
                    quantity = int(quantVar.get())
                except:
                    quantity = 1
                if quantity:
                    item_old = None
                    for q in calculation:
                        if q.ingredient == ingredient:
                            item_old = q

                    if item_old:
                        item_old.quantity = quantity
                        if queries.update_calculation(item_old):
                            calc_fill(item)
                            quantVar.set('')
                    else:
                        calc = queries.add_calculation(item, ingredient,
                                                                       quantity)
                        if calc:
                            sales_fill()
                            calc_fill(item)
                            quantVar.set('')
Example #2
0
    def apply():
        """Вносит изменения в калькуляцию текущего товара, добавляя выбранный
        в списке ингредиентов товар в количестве, указанном в Entry"""

        index = show_calc.assortiment_index
        item = assortiment[index]
        if item:
            selected = listbox_ingr.curselection()
            if selected:
                ingredient = ingredients[int(selected[0])]
                try:
                    quantity = int(quant_var.get())
                except:
                    tkMessageBox.showerror(u'Ошибка!',
                            u'Внимательно проверьте заполнение числового поля.')
                else:
                    if quantity:

                        item_old = None
                        for q in calculation:
                            if q.ingredient == ingredient:
                                item_old = q

                        if item_old:
                            item_old.quantity = quantity
                            if queries.update_calculation(item_old):
                                listbox_calc_fill(item)
                                quant_var.set('')
                        else:
                            calc = queries.add_calculation(item, ingredient,
                                                                       quantity)
                            if calc:
                                listbox_fill()
                                listbox_calc_fill(item)
                                quant_var.set('')