Mantenimientos DBF: Virtual Error
Publicado: Sab Jul 23, 2005 5:42 am
Que hago mal aqui?
Me marca:
Error Method "AddNew()" not declared in class tDBFRecords
Error Method "Delete()" not declared in class tDBFRecords
Error Method "Edit()" not declared in class tDBFRecords
Class tDBFRecords From tForm
COMPONENT oDBBrowse1
COMPONENT oDataSet
COMPONENT oDataSource
PROPERTY nTag INIT 1 WRITE InLine ::SetTag( Value )
DATA oTagMenu
Data oTagBtn
Data aTags
DATA oToolBar
Data oRebarBand
DATA oFilterBtn
Data bEdit
METHOD Addnew() VIRTUAL
Method Delete() VIRTUAL
Method Edit() VIRTUAL
METHOD SetTag( Value )
METHOD Filter()
Method FormInitialize( oSender )
EndClass
METHOD FormInitialize( oSender ) CLASS tDBFRecords
LOCAL oSortMenu
LOCAL aTags
LOCAL nFor
//este menu es para los indices del cdx.
oSortMenu := TMenu():Create( Self, .t. )
::aTags := ::oDataSet:GetTags()
FOR nFor := 1 to len( ::aTags )
WITH OBJECT TMenuItem():New( oSortMenu )
:cText := "Orden: " + ::aTags[ nFor ]
:Cargo := nFor
:OnClick := {|o| ::nTag := o:Cargo }
:Create()
END
NEXT
WITH OBJECT ::oToolBar := TToolBar():New( ::oRebar1 )
:lList := .t.
:lAutoSize := .t.
:Create()
::oTagBtn := :AddButton( "", "bOrden",,, "Orden: ", {|| ::nTag++ },
oSortMenu )
::nTag := 1
WITH OBJECT ::oFilterBtn := :AddButton( "", "bFiltro",,, "Crear
Filtro", {|| ::Filter() } )
:lChecked := .f.
END
:AddSeparator(10)
:AddButton( "", "bInicio",,, "Primer Registro", {||
::oDBBrowse1:GoTop() } )
:AddButton( "", "bAnterior",,, "Registro Anterior", {||
::oDBBrowse1:GoUp() } )
:AddButton( "", "bSiguiente",,, "Siguiente Registro", {||
::oDBBrowse1:GoDown() } )
:AddButton( "", "bUltimo",,, "Último Registro", {||
::oDBBrowse1:GoBottom() } )
:AddSeparator(10)
:AddButton( "", "bNuevo",,, "Nuevo Registro", {|| ::AddNew() } )
:AddButton( "", "bEditar",,, "Editar Registro", {|| ::Edit() } )
:AddButton( "", "bEliminar",,, "Borrar Registro", {|| ::Delete() } )
//:AddButton( "", "bMovimientos",,, "Ver Movimientos", {||
TFrmMovtos():New( Self ):ShowModal() } )
:AddSeparator(10)
:AddButton( "", "XA_BMP_PRINTER",,, "Impresora", {|| Msginfo( "Not
available" ) } )
:AddButton( "", "XA_BMP_EXIT",,, "Regresar al Menú", {|| ::Close() } )
END
WITH OBJECT ::oRebarBand := TRebarBand():New( ::oRebar1 )
:oControl := ::oToolBar
:Create()
END
Return ( Self )
//---------------------------------------------------------- --------------------
// Rutina para Agregar Registros
//---------------------------------------------------------- --------------------
METHOD AddNew() CLASS tDBFRecords
LOCAL oFrm
WITH OBJECT oFrm := Eval(::bEdit)
:cText := "Agregar Nuevo"
::oDataSet:AddNew()
:ShowModal()
if :nModalResult == mrOK
::oDataSet:Update()
::oDBBrowse1:Refresh()
else
::oDataSet:Cancel()
endif
END WITH
RETURN NIL
//---------------------------------------------------------- --------------------
// Rutina para Eliminar Registros
//---------------------------------------------------------- --------------------
METHOD Delete() CLASS tDBFRecords
if MsgYesNo( "Desea Eliminar el Regisro Actual?" )
if ::oDataSet:Delete()
If ::oDataSet:Eof()
::oDataSet:Skip( -1 )
endif
::oDBBrowse1:Refresh()
endif
endif
RETURN NIL
//---------------------------------------------------------- --------------------
// Rutina para Editar Registros
//---------------------------------------------------------- --------------------
METHOD Edit() CLASS tDBFRecords
LOCAL oFrm
WITH OBJECT oFrm := Eval(::bEdit)
:cText := "Editando Registro " // + ::oDataset:Field[3]
::oDataSet:Edit()
:ShowModal()
if :nModalResult == mrOK
::oDataSet:Update()
::oDBBrowse1:RefreshCurrent()
else
::oDataSet:Cancel()
endif
END WITH
RETURN NIL
//---------------------------------------------------------- --------------------
METHOD SetTag( nTag ) CLASS tDBFRecords
if nTag > len( ::aTags )
nTag := 1
endif
::FnTag := nTag
if ::oDataSet != nil
::oDataSet:OrdSetFocus( nTag )
endif
if ::oDBBrowse1 != nil
::oDBBrowse1:Refresh( .t. )
endif
if ::oTagBtn != nil
::oTagBtn:cText := "Orden: " + ::aTags[ nTag ]
endif
RETURN nil
//---------------------------------------------------------- --------------------
METHOD Filter() CLASS tDBFRecords
local lFilterBar
WITH OBJECT ::oFilterBtn
lFilterBar := !:lChecked
:lChecked := lFilterBar
END
WITH OBJECT ::oDBBrowse1
:lFilterBar := !:lFilterBar
END
RETURN NIL
Saludos.
Ramón Zea
Me marca:
Error Method "AddNew()" not declared in class tDBFRecords
Error Method "Delete()" not declared in class tDBFRecords
Error Method "Edit()" not declared in class tDBFRecords
Class tDBFRecords From tForm
COMPONENT oDBBrowse1
COMPONENT oDataSet
COMPONENT oDataSource
PROPERTY nTag INIT 1 WRITE InLine ::SetTag( Value )
DATA oTagMenu
Data oTagBtn
Data aTags
DATA oToolBar
Data oRebarBand
DATA oFilterBtn
Data bEdit
METHOD Addnew() VIRTUAL
Method Delete() VIRTUAL
Method Edit() VIRTUAL
METHOD SetTag( Value )
METHOD Filter()
Method FormInitialize( oSender )
EndClass
METHOD FormInitialize( oSender ) CLASS tDBFRecords
LOCAL oSortMenu
LOCAL aTags
LOCAL nFor
//este menu es para los indices del cdx.
oSortMenu := TMenu():Create( Self, .t. )
::aTags := ::oDataSet:GetTags()
FOR nFor := 1 to len( ::aTags )
WITH OBJECT TMenuItem():New( oSortMenu )
:cText := "Orden: " + ::aTags[ nFor ]
:Cargo := nFor
:OnClick := {|o| ::nTag := o:Cargo }
:Create()
END
NEXT
WITH OBJECT ::oToolBar := TToolBar():New( ::oRebar1 )
:lList := .t.
:lAutoSize := .t.
:Create()
::oTagBtn := :AddButton( "", "bOrden",,, "Orden: ", {|| ::nTag++ },
oSortMenu )
::nTag := 1
WITH OBJECT ::oFilterBtn := :AddButton( "", "bFiltro",,, "Crear
Filtro", {|| ::Filter() } )
:lChecked := .f.
END
:AddSeparator(10)
:AddButton( "", "bInicio",,, "Primer Registro", {||
::oDBBrowse1:GoTop() } )
:AddButton( "", "bAnterior",,, "Registro Anterior", {||
::oDBBrowse1:GoUp() } )
:AddButton( "", "bSiguiente",,, "Siguiente Registro", {||
::oDBBrowse1:GoDown() } )
:AddButton( "", "bUltimo",,, "Último Registro", {||
::oDBBrowse1:GoBottom() } )
:AddSeparator(10)
:AddButton( "", "bNuevo",,, "Nuevo Registro", {|| ::AddNew() } )
:AddButton( "", "bEditar",,, "Editar Registro", {|| ::Edit() } )
:AddButton( "", "bEliminar",,, "Borrar Registro", {|| ::Delete() } )
//:AddButton( "", "bMovimientos",,, "Ver Movimientos", {||
TFrmMovtos():New( Self ):ShowModal() } )
:AddSeparator(10)
:AddButton( "", "XA_BMP_PRINTER",,, "Impresora", {|| Msginfo( "Not
available" ) } )
:AddButton( "", "XA_BMP_EXIT",,, "Regresar al Menú", {|| ::Close() } )
END
WITH OBJECT ::oRebarBand := TRebarBand():New( ::oRebar1 )
:oControl := ::oToolBar
:Create()
END
Return ( Self )
//---------------------------------------------------------- --------------------
// Rutina para Agregar Registros
//---------------------------------------------------------- --------------------
METHOD AddNew() CLASS tDBFRecords
LOCAL oFrm
WITH OBJECT oFrm := Eval(::bEdit)
:cText := "Agregar Nuevo"
::oDataSet:AddNew()
:ShowModal()
if :nModalResult == mrOK
::oDataSet:Update()
::oDBBrowse1:Refresh()
else
::oDataSet:Cancel()
endif
END WITH
RETURN NIL
//---------------------------------------------------------- --------------------
// Rutina para Eliminar Registros
//---------------------------------------------------------- --------------------
METHOD Delete() CLASS tDBFRecords
if MsgYesNo( "Desea Eliminar el Regisro Actual?" )
if ::oDataSet:Delete()
If ::oDataSet:Eof()
::oDataSet:Skip( -1 )
endif
::oDBBrowse1:Refresh()
endif
endif
RETURN NIL
//---------------------------------------------------------- --------------------
// Rutina para Editar Registros
//---------------------------------------------------------- --------------------
METHOD Edit() CLASS tDBFRecords
LOCAL oFrm
WITH OBJECT oFrm := Eval(::bEdit)
:cText := "Editando Registro " // + ::oDataset:Field[3]
::oDataSet:Edit()
:ShowModal()
if :nModalResult == mrOK
::oDataSet:Update()
::oDBBrowse1:RefreshCurrent()
else
::oDataSet:Cancel()
endif
END WITH
RETURN NIL
//---------------------------------------------------------- --------------------
METHOD SetTag( nTag ) CLASS tDBFRecords
if nTag > len( ::aTags )
nTag := 1
endif
::FnTag := nTag
if ::oDataSet != nil
::oDataSet:OrdSetFocus( nTag )
endif
if ::oDBBrowse1 != nil
::oDBBrowse1:Refresh( .t. )
endif
if ::oTagBtn != nil
::oTagBtn:cText := "Orden: " + ::aTags[ nTag ]
endif
RETURN nil
//---------------------------------------------------------- --------------------
METHOD Filter() CLASS tDBFRecords
local lFilterBar
WITH OBJECT ::oFilterBtn
lFilterBar := !:lChecked
:lChecked := lFilterBar
END
WITH OBJECT ::oDBBrowse1
:lFilterBar := !:lFilterBar
END
RETURN NIL
Saludos.
Ramón Zea