meu código
try
try
ConsultarSituacao(QRYCONSULTAPROTOCOLO.ASSTRING, QRYCONSULTALOTE.ASSTRING);
except
on E: Exception do
begin
if WebServices.ConsSitLoteRPS.Msg <> '' then
widRespAux := WebServices.ConsSitLoteRPS.Msg
else if E.Message <> '' then
widRespAux := E.Message
else
widRespAux := 'RPS em processamento aguarde e consulte mais tarde!';
frm_aviso(widRespAux);
end;
end;
Situacao := StrToIntDef(WebServices.ConsSitLoteRPS.Situacao, 0);
if (Situacao = 4) then
begin
strArquivo := Configuracoes.Arquivos.GetPathNFSe(qryConsultaDATA.value) + '\NFSe\Recibos\' + inttostr(qryconsultanumero.value) + 'E-RPS.XML';
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(qryConsultaDATA.value) + '\Recibos\' + inttostr(qryconsultanumero.value) + 'E-RPS.XML';
end;
qrygravalotenota.close;
qrygravalotenota.ParamByName('numero').value := NotasFiscais.Items[0].NFSe.IdentificacaoRps.Numero;
qrygravalotenota.Open;
qrygravalotenota.edit;
qrygravalotenotaSITUACAO.value := Situacao;
if FileExists(strArquivo) then
begin
NotasFiscais.Clear;
NotasFiscais.LoadFromFile(strArquivo);
ConsultarNFSeporRps(NotasFiscais.Items[0].NFSe.IdentificacaoRps.Numero,
NotasFiscais.Items[0].NFSe.IdentificacaoRps.Serie,
TipoRPSToStr(NotasFiscais.Items[0].NFSe.IdentificacaoRps.Tipo));
end
else
begin
ConsultarNFSeporRps(qryConsultaNUMERO.ASSTRING, dtmdados.serie, TipoRPSToStr(trRPS));
end;
// Grava numero da NFSe
qrygravalotenotanota.Value := strtofloat(NotasFiscais.Items[0].NFSe.Numero);
strArquivo := Configuracoes.Arquivos.GetPathNFSe(qryConsultaDATA.value) + '\NFSe\Notas\' + NotasFiscais.Items[0].NFSe.Numero + 'E-NFSE.XML';
// procura NFSe
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(0) + '\Notas\' + qryConsultaNOTA.AsString + 'E-NFSE.XML';
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(qryConsultaDATA.value) + '\Notas\' + qryConsultaNOTA.AsString + 'E-NFSE.XML';
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(qryConsultaDATA.value) + qryConsultaNOTA.AsString + 'E-NFSE.XML'
end;
end;
end;
// procura RPS
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(0) + '\recibos\' + inttostr(qryconsultanumero.value) + 'E-RPS.XML';
if not FileExists(strArquivo) then
begin
strArquivo := Configuracoes.Arquivos.GetPathGer(qryConsultaDATA.value) + '\recibos\' + inttostr(qryconsultanumero.value) + 'E-RPS.XML'
end;
end;
NotasFiscais.Clear;
NotasFiscais.LoadFromFile(strArquivo);
if FileExists(strArquivo) then
begin
Configuracoes.Arquivos.NomeLongoNFSe := True;
NotasFiscais.Imprimir;
NotasFiscais.ImprimirPDF;
end;
end;
finally
if dtsgravalotenota.State in [dsEdit] then
begin
qrygravalotenota.POST;
QRYGRAVALOTENOTA.Transaction.CommitRetaining;
end;
end;
end;