The code of tip:
- Code: Select all Expand view
// Some MDI application testing
// Cryptograph some fields
// By Rochinha - 5Volution
#include "FiveWin.ch"
#include "Customer.ch"
static oWnd, oClients, oClient, oName
static cName
static oSplit
static lEncrypted
//----------------------------------------------------------------------------//
function main()
SET _3DLOOK ON
// ********** Check if file have a field encrypted **********
cPath := cFilePath( GetModuleFileName( GetInstance() ) )
cEncrypted := VerifyINI( "Customer", "Encripted", "N", cPath+"crypto.ini" )
lEncrypted := iif( cEncrypted="N", .f., .t. )
if ! lEncrypted
USE crypto EXCLUSIVE
do while .not. eof()
dbRLock()
crypto->FIRST := FEncripta( crypto->FIRST )
crypto->LAST := FEncripta( crypto->LAST )
crypto->STREET:= FEncripta( crypto->STREET )
crypto->CITY := FEncripta( crypto->CITY )
dbRUnLock()
dbCommit()
skip
enddo
USE
VerifyINI( "Customer", "Encripted", "S", cPath+"crypto.ini", .t. )
? "Encrypted"
endif
// ********** Make index on encrypted field **********
if !FILE( "crypto.NTX" )
USE crypto EXCLUSIVE
INDEX ON FDecripta( FIRST ) TO crypto
USE
endif
USE crypto NEW SHARED INDEX crypto
DEFINE WINDOW oWnd TITLE "Cryptograph Test" MDI MENU BuildMenu() COLOR "N/W"
DEFINE BUTTONBAR OF oWnd
SET MESSAGE OF oWnd TO "Fivewin Power" CENTERED
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Tem certeza?" )
dbCloseAll()
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&DataBases"
MENU
MENUITEM "&Clients Encrypteds..." ACTION BrwClientsE() ;
MESSAGE "Clients management"
MENUITEM "&Clients Decrypteds..." ACTION BrwClientsD() ;
MESSAGE "Clients management"
MENUITEM "&Report..." ACTION GenReport()
SEPARATOR
MENUITEM "&End" ACTION oWnd:End() ;
MESSAGE "End this test"
ENDMENU
oMenu:AddMdi() // Add standard MDI menu options
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function brwClientsE()
local oBrw, oIco, oBar
if oClients != nil
return nil
endif
DEFINE ICON oIco FILENAME "..\icons\customer.ico"
DEFINE WINDOW oClients TITLE "Clients management" MDICHILD ICON oIco
DEFINE BUTTONBAR oBar OF oClients
DEFINE BUTTON OF oBar ACTION ShowClient()
@ 2, 0 LISTBOX oBrw FIELDS first,last,street,city OF oClients ;
HEADERS "First","Last","Street","City" ;
FIELDSIZES 200, 200, 300.150 ;
SIZE 500, 500 ;
ON CHANGE ChangeClient()
oClients:SetControl( oBrw )
ACTIVATE WINDOW oClients VALID( oClients := nil, .t. )
return nil
//----------------------------------------------------------------------------//
function brwClientsD()
local oBrw, oIco, oBar
if oClients != nil
return nil
endif
DEFINE ICON oIco FILENAME "..\icons\customer.ico"
DEFINE WINDOW oClients TITLE "Clients management" MDICHILD ICON oIco
DEFINE BUTTONBAR oBar OF oClients
DEFINE BUTTON OF oBar ACTION ShowClient()
@ 2, 0 LISTBOX oBrw FIELDS ;
FDecripta( first ),;
FDecripta( last ),;
FDecripta( street ),;
FDecripta( city ) OF oClients ;
HEADERS "First","Last","Street","City" ;
FIELDSIZES 200, 200, 300.150 ;
SIZE 500, 500 ;
ON CHANGE ChangeClient()
oClients:SetControl( oBrw )
ACTIVATE WINDOW oClients VALID( oClients := nil, .t. )
return nil
//----------------------------------------------------------------------------//
function GenReport()
local oWnd, oIco
DEFINE ICON oIco FILENAME "..\icons\print.ico"
DEFINE WINDOW oWnd MDICHILD TITLE "Clients report" ;
VSCROLL HSCROLL ICON oIco
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function ShowClient()
local oIco
if oClient != nil
return nil
endif
DEFINE ICON oIco FILENAME "..\icons\Person.ico"
DEFINE DIALOG oClient RESOURCE "Client" ICON oIco
REDEFINE SAY ID 3 OF oClient // To get the proper color
REDEFINE SAY ID 4 OF oClient
REDEFINE SAY ID 5 OF oClient
REDEFINE GET oName VAR cName ID ID_NAME OF oClient
REDEFINE BUTTON ID ID_NEXT OF oClient ACTION GoNext()
SELECT Sales // We select Sales to properly initialize the Browse
REDEFINE LISTBOX FIELDS ID ID_SALES OF oClient
ACTIVATE DIALOG oClient CENTERED NOWAIT ;
VALID ( oClient := nil, .t. ) // Destroy the object
SELECT Clients
return nil
//----------------------------------------------------------------------------//
function ChangeClient()
if oClient != nil
cName = AllTrim( FDecripta( crypto->Last ) ) + ", " + FDecripta( crypto->First )
oName:Refresh()
endif
return nil
//----------------------------------------------------------------------------//
function GoNext()
if oClients != nil
oClients:oControl:GoDown()
else
SKIP
if EoF()
GO BOTTOM
endif
endif
ChangeClient()
return nil
Function VerifyINI( _section_, _entry_, _var_, _inifile_, _grava_ )
oIni := TIni():New( _inifile_ )
if _grava_ = .t.
oIni:Set( _section_, _entry_, _var_ )
endif
return oIni:Get( _section_, _entry_, _var_, _var_ )
Function FEncripta( _oque_ )
return "5VZ" + Codifica( alltrim( _oque_ ) )
Function FDecripta( _oque_ )
return iif( "5VZ" $ _oque_, Decodifica( StrTran( _oque_, "5VZ", "" ) ), _oque_ )
Function codifica( _pass_ )
_senha_ := ''
for i = 1 to len(alltrim(_pass_))
_senha_ := _senha_ + chr(asc(substr(_pass_,i,1))+9)
next
return _senha_
Function decodifica( _pass_ )
_senha_ := ''
for i = 1 to len(alltrim(_pass_))
_senha_ := _senha_ + chr(asc(substr(_pass_,i,1))-9)
next
return _senha_
This sample speek for me:
Download at http://www.5volution.com/forum/crypto.zip
Need customer.ch