Пример #1
0
    def _add_stock_info(self, model, brand, model_id, brand_id, line_number, total, number, unit):
        service_id = getattr(self, 'service_' + line_number).currentData()
        service_name = getattr(self, 'service_' + line_number).currentText()
        stock_info = Stock()

        services = service_name.split('-')
        service_ids = service_id.split('-')

        first_service_id = int(service_ids[0])
        first_service_name = services[0]
        second_service_id = int(service_ids[1])
        second_service_name = services[1]

        stock_info.model_id(model_id).model_name(model)
        stock_info.brand_id(brand_id).brand_name(brand)
        stock_info.first_service_id(first_service_id).first_service_name(first_service_name)
        stock_info.second_service_id(second_service_id).second_service_name(second_service_name)
        stock_info.unit(unit).name(brand + '-' + model)
        stock_info.create_op(config.login_user_info[0]).create_time(time_utils.get_now())
        stock_info.total_cost(total).balance(number)

        stock_id = stock_handler.add_stock_info(stock_info)

        return stock_id
Пример #2
0
def add_stock_info(stock: Stock):
    sql_text = '''
                INSERT INTO stock_info(
                                        UNIT,
                                        first_service_name,
                                        first_service_id,
                                        model_id,
                                        model_name,
                                        brand_id,
                                        brand_name,
                                        name,
                                        second_service_id,
                                        second_service_name,
                                        balance,
                                        total_cost,
                                        create_time,
                                        create_op
                                        )
                VALUES(
                        '{}',
                        '{}',
                         {},
                         {},
                        '{}',
                         {},
                        '{}',
                        '{}',
                         {},
                        '{}',
                         {},
                        {:.2f},
                        '{}',
                        {}                    
                )''' \
        .format(stock.unit(), stock.first_service_name(), stock.first_service_id(), stock.model_id(),
                stock.model_name(), stock.brand_id(), stock.brand_name(), stock.name(), stock.second_service_id(),
                stock.second_service_name(), stock.balance(), stock.total_cost(), stock.create_time(),
                stock.create_op())
    new_stock_id = execute(sql_text)

    return new_stock_id