mas ao trocar SBUTTON por BUTTON a coisa fica maluca...
Segue o prg (em vermelho no final e o erro.log (em azul) onde ocorre ao incluir um obj BUTTON "a mais".
Se ficar só "um" BUTTON o programa roda normalmente.
- Digite os primeiros caracteres do dado desejado para seleciona-lo automáticamente (obedecendo a ordenação atual).
- Clique com o botão da esquerda do mouse sobre a lista e sem solta-lo arraste-o para ver paginas seguintes e anteriores.
- Clique com o botão da direita na área dos "CABEÇALHOS" para incluir/excluir colunas apresentadas.
-------------------------------------------------------------------------------------------------------------------------------------
F2 - Informa os parâmetros de filtragem. (se houverem).
Del ou Alt+E - Exclui a planilha atualmente marcada pela barra luminosa.
Ins ou Alt+I - Inclui uma nova planilha.
Alt+R - Revisa a planilha atualmente marcada pela barra luminosa.
Alt+X - Gera planilhas Excel em diversos formatos.
Enter ou Alt+V ou Duplo Clique sobre a linha - Visualiza a planilha atualmente marcada pela barra luminosa.
Alt+F - Filtra a lista de planilhas.
Ctrl+seta dir. - Vai para o fim da linha atualmente selecionada.
Ctrl+seta esq. - Vai para o início da linha atualmente selecionada.
Busca de dados por digitação ("Busca Incremental"): Posiciona o cursor no item desejado apenas digitando as letras ou nºs iniciais do dado procurado.
-------------------------------------------------------------------------------------------------------------------------------------
Pressione a tecla "Ctrl" junto com a tecla da letra "L" para preparar para uma nova busca por digitação .
Primeiro selecione a "ORDEM DE APRESENTAÇÃO" dos dados da lista.
Depois basta digitar as primeiras letras ou digitos do dado procurado.
Primeiro digite os dois algarismos do ANO desejado depois, os QUATRO NÚMEROS da planilha.
Obs.: Se a ordem for a de "SITUAÇÃO DA PLANILHA" digite A para Aprovadas, C para Cancelada, G para Aguardando Aprovação,
O para Outras, R para Reprovada, T para Cotando Mat.Prima e V para Analisando Viabilidade, -.
Se for informado que o dado procurado não existe: A função pesquisadora ficará pronta para outra pesquisa.
Para cancelar a pesquisa enquanto estava digitando: pressione a tecla Ctrl junto com a tecla L."
Code: Select all | Expand
[b]2 - PRG ONDE OCORRE O ERRO[/b]
[color=#BF0000]****************************************************
* CADPLAN.PRG - CADASTRO DAS PLANILHAS DE CUSTOS *
* CHAMADA DE A.PRG *
****************************************************
#include "fivewin.ch"
#include "xbrowse.ch"
#include "vkey.ch"
#include "inkey.ch"
#include "dbinfo.ch"
#include "Dbstruct.ch"
************
func cadplan
************
local ob
local nrecno
local obrush
local ocursorp
local nordem
local ldbfnaovazio := .f.
local areaberta := select()
local cstate := ''
local vobsemovs := '- Utilize a roda do mouse para selecionar o registro desejado ou clique nos botões de movimentação acima e a esquerda!'+CRLF+CRLF+;
'- Digite os primeiros caracteres do dado desejado para seleciona-lo automáticamente (obedecendo a ordenação atual).'+CRLF+CRLF+;
'- Clique com o botão da esquerda do mouse sobre a lista e sem solta-lo arraste-o para ver paginas seguintes e anteriores.'+CRLF+CRLF+;
'- Clique com o botão da direita na área dos "CABEÇALHOS" para incluir/excluir colunas apresentadas.'+CRLF+CRLF+;
'Efeitos de Teclas nesta tela: ("teclas de atalho")'+CRLF+;
'-------------------------------------------------------------------------------------------------------------------------------------'+CRLF+;
'F2 - Informa os parâmetros de filtragem. (se houverem).'+CRLF+CRLF+;
'Del ou Alt+E - Exclui a planilha atualmente marcada pela barra luminosa.'+CRLF+;
'Ins ou Alt+I - Inclui uma nova planilha. '+CRLF+;
'Alt+R - Revisa a planilha atualmente marcada pela barra luminosa.'+CRLF+;
'Alt+X - Gera planilhas Excel em diversos formatos.'+CRLF+;
'Enter ou Alt+V ou Duplo Clique sobre a linha - Visualiza a planilha atualmente marcada pela barra luminosa.'+CRLF+;
'Alt+F - Filtra a lista de planilhas.'+CRLF+;
'Ctrl+seta dir. - Vai para o fim da linha atualmente selecionada.'+CRLF+;
'Ctrl+seta esq. - Vai para o início da linha atualmente selecionada.'+CRLF+CRLF+;
'Busca de dados por digitação ("Busca Incremental"): Posiciona o cursor no item desejado apenas digitando as letras ou nºs iniciais do dado procurado.'+CRLF+;
'-------------------------------------------------------------------------------------------------------------------------------------'+CRLF+;
'Pressione a tecla "Ctrl" junto com a tecla da letra "L" para preparar para uma nova busca por digitação .'+CRLF+;
'Primeiro selecione a "ORDEM DE APRESENTAÇÃO" dos dados da lista. '+CRLF+;
'Depois basta digitar as primeiras letras ou digitos do dado procurado.'+CRLF+CRLF+;
'Obs.: Se a ordem for a de "NÚMEROS DE PLANILHA" digite a seguinte sequencia:'+CRLF+;
'Primeiro digite os dois algarismos do ANO desejado depois, os QUATRO NÚMEROS da planilha.'+CRLF+CRLF+;
'Obs.: Se a ordem for a de "SITUAÇÃO DA PLANILHA" digite A para Aprovadas, C para Cancelada, G para Aguardando Aprovação,'+CRLF+;
'O para Outras, R para Reprovada, T para Cotando Mat.Prima e V para Analisando Viabilidade, -.'+CRLF+CRLF+;
'Se for informado que o dado procurado não existe: A função pesquisadora ficará pronta para outra pesquisa.'+CRLF+;
'Para cancelar a pesquisa enquanto estava digitando: pressione a tecla Ctrl junto com a tecla L.'
priva obtcancelap, obtmostrap, obtprintp
priva nttinic := 0
priva ntt := nttfiltr := 0
priva i := 0
priva obtanterior,obtprimeiro,obtseguinte,obtultimo
priva obtinclui // inclui
priva obtexclui // exclui
priva obtrevisa // revisa
priva obtfiltra // filtra
priva obtcancfi // cancela filtro
priva obtprocura // procura
priva obtrepproc // repete ultima procura
priva odlgplan // esta variavel tem que ser private
priva olstbplan
priva v_escolha := ' nº planilha - da +nova para +antiga '
priva n_escolha
priva ocombordem
priva ostemfilt
priva ostipselemb // 5713 // este objeto deve ficar nesta rotina
priva obtinfs // 1140
priva vdatavalid
priva nrpos := 0
priva nx
procutoque := ''
vtipoforesc := 0
vtiposecesc := 0
USE planilha;
INDE pcldsdmi,pcldmdsi,pldsdmit,pldmdsit,pldtanal,plidplai,plidplan,plsituac;
ALIAS planilha ;
NEW ;
SHARED
planilha->( dbsetorder('plidplan') )
planilha->( orddescend( ,, .t. ) )
ldecend := .t.
// pcldsdmi,pcldmdsi,pldsdmit,pldmdsit,pldtanal,plidplai,plidplan,plsituac ;
// planilha->( orddescend( ,, .t. ) ) se antes era .f. seta para .t. mas retorna como estava antes
// ORDKEY(), = 'subs(nridpla,5,2)+subs(nridpla,1,4)+subs(nridpla,7,2)'
// indexkey(0) = 'subs(nridpla,5,2)+subs(nridpla,1,4)+subs(nridpla,7,2)'
// 'ORDNUMBER()',ORDNUMBER() = 7
// indexord() = 7
// planilha->( dbsetorder('plidplan') ) = seta indice para PLIDPLAN
// OrdSetFocus('plidplan') = seta indice para PLIDPLAN
// planilha->( dbsetorder(7) ) = seta indice para PLIDPLAN
// DBORDERINFO(5) = PLIDPLAN (o indice atual)
planilha->( dbgotop() )
if file('statbrw.sys') // arquivo de registro dos tamanhos das colunas
restore from statbrw.sys addi
cstate := a_cstate
a_cstate := ''
endif
* VERIFICAR O NUMERO DE REGISTROS APARENTES
// ntt := 0
// count to ntt for !deleted()
// if ntt # 0
// ldbfnaovazio := .t.
// endif
// ?ntt OU TAMBEM COMO ABAIXO...
nttinic := planilha->( dbeval( {|| ++ntt },{|| planilha->(!eof()) } ))
define dialog odlgplan;
resource 'rcadplan';
color cor_pret,cor_cinz_;
font ofntprinc;
title 'CADASTRO DAS PLANILHAS DE CUSTOS'
redefine say id 6002 color cor_pret,cor_cinz_
// SELECÁO DOS INDEXADORES
redefine combobox ocombordem;
var v_escolha;
items { v_escolha ,;
' nº planilha - da +antiga para +nova ' ,;
' cliente+desenho+desmestre+item ' ,;
' cliente+desmestre+desenho+item ' ,;
' desenho+desmestre+item ' ,;
' desmestre+desenho+item ' ,;
' data da analise ' ,;
' situação e data ' };
on change ( procutoque := '' ,;
nrecno:=planilha->(recno()),;
fselordem(ocombordem:nat) ,;
planilha->(dbgotop()) ,; //planilha->(dbgoto(nrecno)) ,;
olstbplan:vupdateall() ,;
olstbplan:refresh() ,;
olstbplan:setfocus() );
id 6003;
of odlgplan;
update;
color cor_azule,cor_azulff
ocombordem:ocursor := ocursorp
redefine say ostemfilt;
prompt if( !empty(planilha->(dbfilter())),' A RELAÇÃO ABAIXO ESTÁ FILTRADA! ','');
id 6001;
of odlgplan;
color cor_vermt,cor_cinz_;
font ofntbold;
update
/*
redefine dynamic say ostemfilt ;
prompt if( !empty(planilha->(dbfilter())),' A RELAÇÃO ABAIXO ESTÁ FILTRADA! ','');
id 6001;
of odlgplan;
color cor_vermt,cor_cinz_;
font ofntbold;
update;
blinking
*/
define brush obrush resource "paper"
redefine xbrowse olstbplan alias planilha->( alias() ); // autosort footers fastedit
lines cell;
fields (subs(planilha->nridplan,1,4)+'/'+;
subs(planilha->nridplan,5,2)+'-'+;
subs(planilha->nridplan,7,2)) ,;
oemtoansi(planilha->cliente) ,;
fmostrsit(planilha->situacao) ,;
oemtoansi(planilha->desenho) ,;
oemtoansi(planilha->desmestre) ,;
planilha->item,;
trans(1000*planilha->quantpedd,'@e 999,999,999'),;
planilha->descricao ,; // oemtoansi(planilha->descricao) ,;
planilha->tipomola ,; // oemtoansi(planilha->tipomola) ,;
oemtoansi(alltrim(planilha->material)),;
planilha->tiposecao ,;
oemtoansi(planilha->forneced) ,;
planilha->celula,;
trans(planilha->custotpla,'@e 999,999,999.99'),;
trans(planilha->Totvdpla ,'@e 999,999,999.99'),;
oemtoansi(planilha->analista) ,;
oemtoansi(planilha->solicita) ,;
trans(planilha->dtanalise,'99/99/9999'),;
trans(planilha->validade,'99')+' dias';
id 1001;
of odlgplan;
on change ( olstbplan:setfocus() );
font ofntprinc;
update
olstbplan:ajustify := {.f.,.f.,.f.,.f.,.f.,.f.,.t.,.f.,.f.,.f.,.f.,.f.,.f.,.t.,.t.,.f.,.f.,.f.,.f.}
olstbplan:nRowDividerStyle := 0 // no LINES
olstbplan:nColDividerStyle := 4 // cinza claro
olstbplan:nmarqueestyle := MARQSTYLE_HIGHLROW // 4
olstbplan:nfreeze := 2
olstbplan:bclrstd := { ||{ cor_azule, if( ( olstbplan:calias )->( ordkeyno() ) %2 == 0, cor_azulf, cor_azulff ) } }
olstbplan:nheaderlines := 1
olstbplan:nfooterlines := 0
olstbplan:ndatalines := 1
olstbplan:lfooter := .f.
olstbplan:acols[ 1]:cheader := 'nº/ano-rev.'
olstbplan:acols[ 1]:odatafont := ofntbold
olstbplan:acols[ 1]:bclrselfocus := {||{cor_amar,cor_azule}} // olstbplan:acols[ 1]:obrush := obrush
olstbplan:acols[ 2]:cheader := 'CLIENTE'
olstbplan:acols[ 2]:odatafont := ofntprinc
olstbplan:acols[ 3]:cheader := 'SITUACAO'
olstbplan:acols[ 3]:bclrselfocus := { ||{ if( (olstbplan:calias)->situacao==UPPER('A'), cor_amar,cor_azulf),cor_azule }}
olstbplan:acols[ 3]:odatafont := if( (olstbplan:calias)->situacao==UPPER('A'),ofntbold,ofntprinc)
olstbplan:acols[ 4]:cheader := 'DESENHO'
olstbplan:acols[ 4]:odatafont := ofntprinc
olstbplan:acols[ 5]:cheader := 'DES.MESTRE'
olstbplan:acols[ 5]:odatafont := ofntprinc
olstbplan:acols[ 6]:cheader := 'ITEM'
olstbplan:acols[ 7]:cheader := 'QUANT PEDD'
olstbplan:acols[ 8]:cheader := 'DESCRIÇÃO'
olstbplan:acols[ 9]:cheader := 'TIPO PROD'
olstbplan:acols[10]:cheader := 'MATERIAL'
olstbplan:acols[11]:cheader := 'TIPO SEÇÃO'
olstbplan:acols[12]:cheader := 'FORNECEDOR'
olstbplan:acols[13]:cheader := 'CÉLULA'
olstbplan:acols[14]:cheader := 'CUSTO INDUST.'
olstbplan:acols[15]:cheader := 'TOT.VENDA'
olstbplan:acols[16]:cheader := 'ANALISTA'
olstbplan:acols[17]:cheader := 'SOLICITA'
olstbplan:acols[18]:cheader := 'DT ANALISE'
olstbplan:acols[19]:cheader := 'VALIDADE'
// olstbplan:bseek := {|carac| buscadig( carac, olstbplan ) }
/* Era
* registro das larguras das colunas do txbrowse
for i := 1 to len(ar_cadplan)
olstbplan:acols[i]:nwidth := ar_cadplan[i]
next
*/
* duplo clique numa linha => mostra a planilha
olstbplan:bLDblClick := { || if( planilha->(lastrec())>0,; // mostrapl(@olstbplan,odlgplan,'cadplan'), ),;
mostrapl(@olstbplan,odlgplan,'cadplan'), ),;
olstbplan:setfocus() }
// olstbplan:bRClicked := { || if( l_testando , owndprinc:end(), ) }
olstbplan:bRClicked := { || if( l_testando , prtbreak(), ) }
olstbplan:bkeydown := {|nkey| if( nkey==27, procutoque:= '', fteclei(nkey,olstbplan)) }
// INCLUI
redefine button obtinclui;
id 1010;
of odlgplan;
prompt '&INCLUI NOVA';
update;
action if( v_operad=='adm',;
( if(inrevpla('inclusao',@odlgplan), ((++ntt,++nttinic),frefreshbt(''),olstbplan:refresh()) ,olstbplan:refresh() ));
,olstbplan:refresh() )
/*
// EXCLUI
redefine button obtexclui;
id 1020;
prompt '&EXCLUI';
of odlgplan;
update;
action if(v_operad=='adm',(if(fexcluipla(olstbplan), ((--ntt,--nttinic),frefreshbt('')), )),)
// REVISA
redefine button obtrevisa;
id 1030;
prompt '&REVISA';
of odlgplan;
//action if(v_operad=='adm', (if( planilha->(lastrec())>0 ,;
// if(inrevpla('revisao',@odlgplan),(++ntt,++nttinic,olstbplan:refresh()),), ),;
// olstbplan:refresh(), olstbplan:setfocus(),olstbplan:refresh()),)
// VISUALIZA PLANILHA
redefine button obtmostrap;
id 1040;
prompt '&VISUALIZA';
of odlgplan;
//action mostrapl(olstbplan,odlgplan,'cadplan')
// if( planilha->(lastrec()) > 0 , mostrapl(olstbplan,odlgplan,'cadplan'), )
// IMPRIME PLANILHA
redefine button obtprintp;
id 1050;
prompt 'Imprime Planilha' ;
of odlgplan;
//action prtwind() cancel
// if(planilha->(lastrec())>0,prtwind() , )
// PROCURA PLANILHA
redefine button obtprocura;
id 1070;
of odlgplan;
prompt '&Procura';
action procupla(odlgplan)
// REPETE PROCURA
redefine sbutton obtrepproc;
id 1071;
update;
of odlgplan;
action if( repete() , olstbplan:refresh() , obtrepproc:disable ); // CONCLUIR
tooltip 'Busca por mais ocorrencias da ultima procura';
font ofntprinc;
colors corbotaoazul1,corbotaoazul2;
W97 ROUNDRECT
// FILTRA PLANILHA
redefine button obtfiltra;
id 1080;
of odlgplan;
update;
action ( if( frotfiltro(), ( olstbplan:keycount ,;
ostemfilt:refresh() ,;
obtfiltra:disable() ,;
obtcancfi:enable() ,;
olstbplan:vupdateall()) , ),;
olstbplan:gotop() ,;
olstbplan:refresh() ,;
olstbplan:setfocus() )
// CANCELA FILTRO
redefine button obtcancfi;
id 1081;
of odlgplan;
update; // when !empty(planilha->( dbfilter()))
action ( planilha->( dbsetfilter() ) ,;
ostemfilt:refresh() ,;
obtfiltra:enable() ,;
obtcancfi:disable() ,;
olstbplan:vupdateall() ,;
olstbplan:gotop() ,;
olstbplan:refresh() ,;
ntt := nttinic ,;
olstbplan:setfocus() )
// VAI PARA PRIMEIRO REGISTRO
redefine button obtprimeiro;
id 1100;
of odlgplan;
update;
prompt 'Topo da Lista'+CRLF+'[Ctrl+Home]';
action ( olstbplan:gotop(),frefreshbt('primeiro'),olstbplan:setfocus())
//obtprimeiro:ocursor := ocursorp
redefine button obtanterior;
id 1110;
of odlgplan;
update;
prompt 'Planilha Anterior'+CRLF+'[seta p/cima]';
action ( olstbplan:goup(),frefreshbt(''),olstbplan:setfocus())
// obtanterior:ocursor := ocursorp
redefine button obtseguinte;
id 1120;
of odlgplan;
update;
prompt 'Planilha Seguinte'+CRLF+'[seta p/baixo]';
action (olstbplan:godown(),frefreshbt(''),olstbplan:setfocus())
// obtseguinte:ocursor := ocursorp
redefine button obtultimo;
id 1130;
of odlgplan;
update;
prompt 'Final da Lista'+CRLF+'[Ctrl+End]';
action (olstbplan:gobottom(), frefreshbt('ultimo'),olstbplan:setfocus())
//obtultimo:ocursor := ocursorp
redefine button obtinfs;
id 1140;
of odlgplan;
action (msgalert(vobsemovs,'Ações e Movimentações:'),olstbplan:setfocus());
cancel;
update
// obtinfs:ocursor := ocursorp
redefine button obtcancelap;
id 5000;
of odlgplan; // tooltip 'Retorna a tela anterior'
prompt 'RETORNA &A TELA INICIAL';
update;
action odlgplan:end();
cancel
// obtcancelap:ocursor := ocursorp
*/
odlgplan:lhelpicon := .f.
odlgplan:bkeydown := {|nt| if( nt==27, procutoque := '', fteclei(nt,olstbplan)) }
activate dialog odlgplan centered;// on paint poenotopo(odlgplan);
on right click if( l_testando ,(ondestou(procfile()),owndprinc:end()), );
on init ( odlgplan:lballoon:= .t., owndprinc:hide(),;
olstbplan:restorestate(cstate),;
cfiltrotela := '' ,;
ostemfilt:refresh() ,; // obtanterior:disable(),; obtfiltra:enable() ,; obtcancfi:disable() ,; // if(alltrim(v_operad)#'adm',(obtinclui:disable(),; obtexclui:disable(),; obtrevisa:disable()),),;
olstbplan:gotop() ,;
olstbplan:setfocus() ,;
olstbplan:refresh() );
valid (cstate:=olstbplan:savestate(),.t.)
a_cstate := cstate
save to statbrw.sys all like a_cstate
// as_cadplan := asave(ar_cadplan)
// save to colunas.sys all like as_*
dbcloseall()
sele (areaberta)
owndprinc:show()
retu nil
*******************
stat func fmostrsit()
*******************
if planilha->situacao == 'A'
retu padr('APROVADO',22 )
elseif planilha->situacao == 'V'
retu padr('ANALISANDO VIABILIDADE',22 )
elseif planilha->situacao == 'G'
retu padr('AGUARDANDO APROVAÇÃO',22 )
elseif planilha->situacao == 'C'
retu padr('CANCELADO',22 )
elseif planilha->situacao == 'T'
retu padr('COTANDO MATÉRIA-PRIMA',22 )
elseif planilha->situacao == '0'
retu padr('OUTRAS',22 )
elseif planilha->situacao == 'R'
retu padr('REPROVADO',22 )
endif
retu space(22)
*********************
stat func fmostrtip()
*********************
if planilha->tipomola == 1
retu 'COMPRESSÃO'
elseif planilha->tipomola == 2
retu padr('TRAÇÃO',10)
elseif planilha->tipomola == 3
retu padr('TORÇÃO',10)
elseif planilha->tipomola == 4
retu padr('ARTEFATO',10)
endif
retu 0
*****************************
stat func fselordem(vordsele) // seleciona a ordem de apresentaçao dos registros
*****************************
n_escolha := vordsele
if vordsele==1
planilha->( dbsetorder( 'plidplan'))
ldescend := planilha->( orddescend(,,.t.) )
elseif vordsele==2
planilha->( dbsetorder( 'plidplan' ))
ldescend := planilha->( orddescend(,,.f.) )
elseif vordsele==3
planilha->( dbsetorder('pcldsdmi' ))
elseif vordsele==4
planilha->( dbsetorder('pcldmdsi' ))
elseif vordsele==5
planilha->( dbsetorder('pldsdmit' ))
elseif vordsele==6
planilha->( dbsetorder('pldmdsit' ))
elseif vordsele==7
planilha->( dbsetorder('pldtanal' ))
elseif vordsele==8
planilha->( dbsetorder('plsituac' ))
endif
retu nil
****************************
stat func fexcluipla(olstbox)
****************************
// pcldsdmi,pcldmdsi,pldsdmit,pldmdsit,pldtanal,plidplai,plidplan,plsituac ;
// planilha->( orddescend( ,, .t. ) ) se antes era .f. seta para .t. mas retorna como estava antes
// ORDKEY(), = 'subs(nridpla,5,2)+subs(nridpla,1,4)+subs(nridpla,7,2)'
// indexkey(0) = 'subs(nridpla,5,2)+subs(nridpla,1,4)+subs(nridpla,7,2)'
// ORDNUMBER() = 7
// indexord() = 7
// planilha->( dbsetorder('plidplan') ) = seta indice para PLIDPLAN
// OrdSetFocus('plidplan') = seta indice para PLIDPLAN
// planilha->( dbsetorder(7) ) = seta indice para PLIDPLAN
// DBORDERINFO(5) = PLIDPLAN
local nreg_atual := planilha->( recno() ) // registro atual
local regdepois := planilha->( recno() )
local ultimo_reg := planilha->( lastrec() )
local fil_atual := planilha->( dbfilter() ) // filtro atual
local nind_atual := planilha->( indexord() ) // indice principal atual
local ldescendo := planilha->(DbOrderInfo(DBOI_ISDESC)) // ordenaçao atual (descendente ou ascendente )
local n_revisao := subs(planilha->nridplan,1,6) // numero da revisao atual da planilha
local l_resp := .f.
local lretu := .f.
planilha->( dbsetorder('plidplan') ) // seta indice para PLIDPLAN
planilha->( orddescend(,,.f.) ) // seta para numero de planilha ascendente
planilha->( dbskip() )
if planilha->( eof() )
* COMO JÁ ESTA NO ULTIMO REGISTRO - NAO HAVERÃO REGISTROS POSTERIORES A SEREM DELETADOS - ENTÃO: VOLTA PARA O TOPO
planilha->( dbgoto(nreg_atual) )
planilha->( dbgobottom() )
regdepois := planilha->( recno() )
else
regdepois := nreg_atual
endif
planilha->( dbgoto(nreg_atual) )
* SE EXISTIR FILTRO ATIVO: CANCELA-LO (PARA QUE AS REVISOES DA PLANILHA SELECIONADA APAREÇAM)
if ! empty( fil_atual )
planilha->( dbsetfilter())
planilha->( dbgoto(nreg_atual))
endif
* REODENA PELA ORDEM NATURAL DE PLIDPLAN
planilha->( dbsetorder('plidplan') )
planilha->( orddescend( ,, .f. ) )
planilha->( dbgotop() )
planilha->( dbgoto(nreg_atual))
* CHECA SE É A ULTIMA REVISAO (pois só ela pode ser deletada!!!)
planilha->( dbskip() )
if subs(planilha->nridplan,1,6) == n_revisao .and. planilha->( !eof() )
msgalert('Só será possível excluir uma planilha a partir de sua última revisão!')
planilha->( dbskip(-1) )
regdepois := nreg_atual
lretu := .f.
else // E SE FOR A ULTIMA REVISAO...
planilha->( dbgoto( nreg_atual ) )
l_resp := msgnoyes('A operação de exclusão elimina definitivamente o registro da' + CRLF+;
'planilha selecionada. ' + CRLF+;
' Responda a pergunta abaixo. ' + CRLF+;
' ' + CRLF+;
'Voce tem certeza que deseja excluir a planilha: ' + trans(nridplan,'@r 9999/99-99'), 'Atenção!!!' )
if l_resp
if alltrim(v_operad)=='adm'
if planilha->( flock() )
planilha->( dbdelete() )
planilha->( dbunlock() )
//planilha->( dbpack() ) // não é possivel packear com shared e preciso do shared para o procupla.prg
planilha->( dbcommit() )
lretu := .t.
else
msgstop( "O registro selecionado está em uso!", "Por favor, tente novamente mais tarde!" )
regdepois := nreg_atual
lretu := .f.
endif
else
regdepois := nreg_atual
lretu := .f.
endif
else
lretu := .f.
endif
endif
* RESTAURA FILTRO (SE EXISTIR)
if ! empty( fil_atual )
planilha->( dbsetfilter( {|| &fil_atual}, fil_atual) )
endif
* VOLTA PARA O INDICE E A ORDEM QUE ESTAVAM SELECIONADOS
planilha->( dbsetorder(nind_atual ))
planilha->( orddescend(,,ldescendo) )
planilha->( dbgoto(regdepois) )
olstbplan:vupdateall()
olstbox:refresh()
olstbox:setfocus(.t.)
retu lretu
/*
*****************************
stat func regprod(vforma_reg)
*****************************
if vforma_reg == 'inclusao'
appe blan
endif
planilha->nomeprod := cnomeprod
planilha->( dbcommit() )
retu .t.
******************
stat func procprod
******************
local obtproccr,obtokprcr
local ogetncr,ogetnmcr
local osayncr,osaynmcr
local odlgproccr
cnomeprod := space(35)
define dialog odlgproccr;
resource 'rcadpro_pr';
color cor_pret,cor_cinz_;
font ofntprinc;
title 'PROCURA DESCRIÇÃO';
redefine say;
id 010;
color cor_verm,cor_amar
redefine get ogetnmcr;
var cnomeprod;
id 101;
picture '@k!'
ogetnmcr:ctooltip := 'Informe a descrição (ou parte dela)'
redefine button obtokprcr;
id 300;
action if( procurprod(ogetnmcr) ,;
( olstbplan:refresh(),;
odlgproccr:end()) ,)
redefine button obtproccr;
id 200;
action odlgproccr:end();
cancel
odlgproccr:lhelpicon := .f.
activate dialog odlgproccr center; // on paint poenotopo();
on right click if( l_testando ,(ondestou(procfile()),owndprinc:end()), )
olstbplan:setfocus(.t.)
retu nil
*/
*******************************
stat func procurprod(objorigem)
*******************************
local nregatual := planilha->(recno())
if !empty(cnomeprod)
locate for alltrim(cnomeprod) $ planilha->nomeprod
if planilha->(found())
if !planilha->(eof())
obtrepproc:show()
obtrepproc:enable()
endif
retu .t.
endif
msgalert( 'Descrição não encontrada!')
planilha->(dbgoto(nregatual))
retu .f.
endif
retu .f.
/*
******************
stat func repete()
******************
local nregatual := planilha->(recno())
local areawork := select()
sele planilha
continue
sele (areawork)
if planilha->(found())
if !planilha->(eof())
obtrepproc:show()
obtrepproc:enable()
endif
olstbplan:refresh()
olstbplan:setfocus(.t.)
retu .t.
endif
msgalert('Nao foram encontradas mais ocorrencias do dado procurado')
planilha->(dbgoto(nregatual))
obtrepproc:disable()
olstbplan:setfocus(.t.)
retu .f.
*/
/*
*****************************
stat func regtamcol(ncolunas)
*****************************
local i := 0
ar_cadplan := {}
for i := 1 to ncolunas
aadd(ar_cadplan, olstbplan:acols[i]:nwidth )
next
retu .t.
*/
**************************
stat func frefreshbt(vpos)
**************************
local nrecno := planilha->( recno() )
if empty(vpos)
planilha->( dbskip(1) )
if planilha->( eof() )
vpos := 'ultimo'
planilha->( dbgobottom() )
else
vpos := ''
planilha->( dbgoto(nrecno) )
planilha->( dbskip(-1) )
if planilha->( bof() )
vpos := 'primeiro'
planilha->( dbgotop() )
else
vpos := ''
planilha->( dbgoto(nrecno) )
endif
endif
endif
if vpos == 'primeiro'
obtprimeiro:disable()
obtanterior:disable()
obtseguinte:enable()
obtultimo:enable()
elseif vpos == 'ultimo'
obtprimeiro:enable()
obtanterior:enable()
obtseguinte:disable()
obtultimo:disable()
else
obtprimeiro:enable()
obtanterior:enable()
obtseguinte:enable()
obtultimo:enable()
endif
retu nil
********************
stat func frotfiltro
********************
local lretu := .f.
* O FILTRO ESTÁ VAZIO ?
// SIM
if empty( planilha->(dbfilter()) )
// FILTROU E VERIFICOU SE EXISTEM REGISTROS QUE ATENDAM AO FILTRO?
if filtropl(olstbplan) // SIM
lretu := .t.
endif
// NÃO
else
* DESEJA LIMPAR O FILTRO ATUAL E REALIZAR OUTRA FILTRAGEM ?
// SIM
if flimpafilt()
* CRIOU O FILTRO - APLICOU - E ENCONTROU REGISTROS QUE ATENDAM AO FILTRO?
// SIM
if filtropl(olstbplan)
lretu := .t.
// NÃO
else
* ZERA O FILTRO E FINALIZA
cfiltrotela := ''
planilha->( dbsetfilter() )
planilha->( dbgotop() )
lretu := .t.
endif
// NÃO
else
lretu := .f.
endif
endif
retu lretu
********************
stat func flimpafilt
********************
local lretu := .f.
if empty(cfiltrotela) // este if não é obrigatório - só o fiz para uma eventualidade do texto do filtro ficar vazio
cfiltrotela := planilha->( dbfilter() )
endif
if simnao( 'A relação (apresentada acima) já está filtrada para:!' +CRLF+CRLF+;
cfiltrotela +CRLF+CRLF+ 'Deseja cancelar este filtro e iniciar um outro?' )
cfiltrotela := ''
planilha->( dbsetfilte() )
planilha->( dbgotop() )
lretu := .t.
else
lretu := .f.
endif
retu lretu
*******************************
stat func fteclei(ntecla,olstb)
*******************************
local lretu := .f.
local vindkey
local lfield
* SE LOCALIZADOR DO MOUSE ESTIVER ATIVO ...
if ntecla == VK_CONTROL
procutoque := ''
retu nil
endif
* NAO TIRE O TRECHO ABAIXO DAQUI*********************************
if upper(chr(ntecla)) == upper('L') .and. GetKeyState(VK_CONTROL)
msgwait('Busca por digitação pronta para nova pesquisa!',,1)
procutoque := ''
olstb:gotop()
retu nil
endif
//MOSTRA - VISUALIZA
if ntecla == VK_RETURN .or. ntecla==13 .or. ntecla==K_ALT_V
procutoque := ''
obtmostrap:setfocus()
eval(obtmostrap:baction)
retu nil
//FILTRA
elseif ntecla == K_ALT_F
procutoque := ''
obtfiltra:setfocus()
eval(obtfiltra:baction)
retu lretu
//INCLUI
elseif (ntecla==K_INS .or. ntecla==K_ALT_I .or. ntecla==VK_INSERT) .and. v_operad#'adm'
procutoque := ''
retu .t.
elseif (ntecla==K_INS .or. ntecla==K_ALT_I .or. ntecla==VK_INSERT) .and. v_operad=='adm'
procutoque := ''
obtinclui:setfocus()
eval(obtinclui:baction)
retu lretu
//EXCLUI
elseif (ntecla==K_ALT_E .or. ntecla==K_DEL .or. ntecla==VK_DELETE) .and. v_operad#'adm'
procutoque := ''
retu .t.
elseif (ntecla==K_ALT_E .or. ntecla==K_DEL .or. ntecla==VK_DELETE) .and. v_operad=='adm'
procutoque := ''
obtexclui:setfocus()
eval(obtexclui:baction)
retu lretu
//REVISA
elseif (ntecla==K_ALT_R ) .and. v_operad#'adm'
procutoque := ''
retu .t.
elseif (ntecla==K_ALT_R ) .and. v_operad=='adm'
procutoque := ''
obtrevisa:setfocus()
eval(obtrevisa:baction)
retu lretu
elseif ntecla==VK_UP
procutoque := ''
olstb:goup()
if olstb:bof .or. olstb:nat == 1
olstb:gotop()
frefreshbt('primeiro')
endif
elseif ntecla==VK_DOWN
procutoque := ''
olstb:godown()
if olstb:eof
olstbpla:gobottom()
frefreshbt('ultimo')
endif
elseif ntecla== VK_HOME
procutoque := ''
olstb:gotop()
frefreshbt('primeiro')
elseif ntecla== VK_END
procutoque := ''
olstb:gobottom()
frefreshbt('ultimo')
elseif ntecla==VK_F2
procutoque := ''
msginfo( if(!empty(planilha->(dbfilter())), cfiltrotela , 'Nemhum filtro ativo!'), 'Parâmetros do Filtro:' )
retu nil
elseif ntecla >= 96 .and. ntecla <=105 // se digitar no teclado numerico "keypad"
* caracter "0" -> ascii = 48
ntecla = ntecla - 48
endif
// pcldsdmi,pcldmdsi,pldsdmit,pldmdsit,pldtanal,plidplai,plidplan,plsituac
// 1 2 3 4 5 6 7 8
if (indexord()= 7 .or. indexord()= 6) .and. ! chr(ntecla)$'1234567890' // PLIDPLAN
alerta( 'Para a atual ordem de apresentação: '+ v_escolha +CRLF+CRLF+;
'Voce deve digitar ANO + Nº DA PLANILHA + Nº DA REVISAO'+CRLF+CRLF+;
'no formato AANNNRR '+CRLF+CRLF+;
'Ou selecionar a ordem de apresentação relativa ao dados pesquisado !!!')
procutoque:=''
retu nil
elseif alltrim(str(indexord())) $ '12348' .and. chr(ntecla)$ '1234567890'
alerta( 'Para a atual ordem de apresentação: '+ v_escolha +CRLF+CRLF+;
'Voce deve digitar, sómente, CARACTERES ALFABETICOS E PONTUAÇÕES'+CRLF+CRLF+;
'Ou selecionar a ordem de apresentação relativa ao dados pesquisado !!!')
procutoque:=''
retu nil
elseif indexord()=5
alerta( 'Para a atual ordem de apresentação: '+ v_escolha+CRLF+CRLF+;
'Não é possível fazer pesquisa incremental'+CRLF+CRLF+;
'Utilize o botão "PROCURA" ou o botão "FILTRA" !!!')
procutoque:=''
retu nil
endif
if (upper(chr(ntecla)) $ ' _ABCÇDEFGHIJKLMNOPQRSTUVWXYZ1234567890/<>*"&¨@(){}[]#$%-+.,:;?' .or.;
chr(ntecla) == "'" .and.;
!empty(indexkey()) .and. fieldtype(fieldnum(indexkey())) $ upper('CN') )
flocadig(upper(chr(ntecla)),@olstb)
ntecla := nil
endif
retu nil
***********************************
stat func flocadig(toquelocal,olbx)
***********************************
local atregs
//local indextual := planilha->(indexord()) //OrdBagName()
priva ultimapos := planilha->(recno())
procutoque := procutoque + toquelocal
msgwait(procutoque,,.5)
if ! planilha->( dbseek( procutoque) )
alerta('O dado digitado nao esta cadastrado!')
planilha->( dbgoto(ultimapos) )
olbx:refresh()
procutoque := ''
else
atregs := recno()
olbx:gotop()
planilha->( dbgoto(atregs) )
olbx:refresh()
endif
retu .t.