Perguntas Edição de TCBrowse

Mais
3 anos 9 meses atrás #32978 por Wanderson
Boa Tarde,

Fiz uma tela com TCBrowse e, preciso criar uma formula para editar algumas colunas, alguém pode me ajudar.

Desde já agradesço pelo ajuda,

Segue o Fonte:

#Include 'totvs.ch'
#Include 'Topconn.ch'


User Function VSPFIN14()

Local aDados:={}

Private aBrowse:={}
Private oPanel1
Private cNomeCli := Space(30)
Private cNomeTra := Space(30)
Private cDtamin := (date() -30)
Private oRadMenu1
Private nRadMenu1 := 1
Private nMilissegundos := 10000 // Disparo será de 2 em 2 segundos
Private aSize := MsAdvSize()
Private aObjects := {}
Private aPosObj := {}
Private aSizeAut := MsAdvSize()
Private cFontUti := "Arial"
Private cFontLeg := " ARIAL BLACK"
Private oFontAno := TFont():New(cFontUti, , -38)
Private oFontSub := TFont():New(cFontUti, , -20)
Private oFontLeg := TFont():New(cFontLeg, , -10)
Private cStCor
Private cFontTot := "Arial Black"
Private oFontTit := TFont():New(cFontUti, , -14)
Private oFontGet := TFont():New(cFontTot, , -12)
private aItems :={}


// Calculas as dimensões da tela para deixa o Objeto no tamanho real da Tela

aButtons := {}
aObjects := {}
aadd(aObjects, {100 , 070 , .t. , .f.})
aadd(aObjects, {105 , 309 , .t. , .t.})
aadd(aObjects, {100 , 015 , .t. , .f.})
aInfo := {aSize[1] , aSize[2], aSize[3], aSize[4], 3, 3}
aPosObj := MsObjSize(aInfo,aObjects)
aPosGet := MsObjGetPos(aSize[3]-aSize[1],315,{{003,033,160,200,240,263}})
// Estilo dos Campos
oTFont := TFont():New('ARIAL',,-16,.T.)
MntConsulta()
// Objeto Principal
DEFINE MSDIALOG oDlg TITLE 'Monitoramento de Pedidos de Venda' From aSize[7],0 to aSize[6],aSize[5] PIXEL

nList := 1
(nMilissegundos, {|| BscDados(cNomeCli,cNomeTra,nRadMenu1,cDtamin) }, oDlg )

//Labels gerais
@ 001, 003 SAY "Vespor " SIZE 200, 030 FONT oFontAno OF oDlg COLORS RGB(149,179,215) PIXEL
@ 006, 080 SAY "Estorno de Valores" SIZE 400, 030 FONT oFontSub OF oDlg COLORS RGB(031,073,125) PIXEL
*/
@ 024, 000 GROUP oGroup1 TO 025, 550 OF oDlg COLOR 0, 16777215 PIXEL
@ 045, 000 GROUP oGroup2 TO 046, 675 OF oDlg COLOR 0, 16777215 PIXEL
oTFont := TFont():New('Courier new',,-30,.T.)
aItems := {'Item 1','Item 2','Item 3','Item 4'}
nList := 1

if len(aBrowse)==0
aadd(aBrowse,{" "," "," "," "," "})
endif

// Vetor com elementos do Browse
oBrowse := TCBrowse():New( 050 , 05, 675, 220,, {'Conta','Valor Original', 'Loja p/Estorno','%Estorno','% Aplicado'},{20,100,50,100,20,100}, oDlg,,,,,{||},,,,,,,.F.,,.T.,,.F.,,, )

// Seta vetor para a browse
oBrowse:SetArray(aBrowse)

// Monta a linha a ser exibina no Browse
oBrowse:bLine := {||{ aBrowse[oBrowse:nAt,01],;
aBrowse[oBrowse:nAt,02],;
aBrowse[oBrowse:nAt,03],;
aBrowse[oBrowse:nAt,04],;
aBrowse[oBrowse:nAt,05]} }

oBrowse:bHeaderClick := {|o, nCol| alert('bHeaderClick') }
oBrowse:bLDblClick := {|| alert('click')}



ACTIVATE MSDIALOG oDlg CENTERED

Return


Static Function MntConsulta()

