Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FiveWin 1.9.2 - January 97 - // more work on previuos tutor06 http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
// More work on previuos Tutor06

#include "FiveWin.ch"

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "Working with DataBases" ;
      MENU  BuildMenu()

   SET MESSAGE OF oWnd ;
      TO FWVERSION + ", " + FWCOPYRIGHT CENTERED KEYBOARD

   ACTIVATE WINDOW oWnd           // MAXIMIZED

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "&Information"
      MENU
         MENUITEM   "&About..." ;
            ACTION  MsgInfo( "FiveWin Tutorial" + Chr( 13 ) + FWCOPYRIGHT ) ;
            MESSAGE "Information about this application"

         SEPARATOR

         MENUITEM   "&End..."  ;
            ACTION  If( MsgYesNo( "Want to end ?" ), oWnd:End(),) ;
            MESSAGE "End this application"
      ENDMENU

      MENUITEM "&Files"
      MENU
         MENUITEM   "&Customers..." ;
            ACTION  Customers() ;
            MESSAGE "Customers maintainance"

         MENUITEM   "&Stock" ;
            ACTION  MsgInfo( "Any option from here" ) ;
            MESSAGE "Stock maintainance"
      ENDMENU

      MENUITEM "&Utils"
      MENU
         MENUITEM   "&Calculator..." ;
            ACTION  WinExec( "Calc" ) ;
            MESSAGE "Run Windows calculator"

         MENUITEM   "C&alendar..." ;
            ACTION  WinExec( "Calendar" ) ;
            MESSAGE "Run Windows calendar"

         MENUITEM   "&Some fun..." ;
            ACTION  WinExec( "Sol" ) ;
            MESSAGE "Play a game..."
      ENDMENU
   ENDMENU

return oMenu

//----------------------------------------------------------------------------//

function Customers()

   local oDlg
   local cNombre    := ""
   local cDireccion := ""
   local getNombre, getDireccion

   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 CliNombr
   SET INDEX TO CliNombr
   GO TOP

   cNombre    := Clientes->Nombre
   cDireccion := Clientes->Direccion

   DEFINE DIALOG oDlg FROM 6, 7 TO 21, 72 TITLE "Customers Management"

   @ 1, 2 SAY "Name:" OF oDlg
   @ 1, 8 GET getNombre VAR cNombre OF oDlg  VALID NoEmptyField( cNombre )

   @ 2, 2 SAY "Address:" OF oDlg
   @ 2, 8 GET getDireccion VAR cDireccion OF oDlg

   @ 8,  3 BUTTON "&Previous"  OF oDlg SIZE 50, 12 ;
      ACTION ( DbSkip( -1 ),;
               getNombre:cText    := Clientes->Nombre,;
               getDireccion:cText := Clientes->Direccion )

   @ 8, 14 BUTTON "&Next" OF oDlg SIZE 50, 12;
       ACTION ( DbSkip( 1 ),;
                If( EoF(), MsgInfo( "End of file" ),),;
                If( EoF(), DbGoBottom(),),;
                getNombre:cText    := Clientes->Nombre,;
                getDireccion:cText := Clientes->Direccion )

   @ 8, 26 BUTTON "&End"  OF oDlg SIZE 50, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

   USE

return nil

//----------------------------------------------------------------------------//

static function NoEmptyField( cField )

    if Empty( cField )
        MsgAlert( "Empty field not allow here!" )
        return .f.
    endif

return .t.

//---------------------------------------------------------------------------//

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson