Example #1
0
    def _submit(self):
        stock = Stock()

        brand = self.brand_comboBox
        stock.brand_name(brand.currentText()).brand_id(brand.currentData())

        model = self.model_combo_box
        stock.model_name(model.currentText()).model_id(model.currentData())

        first_service = self.first_service_combo_box
        stock.first_service_id(first_service.currentData()).first_service_name(
            first_service.currentText())

        second_service = self.second_service_combo_box
        stock.second_service_name(
            second_service.currentText()).second_service_id(
                second_service.currentData())

        name = brand.currentText() + '-' + model.currentText()
        stock.name(name)
        stock.unit(self.unit.text())
        stock.create_op(common.config.login_user_info[0])
        stock.create_time(get_now())

        stock_id = stock_handler.add_stock_info(stock)

        stock.id(stock_id)
Example #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