Code: Select all
// BUSCA DO CLIENTE
FUNCTION BUSCA_NOME_CLIENTE( aGet, DeOndeVem )
LOCAL oDlg, oLbx, oSaida, oBrush, oFont, oFnt, oOk, oSay
LOCAL lConfirma := .F., nRecno, nKey := VK_RETURN, cAlias, IDCOR
LOCAL CNOMECLIEN, cEnderPropo, cBairrPropo, cCepdaPropo, bGet := ARRAY(5)
LOCAL cCidadPropo, cUFdaPropo, ccEmailCli, ccContatoCli, ccFuncaoClie
LOCAL ccFonesClien, oDlgInd, TRAB, cIndice, nColuna := 1, cnContrato, aGrad
TRAB := OemToAnsi( "ESCOLHA O ÖNDICE DA PESQUISA DO CLIENTE" )
aGrad := { { 0.30, CLR_WHITE, CLR_WHITE },{ 0.50, CLR_WHITE, CLR_WHITE } }
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD
DEFINE FONT oFnt NAME "Ms Sans Serif" SIZE 00, -12 BOLD
DEFINE DIALOG oDlgInd RESOURCE "DLG_INDICE_PESQUISA" GRADIENT aGrad
oDlgInd:lHelpIcon := .F.
For IDCor = 401 To 401 // Os ID's dos TEXTOS na DIALOG.
REDEFINE SAY ID IDCor COLOR CLR_BLACK, CLR_WHITE OF oDlgInd ;
UPDATE FONT oFnt TRANSPARENT
Next IDCor
REDEFINE GROUP oGroup ID 501 OF oDlgInd COLOR CLR_BLACK, CLR_WHITE ;
FONT oFnt TRANSPARENT
REDEFINE RADIO oRadMenu VAR nOpcBuscaClie ID 201, 202, 203, 204, 205, ;
206 OF oDlgInd UPDATE
REDEFINE GET aGet[1] VAR TRAB PICTURE "@!" ID 50 OF oDlgInd ;
WHEN( .F. ) UPDATE COLORS CLR_HBLUE, CLR_WHITE FONT oFont
REDEFINE BUTTONBMP oOk ID 301 OF oDlgInd ;
ACTION( lConfirma := .T., oDlgInd:End() )
oOk:cToolTip := OemToAnsi( "Escolha um Cliente" )
REDEFINE BUTTONBMP oSaida ID 302 OF oDlgInd ;
ACTION( lConfirma := .F., oDlgInd:End() ) CANCEL
oSaida:cToolTip := OemToAnsi( "Saida - Exit - Cancelar" )
SET FONT OF oOk TO oFont
SET FONT OF oSaida TO oFont
SET FONT OF oDlgInd TO oFont
ACTIVATE DIALOG oDlgInd CENTERED
oFnt:End()
oFont:End()
Do Case
Case nKey == VK_ESCAPE .OR. GetKeyState( VK_ESCAPE ) .OR. .NOT. lConfirma
nOpcBuscaClie := 6
XFOCUS( aGet[10] )
RETURN NIL
EndCase
SELECT( DBCADCLIEN )
GO TOP
IF nOpcBuscaClie == 6 //-> Por Endereco
INDEX ON END_FAT TAG 12 TO CLIETEMP FOR ( .NOT. EOF() ) MEMORY // TEMPORARY
MsgWait( "PESQUISA PELO ENDERECO DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "Endere‡o" )
nColuna := 3
ELSEIF nOpcBuscaClie == 5 //-> Por CPF
SET ORDER TO 09
MsgWait( "PESQUISA PELO C.P.F. DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "Cpf" )
nColuna := 5
ELSEIF nOpcBuscaClie == 4 //-> Por CGC/CNPJ
SET ORDER TO 08
MsgWait( "PESQUISA PELO C.N.P.J. DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "Cnpj" )
nColuna := 4
ELSEIF nOpcBuscaClie == 3 //-> Por fantasia
SET ORDER TO 10
MsgWait( "PESQUISA PELA FANTASIA DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "Fantasia" )
nColuna := 3
ELSEIF nOpcBuscaClie == 2 //-> Por Codigo
SET ORDER TO 01
MsgWait( "PESQUISA PELO CODIGO DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "C¢digo" )
nColuna := 1
ELSEIF nOpcBuscaClie == 1 //-> Por Nome
SET ORDER TO 07
MsgWait( "PESQUISA PELO NOME DO CLIENTE...", ;
"AGUARDE UM MOMENTO POR FAVOR... ", 1.5 )
cIndice := OemToAnsi( "Nome" )
nColuna := 2
ENDIF
GO TOP
// Swap it to descending - Trocar para descendente
SET DESCENDING OFF
GO TOP
cAlias := ALIAS() //-> Busca Incremental.
DBPESQ := ALIAS()
aGrad := { { 0.30, CLR_WHITE, CLR_WHITE },{ 0.50, CLR_WHITE, CLR_WHITE } }
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 800, 455 PIXEL FONT oFont ;
TITLE "PLENOIND: PESQUISA INCREMENTAL - Digite o Que Deseja Procurar" ;
GRADIENT aGrad
oDlg:lHelpIcon := .F.
oDlg:nSeeThroClr := RGB(1,1,1)
@ 30, 10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE "DBPESQ" AUTOCOLS AUTOSORT CELL LINES NOBORDER ;
HEADERS "Código:", "Nome:", "Endereço:", "Fantasia:", "Cnpj:", "Cpf:" ;
FIELDS ( cAlias )->CLIENCOD, ( cAlias )->CLIENTE, ( cAlias )->END_FAT, ;
( cAlias )->FANTASIA, ( cAlias )->CGC, ( cAlias )->CPF
oBrw:l2007 := .F.
oBrw:lFlatStyle := .T. // ??
oBrw:SetFont( oFont )
oBrw:nColSel := nColuna // <n> // Mister Nages - Perfect. Cursor inicia na xBrowse()
BrwColors( oBrw )
WITH OBJECT oBrw
oBrw:lIncrFilter := .T. // Liga o Filtro incremental
oBrw:lSeekWild := .T. // Liga a busca incremental
oBrw:bKeyDown := { |nKey| If( nKey == VK_RETURN, ( oDlg:End() ), nil ) }
oBrw:bKeyChar := { |nKey| If( nKey == VK_ESCAPE, ( oBrw:Seek( "" ), oDlg:End() ), nil ) }
oBrw:AutoFit()
oBrw:CreateFromCode()
END
@ 10, 055 SAY "Digite o Que Deseja Procurar: " SIZE 120, 10 PIXEL OF oDlg ;
COLOR CLR_BLACK, CLR_WHITE TRANSPARENT
@ 10, 150 SAY oBrw:oSeek PROMPT oBrw:cSeek PICTURE "@!" SIZE 100, 10 ;
PIXEL OF oDlg COLOR CLR_BLACK, CLR_YELLOW FONT oFont UPDATE BORDER
@ 10, 280 SAY "Busca Por: " + cIndice SIZE 100, 10 PIXEL OF oDlg ;
COLOR CLR_BLACK, CLR_WHITE TRANSPARENT
WITH OBJECT oBrw:oSeek
oBrw:bLClicked := { || oDlg:End() }
END
@ 010, 005 BUTTON oSaida PROMPT( "&Sair" ) ACTION( oDlg:End() ) ;
SIZE 25, 12 PIXEL FONT oFont OF oDlg CANCEL
oSaida:cToolTip := "Saida - Exit - Cancelar"
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oBrw:cSeek(""), oBrw:SetFocus(), .F. )
oFont:End()
DO CASE
CASE nKey == VK_ESCAPE .OR. GetKeyState( VK_ESCAPE )
lConfirma := .F.
ENDCASE
IF lConfirma //-> Usuario Escolheu um Cliente
nRecNo := ( cAlias )->( RecNo() )
GoTo( nRecNo )
CNOMECLIEN := ( cAlias )->CLIENTE
nClienCod := ( cAlias )->CLIENCOD
aGet[10]:VARPUT( CNOMECLIEN )
aGet[10]:Refresh()
IF DeOndeVem = "FOLDER2" // SEGUNDA TELA DA PROPOSTA
aGet[43]:VARPUT( CNOMECLIEN )
aGet[43]:Refresh()
ENDIF
cEnderPropo := ( cAlias )->END_FAT
aGet[11]:VARPUT( cEnderPropo )
aGet[11]:Refresh()
cBairrPropo := ( cAlias )->BAIR_FAT
aGet[12]:VARPUT( cBairrPropo )
aGet[12]:Refresh()
cCepdaPropo := ( cAlias )->CEP_FAT
aGet[13]:VARPUT( cCepdaPropo )
aGet[13]:Refresh()
cCidadPropo := ( cAlias )->CID_FAT
aGet[26]:VARPUT( cCidadPropo )
aGet[26]:Refresh()
cUFdaPropo := ( cAlias )->UF_FAT
aGet[27]:VARPUT( cUFdaPropo )
aGet[27]:Refresh()
ccEmailCli := ( cAlias )->EMAIL
aGet[28]:VARPUT( ccEmailCli )
aGet[28]:Refresh()
ccContatoCli := ( cAlias )->CON_FAT
aGet[29]:VARPUT( ccContatoCli )
aGet[29]:Refresh()
ccFuncaoClie := ( cAlias )->DEPTO_FAT
aGet[30]:VARPUT( ccFuncaoClie )
aGet[30]:Refresh()
ccFonesClien := ( cAlias )->FONE_FAT
aGet[31]:VARPUT( ccFonesClien )
aGet[31]:Refresh()
ENDIF
IF nOpcBuscaClie == 6 //-> Por Endereco
SET ORDER TO 0 // FECHA(Close) O INDICE TEMPORARIO
OrdDestroy( "CLIETEMP" )
ENDIF
// Swap it to descending - Trocar para descendente
SET DESCENDING ON
CLOSE( DBPESQ ) // CLOSE FILTER - FECHO FILTRO DA XBROWSE()
USE CADCLIEN INDEX ICLIEN ALIAS CADCLIEN NEW SHARED
SET ORDER TO 01
GO TOP
SELECT( DBCADPROPO )
SET ORDER TO 01
XFOCUS( aGet[10] )
RETURN NIL
STATIC FUNCTION BrwColors( oBrw, lFoot )
LOCAL cClrBack
DEFAULT lFoot := .F.
oBrw:l2007 := .F.
oBrw:nRowHeight := 24
oBrw:nHeaderHeight := 24
oBrw:lFooter := lFoot
oBrw:lFlatStyle := .T.
oBrw:bClrHeader := { || { CLR_BLACK, CLR_WHITE, CLR_WHITE } } //RGB( 232, 255, 232 ), RGB( 232, 255, 232 ) }}
oBrw:lFullGrid := .F.
oBrw:nRowDividerStyle := LINESTYLE_NOLINES //DARKGRAY //LINESTYLE_LIGHTGRAY //
oBrw:nColDividerStyle := LINESTYLE_NOLINES //LIGHTGRAY // LINESTYLE_NOLINES
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
{ If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLUE ),;
RGB( 198, 255, 198 ) }, ;
{ If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLUE ),;
RGB( 232, 255, 232 ) } ) }
oBrw:bClrSel = { || { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_WHITE ),;
RGB( 34, 177, 76 ) } } //RGB( 0x33, 0x66, 0xCC ) } }
cClrBack = Eval( oBrw:bClrSelFocus )[ 2 ]
oBrw:bClrSelFocus := { || { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_WHITE ),;
cClrBack } }
oBrw:SetColor( CLR_BLUE, RGB( 232, 255, 232 ) )
oBrw:SetFont( oFont1 )
RETURN NIL
Saludos.