Fórum Dificudade para usar IF...BEGIN...END na aplicação? #344326
09/08/2007
0
Tenho que fazer mais uma condiçao de IF para poder cancelar a operação?
Antes funcionava corretamente desta forma
procedure TfAlteraFolha.Button1Click(Sender: TObject);
begin
dm.zspSomaFuncC.Close;
dm.zspSomaFuncC.sql.Clear;
dm.zspSomaFuncC.sql.Text := ´select id_gerarformula, nome from essqlfunc where id_Formula >= 2´
+ ´and id_gerarformula =´ + QuotedSTR(L7.Caption);
dm.zspSomaFuncC.Open;
if not dm.zspSomaFuncC.IsEmpty then
begin
if application.MessageBox(´Atenção! Existe Proventos/Descontos vinculados a este Funcionário. Deletar em cascata?´, ´Informação´, MB_YESNOCANCEL) = mrNo then
begin
if L6.Caption = ´1´ then
begin
ShowMessage(´Este código só pode ser deletado em cascata´);
Abort;
end;
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end
else
begin
dm.zspAltFunc.Close; //-- Comandos da SP
dm.zspAltFunc.Params[0].Value := LMarcar.Caption;
dm.zSPAltFunc.Params[1].Value := L7.Caption;
dm.zspAltFunc.ExecProc; //executando a Stored Procedure
end;
{executando a SP fora do bloco acima}
end else {referente a if not}
begin
{Essa procedure dispara fora pq as vezes o funcionario nao
tem vinculo entao eh necessario desta SP aqui tambem}
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end;
ShowMessage(´Dados Atualizado´);
end;Tem jeito nao depois de velho a gente nao aprende mais mesmo :x
Fiz assim agora e nao funciona certo:
procedure TfAlteraFolha.Button1Click(Sender: TObject);
begin
dm.zspSomaFuncC.Close;
dm.zspSomaFuncC.sql.Clear;
dm.zspSomaFuncC.sql.Text := ´select id_gerarformula, nome from essqlfunc where id_Formula >= 2´
+ ´and id_gerarformula =´ + QuotedSTR(L7.Caption);
dm.zspSomaFuncC.Open;
if not dm.zspSomaFuncC.IsEmpty then
begin
if application.MessageBox(´Atenção! Existe Proventos/Descontos vinculados a este Funcionário. Deletar em cascata?´, ´Informação´, MB_YESNOCANCEL) = mrNo then
begin
if L6.Caption = ´1´ then
begin
ShowMessage(´Este código só pode ser deletado em cascata´);
Abort;
end;
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end else
begin
dm.zspAltFunc.Close; //-- Comandos da SP
dm.zspAltFunc.Params[0].Value := LMarcar.Caption;
dm.zSPAltFunc.Params[1].Value := L7.Caption;
dm.zspAltFunc.ExecProc; //executando a Stored Procedure
end;
{executando a SP fora do bloco acima}
end else {referente a if not}
begin
{Essa procedure dispara fora pq as vezes o funcionario nao
tem vinculo entao eh necessario esta SP aqui tambem}
if application.MessageBox(´Deletar este Provento/Desconto?´, ´Informação´, MB_YESNO) = mrYes then
begin
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end else
begin
Abort;
end;
Abort;
end;
ShowMessage(´Dados Atualizado´);
end;Mais esta [b:e57df5582d][size=18:e57df5582d]ERRADO[/size:e57df5582d][/b:e57df5582d] :evil:
Adriano_servitec
Curtir tópico
+ 0Posts
09/08/2007
Fknyght
case application.MessageBox(´Atenção! Existe Proventos/Descontos vinculados a este Funcionário. Deletar em cascata?´, ´Informação´, MB_YESNOCANCEL) of id_yes : faz alguma coisa id_no : faz outra coisa id_cancel : faz qualquer coisa end; // CASE
tenta ai
Gostei + 0
09/08/2007
Emerson Nascimento
procedure TfAlteraFolha.Button1Click(Sender: TObject);
var
resposta: integer;
begin
dm.zspSomaFuncC.Close;
dm.zspSomaFuncC.sql.Clear;
dm.zspSomaFuncC.sql.Text := ´select id_gerarformula, nome from essqlfunc where id_Formula >= 2´
+ ´and id_gerarformula =´ + QuotedSTR(L7.Caption);
dm.zspSomaFuncC.Open;
if not dm.zspSomaFuncC.IsEmpty then
begin
resposta := application.MessageBox(´Atenção! Existe Proventos/Descontos vinculados a este Funcionário. Deletar em cascata?´, ´Informação´, MB_YESNOCANCEL);
if resposta = mrNo then
begin
if L6.Caption = ´1´ then
begin
ShowMessage(´Este código só pode ser deletado em cascata´);
Abort;
end;
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end
else
if resposta = mrYes then
begin
dm.zspAltFunc.Close; //-- Comandos da SP
dm.zspAltFunc.Params[0].Value := LMarcar.Caption;
dm.zSPAltFunc.Params[1].Value := L7.Caption;
dm.zspAltFunc.ExecProc; //executando a Stored Procedure
end;
{executando a SP fora do bloco acima}
end else {referente a if not}
begin
{Essa procedure dispara fora pq as vezes o funcionario nao
tem vinculo entao eh necessario esta SP aqui tambem}
if application.MessageBox(´Deletar este Provento/Desconto?´, ´Informação´, MB_YESNO) = mrYes then
begin
dm.zspAltFuncU.Close; //-- Comandos da SP
dm.zspAltFuncU.Params[0].Value := LMarcar.Caption;
dm.zSPAltFuncU.Params[1].Value := L6.Caption;
dm.zSPAltFuncU.Params[2].Value := L7.Caption;
dm.zspAltFuncU.ExecProc; //executando a Stored Procedure
end else
begin
Abort;
end;
Abort;
end;
ShowMessage(´Dados Atualizados´);
end;Gostei + 0
09/08/2007
Adriano_servitec
Valeu pessoal, obrigado mais uma vez
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)