#include "FiveTouch.ch"
#include "FiveTouch.ch"
#xcommand DEFAULT <uVar1> := <uVal1> ;
[, <uVarN> := <uValN> ] => ;
<uVar1> := If( <uVar1> == nil, <uVal1>, <uVar1> ) ;;
[ <uVarN> := If( <uVarN> == nil, <uValN>, <uVarN> ); ]
function Main()
LOCAL oBtnCancelJ
LOCAL aBtnText:={"Incluir","Inspec Métodos","Modificar","Insp. Data","Salir"}
LOCAL aBtn :=ARRAY(LEN(aBtnText))
PRIVATE oDlgBrw,oBrw
SET DELETE ON
SET CENTURY ON
SET DATE FRENCH
FT_CREATE_TABLES()
USE ("FT_USER.DBF")
GO TOP
IF RECCOUNT()=0
FT_EDITUSER(NIL)
ENDIF
DEFINE DIALOG oDlgBrw TITLE "Usuarios" ;
SIZE 460, 600
@ 30, 0 BROWSE oBrw OF oDlgBrw ;
SIZE 458, 600 ;
HEADERS "Id", "Nombre","Fecha","Activo" ;
FIELDS FIELD->USR_ID, FIELD->USR_NAME, FIELD->USR_DATE,FIELD->USR_ACTIVE
@ 0, BCOL(1) BUTTON aBtn[1] PROMPT aBtnText[1] OF oDlgBrw ;
ACTION FT_EDITUSER(NIL)
@ 0, BCOL(2) BUTTON aBtn[2] PROMPT aBtnText[2] OF oDlgBrw ;
ACTION FT_INSPECT(oBrw)
@ 0, BCOL(3) BUTTON aBtn[3] PROMPT aBtnText[3] OF oDlgBrw ;
ACTION FT_INSPECT(oBrw:currentIndex(1):DATA)
@ 0, BCOL(4) BUTTON aBtn[4] PROMPT aBtnText[4] OF oDlgBrw ;
ACTION FT_INSPECT_DATA(oBrw)
@ 0, BCOL(5) BUTTON aBtn[5] PROMPT aBtnText[5] OF oDlgBrw ;
ACTION oDlgBrw:End()
ACTIVATE DIALOG oDlgBrw CENTERED
// FT_INSPECT(oBrw:currentIndex(1)
//MsgInfo(oBrw:record(oBrw:currentIndex(1):row()).value(index.column()).toString());
//gInfo(oBrw:currentIndex(1):column())
//FT_EDITUSER()
CLOSE ALL
RETURN NIL
FUNCTION BCOL(nCol)
RETURN 81*(nCol-1)+10
FUNCTION FT_EDITUSER(cId_User)
LOCAL oDlg,I,oBtnOk,oBtnCancel
LOCAL oSay:=ARRAY(3)
PRIVATE oId,oName,oDate,oActive
PRIVATE cId:=SPACE(03),cName:=SPACE(100),dDate:=DTOC(DATE()),lActive:=.T.
PRIVATE aSay :={"ID" ,"Nombre","Fecha"}
PRIVATE aVars:={"cId","cName" ,"dDate"}
IF !Empty(cId_User)
MsgAlert(cId_User)
GO TOP
LOCATE FOR FIELD->USR_ID=cId_User
cId :=FIELD->USR_ID
cName :=FIELD->USR_NAME
dDate :=CTOD(FIELD->USR_DATE)
lActive:=FIELD->USR_ACTIVE
ENDIF
DEFINE DIALOG oDlg TITLE "Crear Usuario <AdaptaPro>" ;
SIZE 300, 200
FOR I =1 TO LEN(aSay)
@ CROW(I),10 SAY oSay[I] PROMPT aSay[I] OF oDlg
NEXT I
@ CROW(1),060 GET oId VAR cId OF oDlg
oId:setFixedSize(30,24)
oId:setInputMask("00") // Solo Numérico
@ CROW(2),060 GET oName VAR cName OF oDlg
oName:setFixedSize(120,24)
@ CROW(3),060 GET oDate VAR dDate OF oDlg
oDate:setFixedSize(80,24)
oDate:setInputMask("00/00/0000")
@ CROW(1),160 CHECKBOX oChk VAR lActive OF oDlg ;
PROMPT "Active"
/*
@ CROW(4), 1 BUTTON oBtnOk PROMPT "Inspect" OF oDlg ;
ACTION FT_INSPECT(oId)
*/
@ CROW(5), 110 BUTTON oBtnOk PROMPT "Ok" OF oDlg ;
ACTION FT_SAVEUSR(oDlg)
@ CROW(5),200 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
FT_INSPECT(oId)
return nil
FUNCTION CROW(nRow)
RETURN 30*(nRow-1)+20
/*
// Guardar Registro
*/
FUNCTION FT_SAVEUSR(oDlg)
LOCAL cMsg:="",i,uValue
FOR I=1 TO LEN(aVars)
if Empty(&(aVars[I]))
cMsg:=cMsg+IF(Empty(cMsg),"",CRLF)+aSay[I]
ENDIF
NEXT I
IF !Empty(cMsg)
MsgInfo(cMsg,"Falta campo(s)")
RETURN .F.
ENDIF
// USE ("FT_USER.DBF")
GO TOP
LOCATE FOR FIELD->USR_ID=cId
IF !FOUND()
APPEND BLANK
ENDIF
REPLACE FIELD->USR_ID WITH cId,;
FIELD->USR_NAME WITH cName,;
FIELD->USR_DATE WITH CTOD(dDate),;
FIELD->USR_ACTIVE WITH lActive
COMMIT
// USE
IF !MsgYesNo("Desea Agregar Otro Usuario")
oDlg:End()
ENDIF
FOR I=1 TO LEN(aVars)
if Empty(&(aVars[I]))
cMsg:=cMsg+IF(Empty(cMsg),"",CRLF)+aSay[I]
ENDIF
NEXT I
// Las variables debe ser vaciadas
oId:SetText(CTOEMPTY(cId))
oName:SetText(CTOEMPTY(cName))
oDate:SetText(CTOEMPTY(dDate))
RETURN NIL
FUNCTION FT_CREATE_TABLES()
LOCAL I
LOCAL aTables:={}
LOCAL aStruct:={}
LOCAL aIndex :={}
AADD(aStruct,{"USR_ID", "C",003,0})
AADD(aStruct,{"USR_NAME", "C",120,0})
AADD(aStruct,{"USR_DATE" , "D",008,0})
AADD(aStruct,{"USR_ACTIVE","L",001,0})
AADD(aTables,{"FT_USER.DBF",aStruct,aIndex})
FOR I=1 TO LEN(aTables)
IF !FILE(aTables[I,1])
dbcreate(aTables[I,1],aTables[I,2])
ENDIF
NEXT I
RETURN NIL
/*
// Devuelve Vacio
*/
FUNCTION CTOEMPTY(uValue,cType,nLen)
DEFAULT cType:=ValType(uValue)
IF cType="C" .AND. EMPTY(nLen) .AND. ValType(uValue)="C"
nLen:=LEN(uValue)
ENDIF
DO CASE
CASE ValType(uValue)="U".AND.cType$"CM"
uValue:=SPACE(nLen)
CASE ValType(uValue)="U".AND.cType="N"
uValue:=0.00
CASE ValType(uValue)="U".AND.cType="D"
uValue:=CTOD("")
CASE ValType(uValue)="U".AND.cType="L"
uValue:=.F.
CASE ValType(uValue)="C"
uValue:=SPACE(nLen)
CASE ValType(uValue)="N"
uValue:=0
CASE ValType(uValue)="D"
uValue:=CTOD("")
CASE ValType(uValue)="L"
uValue:=.F.
ENDCASE
RETURN uValue
FUNCTION MsgAlert(cMsg1,cMsg2)
return MsgInfo(cMsg1,cMsg2)
FUNCTION FT_INSPECT(oObj)
LOCAL aMetodos:=ASORT(__objGetMethodList( oObj )) // Lectura de Metodos
ViewArray(aMetodos,2,oObj)
RETURN NIL
function VIEWARRAY(aData,nCol,oObj)
LOCAL I,U
local oDlg := QDialog()
local oLayout := QVBoxLayout()
local oBrw := QTableView( oDlg )
local oModel := QStandardItemModel( LEN(aData), nCol, oDlg )
oModel:SetHorizontalHeaderItem( 0, QStandardItem( "Header1" ) )
oModel:SetHorizontalHeaderItem( 1, QStandardItem( "Header2" ) )
FOR I=1 TO LEN(aData)
IF ValType(aData[I])="A" .AND. LEN(aData[I])>1
FOR U=1 TO LEN(aData[I])
oModel:SetItem( I-1, U-1, QStandardItem( aData[I,U] ) )
NEXT U
ELSE
oModel:SetItem( I-1, 0, QStandardItem( aData[I] ) )
oModel:SetItem( I-1, 1, QStandardItem( STR(I) ) )
ENDIF
NEXT I
oDlg:SetLayout( oLayout )
oBrw:SetModel( oModel )
oLayout:AddWidget( oBrw )
oDlg:SetWindowTitle( "Inspector, Clase "+oObj:ClassName() )
oDlg:Resize( 500, 400 )
oDlg:Center()
oDlg:Exec()
return nil
FUNCTION VAL2CHAR_( uValue )
LOCAL cResult := "NIL", cType := VALTYPE( uValue )
DO CASE
CASE cType == "A"
cResult := "{ ... }"
CASE cType == "C"
cResult := '"' + uValue + '"'
CASE cType == "D"
cResult := DTOC( uValue )
CASE cType == "L"
cResult := IIF( uValue, ".T.", ".F." )
CASE cType == "N"
cResult := LTRIM( STR( uValue))
CASE cType == "O"
cResult := "Object"
CASE cType == "B"
cResult := "{ || ... }"
ENDCASE
RETURN cResult
FUNCTION OSEND(oObj,cMsg)
RETURN __ObjSendMsg( oObj, cMsg )
function FT_FOLDER()
local aFld:=ARRAY(3)
local oDlg := QDialog()
local oLayout := QVBoxLayout()
local oFolder := QTabWidget( oDlg )
oDlg:SetLayout( oLayout )
oLayout:AddWidget( oFolder )
oDlg:SetWindowTitle( "A folder" )
oDlg:Resize( 400, 400 )
oFolder:AddTab( QWidget(), "One" )
oFolder:AddTab( QWidget(), "Two" )
oFolder:AddTab( QWidget(), "Three" )
oDlg:Center()
oDlg:Exec()
FT_INSPECT_DATA(oFolder)
return nil
FUNCTION FT_INSPECT_DATA(oObj)
LOCAL aLista:= ASort( __ClassSel( oObj:ClassH ) )
ViewArray(aLista,2,oObj)
RETURN NIL