home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SAMPLES / DBF01.PRG < prev    next >
Text File  |  1994-06-08  |  3KB  |  109 lines

  1. // FiveWin - DataBase Objects Tutorial - 01
  2. // FiveWin DataBase tools
  3.  
  4. #include "FiveWin.ch"
  5. #include "Dbf01.ch"
  6.  
  7. static oWnd
  8.  
  9. //----------------------------------------------------------------------------//
  10.  
  11. function Main()
  12.  
  13.    SET 3DLOOK ON
  14.  
  15.    DEFINE WINDOW oWnd FROM 2, 2 TO 20, 70 ;
  16.       TITLE "Testing DataBase Objects" ;
  17.       MENU BuildMenu()
  18.  
  19.    SET MESSAGE OF oWnd ;
  20.       TO "FiveWin - Object Oriented DataBase Management" CENTERED
  21.  
  22.    oWnd:bLDblClick = { || MsgInfo( "Double Left Click" ) }
  23.  
  24.    ACTIVATE WINDOW oWnd MAXIMIZED ;
  25.       VALID MsgYesNo( "Do you really want to end ?" )
  26.  
  27. return nil
  28.  
  29. //----------------------------------------------------------------------------//
  30.  
  31. function BuildMenu()
  32.  
  33.    local oMenu
  34.  
  35.    MENU oMenu
  36.       MENUITEM "&Clients"
  37.       MENU
  38.          MENUITEM "&Management..." ACTION Clients() ;
  39.             MESSAGE "Clients management dialog"
  40.  
  41.          SEPARATOR
  42.  
  43.          MENUITEM "&Exit Test..."  ACTION oWnd:End() ;
  44.             MESSAGE "End doing this tutorial"
  45.       ENDMENU
  46.    ENDMENU
  47.  
  48. return oMenu
  49.  
  50. //----------------------------------------------------------------------------//
  51.  
  52. function Clients()
  53.  
  54.    local oDbf, oDlg
  55.  
  56.    USE Clients
  57.  
  58.    DATABASE oDbf        // We create a DBF Object based on the current Alias
  59.                         // Now we can change WorkArea and the DBF Object
  60.                         // automatically access its area !
  61.  
  62.  
  63.    DEFINE DIALOG oDlg RESOURCE "Clients" OF oWnd  // Specify the container,
  64.                                                   // to access its MsgBar !
  65.  
  66.    REDEFINE GET oDbf:Name ID ID_NAME OF oDlg UPDATE ;
  67.       MESSAGE "Please type here the name of the customer"
  68.  
  69.                                               // We directly use the Fields
  70.                                               // name, but we are working on
  71.                                               // a buffer ! This is perfect
  72.                                               // for Network management
  73.  
  74.    REDEFINE GET oDbf:Adress ID ID_ADDRESS OF oDlg UPDATE ;
  75.       MESSAGE "Please type here the address of the customer"
  76.  
  77.    REDEFINE CHECKBOX oDbf:Active ID ID_ACTIVE OF oDlg UPDATE ;
  78.       MESSAGE "Is the customer currently active"
  79.  
  80.      REDEFINE BUTTON ID ID_NEW OF oDlg ;
  81.       ACTION ( oDbf:Blank(), oDlg:Update(), oDlg:aControls[ 1 ]:SetFocus() ) ;
  82.             MESSAGE "Add a new customer"
  83.  
  84.    REDEFINE BUTTON ID ID_TOP OF oDlg ;
  85.       ACTION ( oDbf:GoTop(), oDlg:Update() ) ;
  86.       MESSAGE "Go to the first record of the DataBase"
  87.  
  88.    REDEFINE BUTTON ID ID_PREV OF oDlg ;
  89.       ACTION ( oDbf:Skip( -1 ), oDlg:Update() ) ;
  90.       MESSAGE "Go to the previous record of the DataBase"
  91.  
  92.    REDEFINE BUTTON ID ID_NEXT OF oDlg ;
  93.       ACTION ( oDbf:Skip(), oDlg:Update() ) ;
  94.       MESSAGE "Go to the next record of the DataBase"
  95.  
  96.    REDEFINE BUTTON ID ID_BOTTOM OF oDlg ;
  97.       ACTION ( oDbf:GoBottom(), oDlg:Update() ) ;
  98.       MESSAGE "Go to the last record of the DataBase"
  99.  
  100.    REDEFINE BUTTON ID ID_END OF oDlg ;
  101.       ACTION oDlg:End() ;
  102.       MESSAGE "End this dialog"
  103.  
  104.    ACTIVATE DIALOG oDlg CENTERED
  105.  
  106. return nil
  107.  
  108. //----------------------------------------------------------------------------//
  109.