Chamar um formulario para digitar o CPF quando a venda for igual ou maior que 500
Alguem poderia me ajudar com essa procedure ela esta me retornando os erros abaixo:
Erros:
[dcc32 Error] uPDV.pas(3854): E2029 'END' expected but ',' found
[dcc32 Error] uPDV.pas(3857): E2066 Missing operator or semicolon
[dcc32 Error] uPDV.pas(3877): E2029 '.' expected but ';' found
Minha Procedure:
procedure TFrmPDV.ChamaCPFCNPJ;
begin
if qryVendaTOTAL.Value >= 500 then
begin
try
frmCPFCNPJ := TfrmCPFCNPJ.Create(Application);
frmCPFCNPJ.ShowModal;
finally
qryVendaCODIGO.AsInteger, StrToFloatDef(edtPrecoP.Text, 0),
frmCPFCNPJ.edtCPFCNPJ.Text);
frmCPFCNPJ.Release;
if ehCaixaRapido = 'S' then
begin
if PageControl2.ActivePage = TabPDV then
InsereItem(EdtProdutoP.Text, '', StrToFloatDef(edtPrecoP.Text, 0),
StrToFloatDef(edtQtdP.Text, 1),
StrToFloatDef(lblTotalP.Caption, 0));
if PageControl2.ActivePage = tabRestaurante then
InsereItem(edtProdutoR.Text, edtOBSR.Text,
StrToFloatDef(edtPrecoR.Text, 0), StrToFloatDef(edtQtdR.Text, 1),
StrToFloatDef(lblTotalR.Caption, 0));
if PageControl2.ActivePage = tabDelivery then
InsereItem(edtProdutoD.Text, edtObsD.Text,
StrToFloatDef(EdtPrecoD.Text, 0), StrToFloatDef(EdtQtdD.Text, 1),
StrToFloatDef(lblTotalD.Caption, 0));
end;
end;
end;
end
Erros:
[dcc32 Error] uPDV.pas(3854): E2029 'END' expected but ',' found
[dcc32 Error] uPDV.pas(3857): E2066 Missing operator or semicolon
[dcc32 Error] uPDV.pas(3877): E2029 '.' expected but ';' found
Minha Procedure:
procedure TFrmPDV.ChamaCPFCNPJ;
begin
if qryVendaTOTAL.Value >= 500 then
begin
try
frmCPFCNPJ := TfrmCPFCNPJ.Create(Application);
frmCPFCNPJ.ShowModal;
finally
qryVendaCODIGO.AsInteger, StrToFloatDef(edtPrecoP.Text, 0),
frmCPFCNPJ.edtCPFCNPJ.Text);
frmCPFCNPJ.Release;
if ehCaixaRapido = 'S' then
begin
if PageControl2.ActivePage = TabPDV then
InsereItem(EdtProdutoP.Text, '', StrToFloatDef(edtPrecoP.Text, 0),
StrToFloatDef(edtQtdP.Text, 1),
StrToFloatDef(lblTotalP.Caption, 0));
if PageControl2.ActivePage = tabRestaurante then
InsereItem(edtProdutoR.Text, edtOBSR.Text,
StrToFloatDef(edtPrecoR.Text, 0), StrToFloatDef(edtQtdR.Text, 1),
StrToFloatDef(lblTotalR.Caption, 0));
if PageControl2.ActivePage = tabDelivery then
InsereItem(edtProdutoD.Text, edtObsD.Text,
StrToFloatDef(EdtPrecoD.Text, 0), StrToFloatDef(EdtQtdD.Text, 1),
StrToFloatDef(lblTotalD.Caption, 0));
end;
end;
end;
end
Lenivaldo Souza
Curtidas 0
Respostas
Raimundo Pereira
30/11/2022
Acrescente um ; no ultimo END
Troque End por End;
Troque End por End;
GOSTEI 0
Emerson Nascimento
30/11/2022
teu código identado:
procedure TFrmPDV.ChamaCPFCNPJ; begin if qryVendaTOTAL.Value >= 500 then begin try frmCPFCNPJ := TfrmCPFCNPJ.Create(Application); frmCPFCNPJ.ShowModal; finally qryVendaCODIGO.AsInteger, StrToFloatDef(edtPrecoP.Text, 0), // isto era pra ser uma atribuição? frmCPFCNPJ.edtCPFCNPJ.Text); // qual a finalidade desta linha? frmCPFCNPJ.Release; // aqui não deveria ter um end do bloco try..finally ??? if ehCaixaRapido = 'S' then begin if PageControl2.ActivePage = TabPDV then InsereItem(EdtProdutoP.Text, '', StrToFloatDef(edtPrecoP.Text, 0), StrToFloatDef(edtQtdP.Text, 1), StrToFloatDef(lblTotalP.Caption, 0)); if PageControl2.ActivePage = tabRestaurante then InsereItem(edtProdutoR.Text, edtOBSR.Text, StrToFloatDef(edtPrecoR.Text, 0), StrToFloatDef(edtQtdR.Text, 1), StrToFloatDef(lblTotalR.Caption, 0)); if PageControl2.ActivePage = tabDelivery then InsereItem(edtProdutoD.Text, edtObsD.Text, StrToFloatDef(EdtPrecoD.Text, 0), StrToFloatDef(EdtQtdD.Text, 1), StrToFloatDef(lblTotalD.Caption, 0)); end; end; end; end // aqui deveria ter um ponto e vírgula
GOSTEI 0
Arthur Heinrich
30/11/2022
Você pode construir uma unit com funções úteis para serem utilizadas em todo o seu código. Uma destas funções pode ser a que pede o CPF.
Aí, no seu código, você poderia fazer:
function SolicitaCPF : String;
var
frmCPFCNPJ : TfrmCPFCNPJ;
begin
Result := '';
try
frmCPFCNPJ := TfrmCPFCNPJ.Create(Application);
if (frmCPFCNPJ.ShowModal = mrOK)
then
Result := frmCPFCNPJ.edtCPF.Text;
finally
frmCPFCNPJ.Close;
//frmCPFCNPJ.Free; // Se no evento OnQueryClose não for especificado "Action:=caFree;"
end;
end;
Aí, no seu código, você poderia fazer:
if ((qryVendaCPF.Text='') and (qryVendaTOTAL.Value >= 500))
then
qryVendaCPF.Text := SolicitaCPF
GOSTEI 0