cQuery:=" SELECT
cQuery+=" SE2.E2_DESC AS DESCRICAO,
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR ,
cQuery+=" SPACE(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '504001' AND '504062'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" AND SE2.E2_NATUREZ NOT IN ('504040','504009','504044','504056','504054','504058','504060','504037','504004','504049','504045','504013','504025','504028')
cQuery+=" GROUP BY
cQuery+=" SE2.E2_DESC
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'GASTOSGERAIS',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR ,
cQuery+=" SPACE(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND SE2.E2_NATUREZ IN ('504056','504054','504058','504060','504037','504004','504049','504045','504013','504025','504028')
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'DESPESAS RANCHO',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '231300' AND '231395'
cQuery+=" AND SE2.E2_NATUREZ NOT BETWEEN '231354' AND '231354'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'CAVALO',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '231354' AND '231354'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'DESPESAS CHACARA',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '200000' AND '200040'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'MATRIZ',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND ((E2_FILIAL IN ('01')
cQuery+=" AND E2_NATUREZ <> '605012') OR (E2_FILIAL IN ('02') AND E2_NATUREZ IN ('504040','504009','504044')))
cQuery+=" AND E2_NATUREZ NOT BETWEEN '102070' AND '102071'
cQuery+=" AND E2_NATUREZ NOT BETWEEN '706001' AND '706010'
cQuery+=" AND E2_NATUREZ NOT BETWEEN '281000' AND '281035'
cQuery+=" AND E2_NATUREZ NOT BETWEEN '202005' AND '202005'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'CALL CENTER',
cQuery+=" SUM(E2_VALOR - E2_SDDECRE + E2_ACRESC - E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND E2_NATUREZ BETWEEN '281000' AND '281035'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'BARRACAO',
cQuery+=" SUM(E2_VALOR - E2_SDDECRE + E2_ACRESC - E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND E2_FILIAL IN ('01','02','05','16','30','40','46','51','52','60','70','72','73')
cQuery+=" AND E2_NATUREZ BETWEEN '202005' AND '202005'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'IMPOSTO MATRIZ',
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01')
cQuery+=" AND SE2.E2_NATUREZ = '605012'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'MARKETING FILIAL '+SE2.E2_FILIAL AS FILIAL,
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '102070' AND '102071'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" GROUP BY
cQuery+=" SE2.E2_FILIAL
cQuery+=" UNION ALL
cQuery+=" SELECT
cQuery+=" 'INVESTIMENTO LOJA '+SE2.E2_FILIAL AS FILIAL,
cQuery+=" SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS VALOR,
cQuery+=" Space(1)
cQuery+=" FROM
cQuery+=" SE2010 SE2
cQuery+=" WHERE
cQuery+=" SE2.D_E_L_E_T_ = ' '
cQuery+=" AND SE2.E2_FILIAL IN ('01')
cQuery+=" AND SE2.E2_NATUREZ BETWEEN '706001' AND '706010'
cQuery+=" AND SE2.E2_BAIXA BETWEEN '20210201' AND '20210211'
cQuery+=" GROUP BY
cQuery+=" SE2.E2_FILIAL

TCQuery cQuery New Alias "TMPCNT"
dbSelectArea("TMPCNT")
dbGoTop()

While TMPCNT->(!EOF())

aAdd(aBrowse,{TMPCNT->DESCRICAO,TMPCNT->VALOR," "," "," "})

TMPCNT->(dbSkip() )

Enddo
oBrowse:Refresh()

TMPCNT->(dbCloseArea())


Return

Por favor Acessar ou Registrar para participar da conversa.

Mais
3 anos 9 meses atrás - 3 anos 9 meses atrás #32979 por admin
Respondido por admin no tópico Edição de TCBrowse
Blz Cara, Segue um Exemplo que encontrei na internet.
#include 'protheus.ch'
user function TcBrowse_EX()
Local oOK := LoadBitmap(GetResources(),'br_verde')
Local oNO := LoadBitmap(GetResources(),'br_vermelho')
Local aList := {} // Vetor com elementos do Browse
Local nX
 // Cria Vetor para teste
for nX := 1 to 100
 aListAux := {.T., strzero(nX,10), 'Descrição do Produto '+;
strzero(nX,3), 1000.22+nX}
 aadd(aList, aListAux)
next
DEFINE MSDIALOG oDlg FROM 0,0 TO 520,600 PIXEL TITLE 'Exemplo da TCBrowse'
 // Cria objeto de fonte que sera usado na Browse
 Define Font oFont Name 'Courier New' Size 0, -12
 // Cria Browse
 oList := TCBrowse():New( 01 , 01, 300, 200,,;
 '','Codigo','Descrição','Valor'},{20,50,50,50},;
 oDlg,,,,,{||},,oFont,,,,,.F.,,.T.,,.F.,,, )
 // Seta o vetor a ser utilizado
 oList:SetArray(aList)
 // Monta a linha a ser exibina no Browse
 oList:bLine := {||{ If(aList[oList:nAt,01],oOK,oNO),;
 aList[oList:nAt,02],;
 aList[oList:nAt,03],;
 Transform(aList[oList:nAT,04],'@E 99,999,999,999.99') } }
// Evento de DuploClick (troca o valor do primeiro elemento do Vetor)
 oList:bLDblClick := {|| aList[oList:nAt][1] :=;
 !aList[oList:nAt][1],oList:DrawSelect() }
 // Principais commandos
oBtn := TButton():New( 210, 001,'GoUp()' , oDlg,{||oList:GoUp()},;
40, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 220, 001,'GoDown()', oDlg,{||oList:GoDown()},;
 40, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 230, 001,'GoTop()' , oDlg,{||oList:GoTop()}, ;
 40, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 240, 001,'GoBottom()', oDlg,{||oList:GoBottom()},;
 40, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 210, 060, 'nAt (Linha selecionada)' ,;
 oDlg,{|| Alert(oList:nAt)},;
 90, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 220, 060, 'nRowCount (Nr de linhas visiveis)',
oDlg,;{|| Alert(oList:nRowCount()) }, 90, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 230, 060, 'nLen (Numero total de linhas)', oDlg,;
{|| Alert(oList:nLen) }, 90, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
oBtn := TButton():New( 240, 060, 'lEditCell (Edita a celula)', oDlg,;
{|| lEditCell(@aList,oList,'@!',3) }, 90, 010,,,.F.,.T.,.F.,,.F.,,,.F. )
ACTIVATE MSDIALOG oDlg CENTERED
return
Ultima edição: 3 anos 9 meses atrás por admin.

Por favor Acessar ou Registrar para participar da conversa.

Tempo para a criação da página:0.135 segundos
Joomla templates by a4joomla