Yes the method executed correctly, but like i said in the modal i insert that with this method:
confirmarItem(){
if (this.itensVenda.qt_item == 0){
this.itensVendaProvider.remove(this.itensVenda.id_venda, this.itensVenda.id_produto, this.itensVenda.id_tabela_preco);
this.closeModal();
}
else if (this.itensVenda.qt_item > 0 && this.itensVenda.qt_item % this.produto.qt_multiplo > 0){
this.toast.create({ message: 'Quantidade do Item invĂĄlida, nĂŁo Ă© mĂșltiplo de: '+this.produto.qt_multiplo.toString()+'.', duration: 2000, position: 'botton' }).present();
}else{
if (this.parVendido == 'S'){
this.itensVendaProvider.update(this.itensVenda);
}else{
this.itensVenda.vendido = 'S';
this.itensVendaProvider.insert(this.itensVenda);
}
this.closeModal();
}
}
This method in the modal call my provider itensVendaProvider to insert data:
export class ItensVendaProvider {
constructor(private dbProvider: DatabaseProvider) { }
public insert(itemVenda: ItensVenda) {
return this.dbProvider.getDB()
.then((db: SQLiteObject) => {
let sql = " INSERT INTO itens_venda ( id_venda "
+" , key_venda "
+" , nr_pedido "
+" , id_tabela_preco "
+" , id_produto "
+" , nr_item "
+" , qt_item "
+" , vl_desconto "
+" , pc_desconto "
+" , vl_unit_item "
+" , vl_total_item "
+" , vendido "
+" ) "
+" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
let data = [itemVenda.id_venda
,itemVenda.key_venda
,itemVenda.nr_pedido
,itemVenda.id_tabela_preco
,itemVenda.id_produto
,itemVenda.nr_item
,itemVenda.qt_item
,itemVenda.vl_desconto
,itemVenda.pc_desconto
,itemVenda.vl_unit_item
,itemVenda.vl_total_item
,itemVenda.vendido];
return db.executeSql(sql, data)
.catch((e) => console.error(e));
})
.catch((e) => console.error(e));
}
But this is a child table and when i close the modal i use this method calculaVenda()
to calculate the father table with the data of the child table⊠but in this time when i close the modal the data seems not to have inserted yet on the sqlite database but if i open the modal an close just close donât insert anything the method calculaVenda()
return data of the databaseâŠ