Carlos Fernandes Posted May 29, 2023 at 10:48 AM Report #631126 Posted May 29, 2023 at 10:48 AM Olá, Gostaria de uma ajuda, preciso adicionar uma browlist para retornar uma tabela com todas as matrículas do cliente e ao selecionar a matrícula ela preencher o primeiro xvars. Segue código: Text to m.mySQL TextMerge NoShow SELECT DISTINCT 'Divida' = (select sum(case when datediff(dd,cc.dataven,getdate())>30 then cc.edeb-cc.edebf-(cc.ecred-cc.ecredf) else 0 end) from cc where cc.no=<<cl.no>> and cc.estab=<<cl.estab>>)-isnull((select sum(case when (RE.PROCESS=0) then RE.ETOTAL else 0 end) from RE WHERE re.no=<<cl.no>> and re.estab=<<cl.estab>>),0) FROM cc (nolock) WHERE cc.no=<<cl.no>> and cc.estab=<<cl.estab>> EndText u_sqlexec(m.mySQL,"cDIV") m.valordivida = cDIV.Divida If cl.U_ASSISCAN=.t. OR cl.inactivo=.t. msg("Abertura de folhas de obra canceladas pela Administração!") else If m.valordivida>0 AND cl.U_ASSISCAN=.f. aadderros("Este Cliente tem um saldo em dívida já vencido de: "+astr(m.valordivida)+chr(13)+"") MOSTRAERROS() *Messagebox("O Cliente tem um saldo de "+astr(cDIV.Divida)+" já vencido.") EndIf local msel, mbox msel= "SELECT u_matricul as 'Viatura' FROM BO WHERE ndos = 26 AND u_ativo = 0 AND no=?cl.no" u_sqlexec(msel,"listbo") Create Cursor xVars ( no N(5), tipo c(1), Nome c(40), Pict c(100), lOrdem N(10), nValor N(18,5), cValor c(250), lValor l, dValor d, tBval M ) Select xVars Append Blank Replace xVars.no With 1 Replace xVars.tipo With "T" Replace xVars.Nome With "Viatura" Replace xVars.Pict With "" Replace xVars.lOrdem With 1 m.mySQL_Viat = "(SELECT u_matricul as 'Viatura' FROM BO WHERE ndos = 26 AND u_ativo = 0 AND no=?cl.no)" m.mySQL_Viat = m.mySQL_Viat + "UNION ALL" m.mySQL_Viat = m.mySQL_Viat + "(SELECT IIF((SELECT COUNT(*) FROM BO WHERE ndos = 26 AND u_ativo = 0 AND no=?cl.no)>0, '', 'SEM VIATURAS') AS 'Viatura')" If u_sqlexec(m.mySQL_Viat,"vT") Select vT Scan Select xVars Replace xVars.tbval with alltrim(xVars.tbval)+alltrim(vT.Viatura)+"," Endscan Endif Select xVars Append Blank Replace xVars.no With 2 Replace xVars.tipo With "T" Replace xVars.Nome With "Tipo de Pedido" Replace xVars.Pict With "" Replace xVars.lOrdem With 2 m.mySQL_TipoServ = "SELECT ltrim(rtrim(u_texto)) AS 'VALOR' FROM BI WHERE ndos=25 AND obrano=6 ORDER BY binum1 ASC" If u_sqlexec(m.mySQL_TipoServ,"vTS") Select vTS Scan Select xVars Replace xVars.tbval with alltrim(xVars.tbval)+alltrim(vTS.VALOR)+"," Endscan Endif Select xVars Append Blank Replace xVars.no With 3 Replace xVars.tipo With "T" Replace xVars.Nome With "Técnico" Replace xVars.Pict With "" Replace xVars.lOrdem With 3 If u_sqlexec([SELECT nome2 FROM AG (nolock) WHERE inactivo = 0 AND u_tecnico = 1],"cT") Select cT Scan Select xVars Replace xVars.tbval with alltrim(xVars.tbval)+alltrim(cT.nome2)+"," Endscan Endif m.Escolheu = .F. m.mCaption = "Dados para abertura de folha de obra" docomando("do form usqlvar with 'xvars',m.mCaption,.t.") If Not m.Escolheu *mensagem("Atribuição interrompida!","DIRECTA") Return .F. Else Select xVars Locate Aut = xVars.cValor Select xVars Skip Tip = xVars.cValor Select xVars Skip Tec = xVars.cValor Select xVars Endif Text to m.mySQL TextMerge NoShow SELECT u_marca as 'Marca', u_modelo as 'Modelo', u_nuchassi as 'Chassi' FROM BO WHERE ndos = 26 AND u_matricul =?Aut EndText u_sqlexec(m.mySQL,"cViatura") If Wexist("SFREF") sfref.Release Endif doread("FREF","SFREF") sfref.dointroduzir select fref replace fref.u_no with cl.no replace fref.u_nome with cl.nome replace fref.u_morada with cl.morada replace fref.u_local with cl.local replace fref.u_codpost with cl.codpost replace fref.u_ncont with cl.ncont replace fref.u_telefone with cl.telefone replace fref.u_email with cl.email replace fref.u_estado with 'STAND BY' replace fref.u_tecnico with astr(Tec) replace fref.u_tipo with astr(Tip) replace fref.u_matricul with astr(Aut) replace fref.u_marca with cViatura.Marca replace fref.u_modelo with cViatura.Modelo replace fref.u_chassi with cViatura.Chassi replace fref.u_dataini with Date() replace fref.u_datafim with Date() sfref.refresh EndIf
pc.cesar Posted August 30, 2023 at 09:22 AM Report #631735 Posted August 30, 2023 at 09:22 AM tipo Query Select xVars Append Blank Replace xVars.no With 6 Replace xVars.tipo With "Q" Replace xVars.Nome With "Nome" Replace xVars.Pict With "" Replace xVars.lOrdem With 6 Replace xVars.tbval with "select fl.nome from fl (nolock)" César Faria
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now