Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Codebook - aerror prob
Message
 
À
12/08/1997 08:43:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00043959
Message ID:
00044404
Vues:
31
You're right,
There are some changes in cDataBehavior.

Here is the class browser "export" of mine. Check the copyright method for a description of changes.

José

***
**************************************************
*-- Class: cdatabehavior (c:\cdbk30\common30\libs\cbhavior.vcx)
*-- ParentClass: ccustom (c:\cdbk30\common30\libs\ccontrls.vcx)
*-- BaseClass: custom
*-- The superclass for all data behavior classes.
*
#INCLUDE "c:\cdbk30\common30\include\framincl.h"
*
DEFINE CLASS cdatabehavior AS ccustom


*-- Name of the table that was selected during the last error
cerrortable = .NULL.
cversion = 01.00.0002
Name = "cdatabehavior"


*-- Returns the first record.
PROCEDURE first
LOCAL lnRecNo

lnRecNo = RECNO()

LOCATE

*-- If we're still on the same record,
*-- return cancel code
IF lnRecNo = RECNO()
RETURN FILE_CANCEL
ENDIF

IF EOF()
RETURN FILE_EOF
ENDIF

RETURN FILE_BOF
ENDPROC


*-- Returns the prior record.
PROCEDURE prior
LOCAL lnRecNo, ;
lnRetVal

lnRetVal = FILE_OK

IF !BOF()
lnRecNo = RECNO()
SKIP -1
*-- If we're at BOF, return BOF code
IF BOF()
RETURN FILE_BOF
ENDIF

*-- If we're still on the same record,
*-- return cancel code
IF lnRecNo = RECNO()
RETURN FILE_CANCEL
ELSE
IF !BOF()
SKIP -1
lnRetVal = IIF(BOF(), FILE_BOF, lnRetVal)
IF !BOF()
SKIP
ENDIF
ENDIF
ENDIF

ELSE
lnRetVal = FILE_BOF
ENDIF

RETURN lnRetVal
ENDPROC


*-- Returns the next record.
PROCEDURE next
LOCAL lnRecNo, ;
lnRetVal

lnRetVal = FILE_OK

IF !EOF()
lnRecNo = RECNO()
SKIP

IF EOF()
SKIP -1
lnRetVal = FILE_EOF
ELSE
*-- If we're still on the same record,
*-- return cancel code
IF lnRecNo = RECNO()
lnRetVal = FILE_CANCEL
ELSE
SKIP
lnRetVal = IIF(EOF(), FILE_EOF, lnRetVal)
SKIP -1
ENDIF
ENDIF
ELSE
lnRetVal = FILE_EOF
ENDIF

RETURN lnRetVal
ENDPROC


*-- Returns the last record.
PROCEDURE last
LOCAL lnRecNo

lnRecNo = RECNO()
GO BOTTOM

*-- If we're still on the same record,
*-- return cancel code
IF lnRecNo = RECNO()
RETURN FILE_CANCEL
ENDIF

RETURN FILE_EOF
ENDPROC


*-- Saves the current record.
PROCEDURE save
LPARAMETERS tlAllRows, tlForce
LOCAL lnRetVal, ;
laError[AERROR_NUMCOLUMNS], ;
loSelect

*-- We save and restore the work area since VFP
*-- will not restore the work area if a validation rule
*-- fails during a TABLEUPDATE().
loSelect = CREATEOBJECT("CSelect")

*-- Mark primary key as being updated if using a view.
*-- This is necessary if we're pre-fetching primary key
*-- values.
*{ Commented at 15:39:36 on June 09, 97
* IF CURSORGETPROP("SOURCETYPE") <> DB_SRCTABLE
* IF IsAdding(ALIAS())
* lcPrimaryKey = CURSORGETPROP("KEYFIELDLIST")
* =SETFLDSTATE(lcPrimaryKey, 4)
* ENDIF
* ENDIF
IF CURSORGETPROP("SOURCETYPE") <> DB_SRCTABLE
*-- IF the cursor is table buffered, scan all
*-- records, and set the state of the primary key
*-- field to "edited"
IF CURSORGETPROP("BUFFERING") = DB_BUFOPTTABLE
SCAN
IF IsAdding(ALIAS())
this.SetPrimaryKeyFieldState(FLDSTATE_APPEND_EDITED)
ENDIF
ENDSCAN
ELSE
IF IsAdding(ALIAS())
this.SetPrimaryKeyFieldState(FLDSTATE_APPEND_EDITED)
ENDIF
ENDIF
ENDIF
*} End Commenting 15:39:36 - June 09, 97


IF TABLEUPDATE(tlAllRows, tlForce)
lnRetVal = FILE_OK
ELSE
*-- CHANGE - JCM - June 09, 1997 - 13:22:33
*-- save the currently selected table
this.cErrorTable = ALIAS()
*-- ENDCHANGE - JCM - June 09, 1997 - 13:23:04

*-- Return error number of what went wrong
=AERROR(laError)
lnRetVal = laError[AERROR_ERROR]
ENDIF
RETURN lnRetVal
ENDPROC


*-- Cancels changes to the current record.
PROCEDURE cancel
LPARAMETERS tlAllRows
LOCAL lnRetVal

=TABLEREVERT(tlAllRows)
lnRetVal = FILE_OK

