Code: Select all | Expand
function Clients()
local oDlg
local oLbx
local cVar
local aHBitMaps:= { ReadBitmap( 0, "..\bitmaps\Level1.bmp" ), ; // BitMaps de 14 x 32
ReadBitmap( 0, "..\bitmaps\Level2.bmp" ), ;
ReadBitmap( 0, "..\bitmaps\Level3.bmp" ), ;
ReadBitmap( 0, "..\bitmaps\Level4.bmp" ),;
ReadBitmap( 0, "..\bitmaps\Level5.bmp" ) }
local n
if ! File( "clientes.dbf" )
DbCreate( "Clientes.dbf", { { "Nombre", "C", 40, 0 },;
{ "Direccion", "C", 50, 0 },;
{ "Telefono", "C", 12, 0 },;
{ "Edad", "N", 2, 0 },;
{ "Productos", "C", 10, 0 },;
{ "Nivel", "N", 2, 0 } } )
endif
USE Clientes
if RecCount() == 0
APPEND BLANK
endif
INDEX ON Clientes->Nombre TO CliName
SET INDEX TO CliName
GO TOP
DEFINE DIALOG oDlg FROM 3, 3 TO 26, 79 TITLE "Clients Management"
@ 0, 1 SAY " &Clients List" OF oDlg
@ 1, 1 LISTBOX oLbx FIELDS aHBitmaps[ Max( 1, Clientes->Nivel ) ],;
Clientes->Nombre, AllTrim( Clientes->Direccion ),;
Clientes->Telefono,;
Str( Clientes->Edad, 3 ) ;
HEADERS "L", "Name", "Address", "Phone", "Age" ;
FIELDSIZES 16, 222, 213, 58, 24 ;
SIZE 284, 137 OF oDlg
// Lets use different row colors
oLbx:nClrText = { || SelColor( Clientes->Nivel ) }
oLbx:nClrForeFocus = { || SelColor( Clientes->Nivel ) }
oLbx:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oLbx ) }
// Try different line styles !!!
oLbx:nLineStyle = 1
oLbx:bKeyChar := {|nKey| if( nKey == VK_RETURN , EditRecord( oLbx ) , )}
oLbx:aJustify = { .f., .f., .t., .f., .t. }
// Uncomment this to quickly calculate the desired columns width
// Right click with the mouse over the browse and you will
// see the columns sizes!
// oLbx:bRClicked = { || oLbx:ShowSizes() }
@ 8.7, 1.4 BUTTON "&New" OF oDlg ACTION EditClient( oLbx, .t. ) ;
SIZE 40, 12
@ 8.7, 9.4 BUTTON "&Modify" OF oDlg ACTION EditClient( oLbx, .f. ) ;
SIZE 40, 12
@ 8.7, 17.4 BUTTON "&Delete" OF oDlg ACTION DelClient( oLbx ) SIZE 40, 12
@ 8.7, 25.4 BUTTON "&Search" OF oDlg ACTION SeekClient( oLbx ) SIZE 40, 12
@ 8.7, 33.4 BUTTON "&Print" OF oDlg ;
ACTION oLbx:Report( "clients Report", .t. ) ; // .t. --> wants preview
SIZE 40, 12
@ 8.7, 42 BUTTON "&Exit" OF oDlg ACTION oDlg:End() SIZE 40, 12
ACTIVATE DIALOG oDlg
USE
AEval( aHBitmaps, { | hBmp | DeleteObject( hBmp ) } )
return nil