#include "FiveWin.Ch"
#include "TCBrowse.ch"
MEMVAR cPesq
STATIC oWnd
FUNCTION TCBCADET( oDbf )
LOCAL oBrw, nI, aTestData, uVar, oBtn, oFont, oFnt, oIco
LOCAL oWnd, oDlg, oBar, oMsg, oBrush, oBmpBrush
LOCAL cName := "Testando...", oSay
LOCAL nLinhaDialog := 5 // Linha Que Come‡a a Dialog
LOCAL nColunaDialog := 5 // Coluna Que Come‡a a Dialog
LOCAL nAlturaDialog := 390 // Altura da Dialog
LOCAL nLarguraDialog := 745 // Largura da Dialog
LOCAL nLinhaBrowse := 38 // Linha que Come‡a a Browse
LOCAL nColunaBrowse := 10 // Coluna que Come‡a a Browse
LOCAL cTitle := "Browse Para Pesquisa " + ;
"Incremental dos Clientes!"
LOCAL acIndices := {}
LOCAL cIndice := ""
PUBLIC cPesq
cPesq := ""
IF NetUse( "CADETIQ", .T. )
OrdListAdd( "CADETIQ", "RAZ_MATRIC", "DEST_NOME", "END" )
DATABASE oDbf
oDbf:Load()
oDbf:SetBuffer( .T. ) // Assim, .T. a Op‡Æo (Cancelar) Funciona.
acIndices := GetIndices()
cIndice := acIndices[ 2 ]
ELSE
MsgStop( "Banco de Dados Bloqueado", "Cuidado!" )
RETURN NIL
ENDIF
SET ORDER TO 2
DBGOTOP()
DEFINE FONT oFnt NAME "Arial" SIZE 0, 14 BOLD
DEFINE FONT oFont NAME "Arial" SIZE 0, 15 BOLD
DEFINE ICON OICO FILE ".\BRASIL__.BMP"
DEFINE BITMAP oBmpBrush FILE "MARMORE.BMP"
DEFINE DIALOG oDlg FROM nLinhaDialog, nColunaDialog ;
TO nAlturaDialog, nLarguraDialog OF oWnd ;
TITLE cTitle ;
PIXEL ;
FONT oFnt ;
ICON oIco ;
STYLE nOR( DS_MODALFRAME )
oDlg:lHelpIcon := .F.
@ nLinhaBrowse, nColunaBrowse COLUMN BROWSE oBrw OF oDlg ;
SIZE 350, 135 ; // On Left
ON LEFT DBLCLICK Cadetiq( oDbf ) ;
MESSAGE "Digite Nome Para Fazer a Pesquisa" ;
Alias ( oDbf:cAlias ) ;
COLOR CLR_BLACK, CLR_HGRAY ;
PIXEL
oBrw:bLDblClick := { || Cadetiq( oDbf ), oBrw, oSay }
oBrw:bKeyChar = { | nKey, nFlags | ;
If( nKey # 13, ;
( oBrw:Refresh(), ;
oBrw:SetFocus(), ;
oBrw:DrawSelect() ), ;
Cadetiq( oDbf ) ), oBrw, oSay }
obrw:bKeyDown := { | nKey, nFlags | Incremental( nKey, ;
( oDbf:cAlias ), oBrw, oSay ) }
oBrw:nColOrder := 20
oBrw:cOrderType := "C"
oBrw:cSeek := ""
oBrw:nClrBackHead := CLR_LGREEN
oBrw:nClrForeHead := CLR_HRED
oBrw:aJustify := { .F. , .F. }
oBrw:lLogicDrop := .T.
oBrw:lNoHScroll := .F.
oBrw:nAdjColumn := 3
oBrw:nFreeze := 1
oBrw:lMChange := .F.
ADD COLUMN TO BROWSE oBrw ; // O Browse
DATA Recno() ; // array element number
SIZE 60 ; // Tamanho da Fonte/DimensÆo
NOBAR ; // Sem barra luminosa(Cursor)
CENTER ; // Centraliza
COLOR CLR_BLACK, CLR_HGRAY ; // As Cores
HEADER OemToAnsi( "Registro" ) // O Cabe‡alho...
ADD COLUMN TO BROWSE oBrw ;
DATA ( oDbf:cAlias )->Raz_Matric ;
HEADER OemToAnsi( "Matr¡cula " ) ;
SIZE 100 PICTURE "99999" ;
COLOR CLR_BLACK, CLR_HRED ;
CENTER ;
ADD TO BROWSE oBrw ;
DATA PadR( Trim( ( oDbf:cAlias )->Dest_Nome ), 50 ) ;
HEADER OemToAnsi( "Nome do Cliente" ) ;
COLOR CLR_BLACK, CLR_HCYAN ;
EDIT MESSAGE "Nome do Cliente no Banco de Dados" ;
SIZE 400 PICTURE "@S50"
ADD COLUMN TO oBrw ;
DATA ( oDbf:cAlias )->End ;
HEADER OemToAnsi( "Endere‡o do Cliente" ) ;
COLOR CLR_BLACK, CLR_LGREEN ;
SIZE 400
ADD COLUMN TO oBrw ;
DATA ( oDbf:cAlias )->Bai ;
HEADER OemToAnsi( "Bairro do Cliente" ) ;
COLOR CLR_BLACK, CLR_HRED ;
SIZE 200
ADD COLUMN TO oBrw ;
DATA ( oDbf:cAlias )->Cid ;
HEADER OemToAnsi( "Cidade/Estado" ) ;
COLOR CLR_BLACK, CLR_HGREEN ;
SIZE 200
ADD COLUMN TO oBrw ;
DATA ( oDbf:cAlias )->Cep ;
HEADER OemToAnsi( "C¢digo Postal" ) ;
COLOR CLR_BLACK, CLR_HGREEN ;
SIZE 200
@ 03.2, 1 BUTTON "&Saida" OF oDlg ;
SIZE 30, 12 ACTION oDlg:End() ;
MESSAGE "Sair do Programa" ;
PIXEL
@ 17.2, 1 BUTTON "&Editar" OF oDlg ;
SIZE 30, 12 ;
ACTION Cadetiq( oDbf ) ;
MESSAGE "Editar os Clientes Para Modificar" ;
PIXEL
@ 0.2, 50 SAY "Digite Letras Iniciais Para Pesquisa " + ;
"Incremental do Nome Com No " + ;
"Maximo de 20 Digitos." + CRLF + ;
"<Click> Duplo Para Editar, <ESC> Para Abortar, " + ;
"Use BackSpace Para Apagar Letras." ;
OF oDlg SIZE 260, 15 ;
FONT oFont ;
PIXEL ;
CENTER ;
COLOR CLR_CHOCOLATE, CLR_YELLOW
@ 20, 50 SAY "Digite Nome: " Size 100, 08 OF oDlg ;
PIXEL ;
FONT oFont ;
COLOR CLR_HBLUE, CLR_CHOCOLATE
@ 20, 112 SAY oSay PROMPT cPesq Size 100, 08 OF oDlg ;
PIXEL ;
COLOR CLR_HRED, CLR_VERDEAGUA ;
CENTERED
@ 20, 212 SAY OemToAnsi( " Suporta No M ximo 20 D¡gitos." ) ;
OF oDlg SIZE 100, 08 ;
FONT oFont ;
PIXEL ;
CENTER ;
COLOR CLR_RED, CLR_CHOCOLATE
oBrw:bChange := {|| cPesq := "" , oSay:Refresh() }
oBrw:ResetBarPos()
oBrw:DrawSelect() // showit
SET FONT OF oBrw TO oFont // ListBox
SET FONT OF oDlg TO oFnt // Dialog
ACTIVATE DIALOG oDlg CENTERED ;
ON PAINT MEUBRUSH( oDlg, oBmpBrush )
DbCloseAll()
oFont:End()
oFnt :End()
RELEASE BITMAP oBmpBrush
RETURN nil
FUNCTION Incremental( nKey, Alias, oBrw, oSay, oLbx )
LOCAL nOldPos := ( Alias )->( Recno() )
IF nKey = VK_ESCAPE
oBrw:oWnd:End()
ENDIF
IF nKey == VK_BACK
IF Len( cPesq ) > 0
cPesq := Left( cPesq, Len( cPesq ) - 1 )
ELSE
Tone( 500, 1 )
RETURN( .F. )
ENDIF
ENDIF
IF ( nKey >= 32 .AND. nKey <= 255 ) .OR. ;
nKey = VK_BACK
IF nKey != VK_BACK
cPesq += UPPER( Chr( nKey ) )
ENDIF
IF !( Alias )->( DbSeek( cPesq ) )
cPesq := Left( cPesq, Len( cPesq ) - 1 )
MsgStop( "Atenção: Esta Combinação de Letras" + CRLF + ;
"Não Existe, Tente Outra." )
DbGoto( nOldPos )
Tone( 500, 1 )
oBrw:Refresh()
RETURN( .F. )
ENDIF
oBrw:Refresh()
ENDIF
IF oSay != Nil
oSay:cTitle( cPesq ) // Mostra o que foi digitado
ENDIF
RETURN( .T. )
// FIM DO PROGRAMA