Fórum Adicionar PRODUTOS ao APLICATIVO de MESA/CARTÃO, tentando UPDATE #616128
28/06/2021
0
Boa noite estou tentando fazer um aplicativo de celular que funcione em rede, estou recuperando os dados do banco e tentando fazer uma comparação com os campos de tabelas diferentes (se o PRODUTO da tabela PRODUTOS for diferente dos PRODUTOS da tabela MESACARTAO, inserir o PRODUTO com QUANTIDADE 1 e se for IGUAL aumentar sua QUANTIDADE em + 1), mas não estou conseguindo meu UPDATE não está funcionando e esta dando erro, sou iniciante no Delphi;
Eu estou fazendo correto ? qual a melhor maneira de comprar esses campos ?
Eu estou fazendo correto ? qual a melhor maneira de comprar esses campos ?
[quoteprocedure TFrmPrincipal.rct_inserirprodClick(Sender: TObject);
var
inserirP,codbarra,nomepro: string;
prodcodigo,numesa,operador,empresa,codigo: integer;
prodprecvend,quantidade,preco,totalitem,produto,contquant: double;
begin
inserirP := edt_inserirprod.Text;
if inserirP <> '''' then
begin
inserirP := AnsiUpperCase(inserirP) + ''%'';
DM_Comanda.FDQueryInsProd.Close;
DM_Comanda.FDQueryInsProd.SQL.text := ''select * from PRODUTO where upper(descricao) like''+QuotedStr(inserirP);
DM_Comanda.FDQueryInsProd.Open;
numesa := lbl_numesa.Text.ToInteger;
prodcodigo := DM_Comanda.FDQueryInsProd.FieldByName(''codigo'').AsInteger;
codbarra := DM_Comanda.FDQueryInsProd.FieldByName(''codbarra'').AsString;
//quantidade fazer algo a respeito
preco := DM_Comanda.FDQueryInsProd.FieldByName(''precovenda'').AsFloat;
operador := DM_Comanda.FDQueryInsProd.FieldByName(''operador'').AsInteger;
empresa := DM_Comanda.FDQueryInsProd.FieldByName(''empresa'').AsInteger;
//TOTALITEM FAZER A MULTIPLICAÇÃO PELA QUANTIDADE;
nomepro := DM_Comanda.FDQueryInsProd.FieldByName(''descricao'').AsString;
DM_Comanda.FDQueryInsProd.Close;
DM_Comanda.FDQueryInsProd.SQL.Text := ''select produto from MESACARTAO'';
DM_Comanda.FDQueryInsProd.Open;
produto := DM_Comanda.FDQueryInsProd.FieldByName(''produto'').AsInteger;
if prodcodigo <> produto then // CÓDIGO DO PRODUTO DIFERENTE DO CÓDIGO DO PRODUTO QUE ESTÁ NA TABELA MESACARTÃO;
begin
DM_Comanda.FDQueryInsProd.Close;
DM_Comanda.FDQueryInsProd.SQL.Text := ''insert into MESACARTAO (codigo,mesa,produto,codbarra,quantidade,preco,operador,empresa,data,totalitem,nomepro) values (:codigo, :numesa, :prodcodigo, :codbarra, :quantidade, :preco, :operador, :empresa, :data, :totalitem, :nomepro)'';
DM_Comanda.FDQueryInsProd.ParamByName(''codigo'').AsInteger := getContadores(''mesacartao'');
DM_Comanda.FDQueryInsProd.ParamByName(''numesa'').AsInteger := numesa;
DM_Comanda.FDQueryInsProd.ParamByName(''prodcodigo'').AsInteger := prodcodigo;
DM_Comanda.FDQueryInsProd.ParamByName(''codbarra'').AsString := codbarra;
DM_Comanda.FDQueryInsProd.ParamByName(''quantidade'').AsFloat := 1;
DM_Comanda.FDQueryInsProd.ParamByName(''preco'').AsFloat := preco;
DM_Comanda.FDQueryInsProd.ParamByName(''operador'').AsInteger := operador;
DM_Comanda.FDQueryInsProd.ParamByName(''empresa'').AsInteger := empresa;
DM_Comanda.FDQueryInsProd.ParamByName(''data'').AsDateTime := now;
DM_Comanda.FDQueryInsProd.ParamByName(''totalitem'').AsFloat := totalitem;
DM_Comanda.FDQueryInsProd.ParamByName(''nomepro'').AsString := nomepro;
DM_Comanda.FDQueryInsProd.ExecSQL;
end
else
begin
DM_Comanda.FDQueryInsProd.Close;
DM_Comanda.FDQueryInsProd.SQL.Text := ''UPDATE MESACARTAO SET quantidade = +1 WHERE codigo = procodigo'';
DM_Comanda.FDQueryInsProd.ExecSQL;
end;
end;
end;]Helton Faria
Curtir tópico
+ 0
Responder