en GUI, Harbour

DBF Viewer 2020 – Código Fuente III

*------------------------------------------------------------------------------*
Procedure DeleteRecall()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )

      aRec := oWndBase.&(Browse_n()).Value
      ( Alias() )->( DbGoto( aRec[1] ) )

      if ( Alias() )->( Rlock() )
         iif( ( Alias() )->( Deleted() ), ( Alias() )->( DbRecall() ), ( Alias() )->( DbDelete() ) )
         siguiente()
      endif
      ( Alias() )->( dbUnlock() )
      Actualizar()

   Endif
Return

*------------------------------------------------------------------------------*
Procedure MuestraRec()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      nPos      := ( Alias() )->( Select( oWndBase.Tab_1.caption( oWndBase.Tab_1.value ) ) )

      If !Empty(nRecCopy)
         nRecSel := Iif(nPos==nRecCopy[1,1],RecToMost(),0)
      Endif

      Titulo()

      aRec := oWndBase.&( Browse_n() ).Value

      oWndBase.StatusBar.Item(1) := ' Record: '      ;
      +padl(Alltrim(Str(aRec[1])),7) ;
      +'/'+padl(Alltrim(Str(( Alias() )->(LastRec()))),7)+'         Row: '+padl(Alltrim(Str(aRec[1])),7)+'   Col:'+padl(Alltrim(Str(aRec[2])),7)
      oWndBase.StatusBar.Item(2) := 'Selected Record: '+ Alltrim(Str( nRecSel ,7))
      oWndBase.StatusBar.Item(3) := 'Index Tag: ' + ( Alias() )->( OrdName() )
      oWndBase.StatusBar.Item(4) := 'Order Key: ' + ( Alias() )->( OrdKey() )
   Else
      oWndBase.StatusBar.Item(1) := ''
   Endif
Return

*------------------------------------------------------------------------------*
Procedure Titulo()
*------------------------------------------------------------------------------*
   Local nPos := ( Alias() )->( Select( oWndBase.Tab_1.caption( oWndBase.Tab_1.value ) ) )
   TRY
        oWndBase.Title := PROGRAM+VERSION+COPYRIGHT+iif(Empty(aFiles[nPos]),"",aFiles[nPos])
   CATCH loError
        oWndBase.Title := PROGRAM+VERSION+COPYRIGHT
   END
Return

*------------------------------------------------------------------------------*
Procedure primero()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      //( Alias() )->( DbGotop() )
      //keybd_event(VK_HOME)
      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      oBrowse:value := { 1, 1 }
      oBrowse:setfocus()
      oBrowse:GoTop()

   Endif
return

*------------------------------------------------------------------------------*
Procedure anterior()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      //( Alias() )->( dBSkip ( -1 ) )
      //keybd_event(VK_UP)
      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      oBrowse:setfocus()
      oBrowse:Up()

   Endif
return

*------------------------------------------------------------------------------*
Procedure siguiente()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      //( Alias() )->( dBSkip (1) )
      //if  ( Alias() )->( recno() ) = ( Alias() )->( LastRec()+1 )
      //    ( Alias() )->( DbGoBottom() )
      //    keybd_event(VK_END)
      //endif
      //keybd_event(VK_DOWN)

      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      oBrowse:setfocus()
      oBrowse:Down()

   Endif
return

*------------------------------------------------------------------------------*
Procedure ultimo()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      ( Alias() )->( DbGoBottom() )
      oBrowse := GetControlObject( Browse_n(), "oWndBase" )
      oBrowse:value := { ( Alias() )->( LastRec() ) , 1 }
   Endif
return

*------------------------------------------------------------------------------*
Function Browse_n()
*------------------------------------------------------------------------------*
Local cAreaPos, cBrowse_n
   cAreaPos  := AllTrim( Str( ( Alias() )->( Select( oWndBase.Tab_1.caption( oWndBase.Tab_1.value ) ) ) ) )
   cBrowse_n := "Browse_"+cAreaPos
Return( cBrowse_n )

*------------------------------------------------------------------------------*
Procedure primeraC()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      ( Alias() )->( DbGoto( oBrowse:value[1] ) )
      oBrowse:value := { ( Alias() )->( recno() ), 1 }
      oBrowse:setfocus()
   Endif
return

*------------------------------------------------------------------------------*
Procedure IzquierdaC()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      // keybd_event(VK_LEFT)
      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      ( Alias() )->( DbGoto( oBrowse:value[1] ) )
      oBrowse:setfocus()
      oBrowse:Left()
   Endif
return

*------------------------------------------------------------------------------*
Procedure DerechaC()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      //keybd_event(VK_RIGHT)
      oBrowse := GetControlObject(Browse_n(),"oWndBase")
      ( Alias() )->( DbGoto( oBrowse:value[1] ) )
      oBrowse:setfocus()
      oBrowse:Right()
   Endif
return