IF lnRetVal = FILE_OK
IF EOF() AND !BOF()
SKIP -1
ENDIF
ENDIF

RETURN lnRetVal
ENDPROC


*-- Deletes the current record.
PROCEDURE delete
LOCAL lnRecNo, ;
lnRetVal, ;
laError[AERROR_NUMCOLUMNS], ;
lnOldArea

lnRecNo = RECNO()
lnRetVal = FILE_OK
lnOldArea = SELECT()

DELETE
*-- If we are using table buffering, the we assume that the user will
*-- have the ability to revert all deleted records. Therefore, do not
*-- issue a TABLEUPDATE().
IF INLIST(CURSORGETPROP("BUFFERING"), DB_BUFOPTRECORD, DB_BUFLOCKRECORD) ;
AND !TABLEUPDATE()
SELECT (lnOldArea)
=TABLEREVERT()
*-- Return error number of what went wrong
=AERROR(laError)
lnRetVal = laError[AERROR_ERROR]
ELSE
IF !EOF()
SKIP
IF EOF()
SKIP -1
IF !BOF()
lnRetVal = FILE_OK
ELSE
lnRetVal = FILE_NORECORDS
ENDIF
ENDIF
ENDIF
ENDIF

SELECT (lnOldArea)
RETURN lnRetVal
ENDPROC


*-- Adds a new record.
PROCEDURE new
APPEND BLANK

*-- Make sure we have a blank record.
*{ Commented at 17:05:43 on December 23, 95
* : 1st errata file
* IF (VAL(GETFLDSTATE(-1)) % VAL(REPLICATE("3", LEN(GETFLDSTATE(-1))))) = 0

*-- obligé de le supprimer provisoirement
*-- voir explications ci-dessous

***IF GETFLDSTATE(-1) = REPLICATE("3", LEN(GETFLDSTATE(-1)))
*} End Commenting 17:05:43 - December 23, 95

RETURN FILE_OK
***ELSE
*** RETURN FILE_CANCEL
***ENDIF

*!* ---------------------------------------------------------------------
*!* Subject: CB3: Views/default vals
*!* From: Martyn Price 74243,151
*!* To: Kevin McNeish [Oak Leaf] 104657,2113
*!* Forum: FOXGANG Sec: 09-3rd Party Products
*!* Msg #: 220947
*!* Date: 14-Dec-96 5:07

*!* Hi Kevin:
*!* A possible bug in CB3 running under VFP5. If you use the new
*!* feature of adding default values in views you will end up with an
*!* error (I forget which) when you add a new record and save it. The
*!* primary key field of the underlying table fails to get updated. The
*!* error is in cDataBehavior.New(). After appending a blank record a
*!* check for an unedited record (with GETFLDSTATE(-1)) shows that the
*!* record has been edited. FILE_CANCEL is returned, but no error
*!* message results. On saving, the program bombs. Looking at the code
*!* in this method I can't quite see why this check is performed. I
*!* guess we must now start using cLocalViewBehavoir instead of the
*!* default cDataBehavior (as soon as someone writes the method code
*!* <g>).
*!*
*!* Martyn
*!*
*!*
*!* There is 1 Reply
*!*


*!* ---------------------------------------------------------------------
*!* Subject: CB3: Views/default vals
*!* From: Kevin McNeish [Oak Leaf] 104657,2113
*!* To: Martyn Price 74243,151
*!* Forum: FOXGANG Sec: 09-3rd Party Products
*!* Msg #: 221036
*!* Date: 16-Dec-96 3:46

*!* Martyn,
*!*
*!* Thanks for the info...I'll look into it.
*!*
*!* Regards,
*!* Kevin McNeish
ENDPROC


*-- Requeries the dataset.
PROCEDURE requery
LOCAL lnRetVal
lnRetVal = FILE_CANCEL

IF CURSORGETPROP("SOURCETYPE") <> DB_SRCTABLE
lnRetVal = REQUERY()
ENDIF

RETURN lnRetVal
ENDPROC


PROCEDURE copyright
* Class.............: CDataBehavior
* Author............: Paul Bienick
* Project...........: Codebook 3.0
* Created...........: 07/19/95 13:08:28
* Copyright.........: (c) Flash Creative Management, Inc., 1995
* Major change list.: *-- CHANGE - JCM - June 09, 1997 - 13:20:30
* : added a new property, cErrorTable to get around the VFP 5 AERROR() problem
* : added a new method, SetPrimaryFieldState() to avoid Codebook throwing away
* : prefetched keys on table-buffered views.
* : Modified Save() for the same reason
ENDPROC


PROCEDURE setprimarykeyfieldstate
*-- CHANGE - JCM - June 09, 1997 - 15:31:15
LPARAMETERS tnFieldState
LOCAL lcPrimaryKey

*-- Get the list of key fields for the the currently selected cursor

lcPrimaryKey = CURSORGETPROP("KEYFIELDLIST")

*-- ignore all other keys in list, except the first

IF "," $ lcPrimaryKey
lcPrimaryKey = SUBSTR(lcPrimaryKey, 1, AT(",", lcPrimaryKey) - 1 )
ENDIF

*-- set the field state of the primary key to the specified value
=SETFLDSTATE(lcPrimaryKey, tnFieldState)
ENDPROC


ENDDEFINE
*
*-- EndDefine: cdatabehavior
**************************************************
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform