#include "FiveWin.ch"
#include "XBrowse.ch"
STATIC CODBCO, NOMBCO, CTABCO, CTACTA, GRA, NREG, oDlg, oBrw
STATIC TNUEVO := .T.
FUNCTION MAIN()
LOCAL oWnd, oBar, oMeter, oText
SET Deleted On
SET _3DLOOK ON
lMkDir("DATA")
IF .NOT. FILE ("DATA\BANCO.DBF")
DbCreate( "DATA\BANCO", { { "BCO_CODIGO", "C", 12, 0 },;
{ "BCO_DESCRI", "C", 30, 0 },;
{ "BCO_CUENTA", "C", 20, 0 } } )
ENDIF
USE DATA\BANCO ALIAS BCO NEW
DEFINE WINDOW oWnd
DEFINE BUTTONBAR oBar OF oWnd
DEFINE BUTTON OF oBar ACTION CBANCO(.T.)
DEFINE BUTTON OF oBar ACTION CBANCO(.F.)
oBrw := TXBrowse():New( oWnd )
oBrw:blDblClick := { | nRow, nCol, nKey | CBANCO(.F.)}
oBrw:bKeyDown := { | nKey, nFlags | CBANCO( .F., oBrw )}
oBrw:SetRDD()
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ;
ON INIT oBrw:SetFocus()
RETURN (.T.)
FUNCTION CBANCO(TNUEVO)
STATIC oDlg, oGet, oCodigo, oNombre, oNumero, oCuenta, oBtn
SetGetColorFocus() // change GET colors when focused
SET 3DLook OFF
BCONUEVO(TNUEVO)
DEFINE DIALOG oDlg ;
TITLE IF(TNUEVO, "Incluir Cuenta Bancaria","Modificar Cuenta Bancaria")
@ 1,1 GET oCodigo VAR CODBCO OF oDlg SIZE 40, 10
@ 2,1 GET oNombre VAR NOMBCO OF oDlg SIZE 40, 10
@ 3,1 GET oNumero VAR CTABCO OF oDlg SIZE 40, 10
@ 3.3,1 BUTTON oBtn PROMPT "&Grabar" OF oDlg ;
ACTION (GRABA(.T., TNUEVO), oDlg:END(), oBrw:Refresh())
@ 3.3,10 BUTTON oBtn PROMPT "&Salir" OF oDlg ;
ACTION oDlg:END()
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
STATIC FUNCTION BCONUEVO(TNUEVO)
IF TNUEVO
NREG:=BCO->(RECNO())
CODBCO := SPACE(12)
NOMBCO := SPACE(30)
CTABCO := SPACE(30)
ELSE
NREG:=BCO->(RECNO())
CODBCO := BCO->BCO_CODIGO
NOMBCO := BCO->BCO_DESCRI
CTABCO := BCO->BCO_CUENTA
ENDIF
RETURN (.T.)
STATIC FUNCTION GRABA(GRA, TNUEVO)
IF GRA
IF TNUEVO
BCO->(DBGOTO(NREG))
BCO->(DBAPPEND())
ENDIF
BCO->(RLOCK())
BCO->BCO_CODIGO := CODBCO
BCO->BCO_DESCRI := NOMBCO
BCO->BCO_CUENTA := CTABCO
BCO->(DBUNLOCK())
ENDIF
RETURN (.T.)