Jump to content

Recommended Posts

Posted

Bom dia, 

Tenho um anexo que inseri no dossier numero 14 dos dossiers internos no modulo de documentos. 

Criei 1 botão no Painel para que esse anexo abra quando o painel o selecionar.

Entretanto não consegui que funcione e escolhi um anexostamp especifico inserido por mim e nem assim funcionou.

O Botão cira o pdf mas ele aquando a abertura da erro de ficheiro no Acrobat, google ou edge. 

Cria o doc no C:\PHC como mando. Podem ajudar ? 

LOCAL lcSql, lcFicheiro, lcBin, lnRet

CURSORSETPROP("MapBinary", .T., 0)

lcSql = ;
    "SELECT ltrim(rtrim(fname)) + '.' + ltrim(rtrim(fext)) AS arquivo, bdados AS conteudo " + ;
    "FROM anexos " + ;
    "WHERE anexosstamp = 'JAL26011456855,909553256'"

u_sqlexec(lcSql, "curArq")
SELECT curArq

IF RECCOUNT("curArq") > 0
    lcFicheiro = FORCEPATH(ALLTRIM(curArq.arquivo), "C:\PHC")
    lcBin      = curArq.conteudo

    IF STRTOFILE(lcBin, lcFicheiro) > 0
        DECLARE INTEGER ShellExecute IN shell32.dll ;
            INTEGER hwnd, STRING lpOperation, STRING lpFile, ;
            STRING lpParameters, STRING lpDirectory, INTEGER nShowCmd

        lnRet = ShellExecute(0, "open", lcFicheiro, "", "", 1)
        IF lnRet <= 32
            MESSAGEBOX("Falha ao abrir o ficheiro. ShellExecute retorno=" + TRANSFORM(lnRet))
        ENDIF
    ELSE
        MESSAGEBOX("Falha ao gravar o ficheiro em " + lcFicheiro)
    ENDIF
ENDIF
Posted

o ficheiro é guardado na base de dados, ou numa pasta

se for pasta, todos os computadores tem de ter acesso á pasta

se estiver na BD deve extrair o ficheiro

Parameters iduvaltsql
gnfile = ''
If u_sqlexecbin([select * from anexos where recstamp=']+ bo.bostamp +['], 'crAnexos')
    If Reccount('crAnexos') > 0
        m.imagem = crAnexos.bdados
        gnfile = 'c:\PHC\' + Alltrim(crAnexos.fname) + '.' + Alltrim(crAnexos.fext)
        m.bindados = Strtofile(m.imagem, gnfile, 0)
    Endif
Endif
Return gnfile

César Faria

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.