*------------------------------------------------------------------------------*
Procedure ultimaC()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      oBrowse := GetControlObject( Browse_n(),"oWndBase" )
      ( Alias() )->( DbGoto( oBrowse:value[1] ) )
      oBrowse:value := { ( Alias() )->( recno() ), ( Alias() )->( Fcount() )+1 }
      oBrowse:setfocus()
   Endif
return

*------------------------------------------------------------------------------*
Procedure Append()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      If IsControlDefine(&(Browse_n()),oWndBase)
         Nuevo := .T.
         Administradbf( oWndBase.&(Browse_n()).Value[1] )
         Siguiente()
      Endif
   Endif
return
*------------------------------------------------------------------------------*
Procedure Edit()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      aRec := oWndBase.&(Browse_n()).Value
      ( Alias() )->( DbGoto( aRec[1] ) )
      oWndBase.&(Browse_n()).Value := ( Alias() )->( RecNo() )
      oWndBase.&(Browse_n()).SetFocus
   Endif
Return
*------------------------------------------------------------------------------*
Procedure JumpEdit(nOpt)
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      If nOpt == 1
         if Fcount() < 16
            EDIT WORKAREA ( oWndBase.Tab_1.caption( oWndBase.Tab_1.value ) )
         Else
            MsgInfo("EDIT does not display workarea with more than 16 Fields",PROGRAM)
         Endif
      Else
         EDIT EXTENDED WORKAREA ( oWndBase.Tab_1.caption( oWndBase.Tab_1.value ) )
      Endif
      Actualizar()
   Endif
Return

*------------------------------------------------------------------------------*
Procedure Actualizar()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      oWndBase.&(Browse_n()).SetFocus
      oWndBase.&(Browse_n()).Refresh
   Endif
Return
*------------------------------------------------------------------------------*
Procedure MueveRec()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      oBrowse := GetControlObject( Browse_n(),"oWndBase" )
      oBrowse:value := { ( Alias() )->( Recno() ) , 1 }
   Endif
Return

*------------------------------------------------------------------------------*
Procedure PackBase()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      if MsgYesNo("Are you sure Pack Database?",PROGRAM)
         Pack
         Primero()
      Endif
   Endif
Return
*------------------------------------------------------------------------------*
Procedure ZapBase()
*------------------------------------------------------------------------------*
   If !Empty( Alias() )
      if MsgYesNo("DANGER!! - Are you sure Zap Database?",PROGRAM)
         Zap
         Actualizar()
      Endif
   Endif
Return
*------------------------------------------------------------------------------*
Procedure GoToRecord()
*------------------------------------------------------------------------------*
    Local VamosA
    If !Empty( Alias() )
       nUltimo := ( Alias() )->( LastRec() )
       VamosA := val(InputBox( 'Goto Record:' , PROGRAM ))
       VamosA := iif(VamosA>nUltimo,nUltimo,VamosA)
       If .Not. Empty(VamosA)
          ( Alias() )->( dbgoto(VamosA) )
          If VamosA == nUltimo
             Ultimo()
          Else
             MueveRec()
          Endif
       EndIf
    Endif
Return

*--------------------------------------------------------*
Procedure InsertRecord()
*--------------------------------------------------------*
   If !Empty( Alias() )
      If MsgYesNo( "A blank record will be inserted before the current record!!!" + Hb_OSNewLine() + "Are You sure ?", "Insert Record")
         aRec := oWndBase.&(Browse_n()).Value
         ( Alias() )->( DbGoTo( aRec[1] ) )
         DbInsert(.T.)
         Actualizar()
      Endif
   Endif
Return

*--------------------------------------------------------*
Procedure BackColorBrowse()
*--------------------------------------------------------*
   Local nc
   If !Empty( Alias() )
   If IsControlDefine(&(Browse_n()),oWndBase)
      aBackClr := GetColor()
      For nc := 1 to oWndBase.Tab_1.ItemCount
          cAreaPos  := AllTrim( Str( ( Alias() )->( Select( oWndBase.Tab_1.caption( nc ) ) ) ) )
          cBrowse_n := "Browse_"+cAreaPos
          oWndBase.&(cBrowse_n).Backcolor := aBackClr
      Next
      SaveArchIni(cBaseFolder+'\')
      Actualizar()
   Endif
   Endif
Return
*--------------------------------------------------------*
Procedure FontColorBrowse()
*--------------------------------------------------------*
   Local nc
   If !Empty( Alias() )
   If IsControlDefine(&(Browse_n()),oWndBase)
      aBackClr := GetColor()
      For nc := 1 to oWndBase.Tab_1.ItemCount
          cAreaPos  := AllTrim( Str( ( Alias() )->( Select( oWndBase.Tab_1.caption( nc ) ) ) ) )
          cBrowse_n := "Browse_"+cAreaPos
          oWndBase.&(cbrowse_n).Fontcolor := aBackClr
      Next
      SaveArchIni(cBaseFolder+'\')
      Actualizar()
   Endif
   Endif
Return