Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a correct logic for AutoNumber ??
Message
De
07/09/2001 11:32:58
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Is this a correct logic for AutoNumber ??
Divers
Thread ID:
00553829
Message ID:
00553829
Vues:
41
hello all

My app generates a autonumber in a form,i have this code in Savedata method of a form,let me know will this work fine in a multiuser environment and i generate the autonumber only when the user clicks save is this the correct method ??

Txs


cmdSave Click Method
---------------------

BEGIN TRANSACTION
Thisform.nAutoNumber.Value=autonumber()

SELECT BANKACCT
M_BALANCE=BANKACCT.BALANCE

SELECT LOAN
llloan=TABLEUPDATE(.T.)

SELECT CHECK
M_BALANCE = M_BALANCE - SC_AMOUNT
APPEND BLANK
REPLACE CK_NUM WITH SC_CHECK;
BANK_ID WITH 789012
llcheck=TABLEUPDATE(.T.)

SELECT BANKACCT
REPLACE BALANCE WITH M_BALANCE
llbank=TABLEUPDATE(.T.)

SELECT LOANREIM
APPEND BLANK
REPLACE CK_NUM WITH SC_CHECK
llloanreim=TABLEUPDATE(.T.)

IF llloan and llcheck and llbank and llloanreim = .t.
end transaction
ELSE
messagebox('Another User modified the record,try later',64,'Network Conflict')
rollback
ENDIF

Wait wind 'RECORD ADDED !!! ' timeout .5
RETURN

Stored Procedure Autonumber
----------------------------
FUNCTION Autonumber(tcAlias)
LOCAL lcAlias, ;
lcID, ;
lcOldReprocess, ;
lnOldArea

lnOldArea = SELECT()

IF PARAMETERS() < 1
lcAlias = UPPER(ALIAS())
ELSE
lcAlias = UPPER(tcAlias)
ENDIF

lcOldReprocess = SET('REPROCESS')

*-- Lock until user presses Esc
SET REPROCESS TO AUTOMATIC

IF !USED("COUNTER")
USE dbcTest!counter IN 0
ENDIF

SELECT counter
IF RLOCK()
lcID = counter.nextcheckno
REPLACE counter.nextCheckNo WITH ;
ALLT(STR(VAL(ALLT(lcID)) + 1, LEN(counter.nextcheckno)))
UNLOCK
ENDIF
SELECT (lnOldArea)
SET REPROCESS TO lcOldReprocess
RETURN lcID
RELEASE lcID
ENDFUNC
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform