Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
'Save' as 'Revert'
Message
De
15/03/2001 09:41:17
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, États-Unis
 
 
À
14/03/2001 19:18:18
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00485071
Message ID:
00485332
Vues:
12
IF EMPTY(m.id) OR ISNULL(m.id) OR NOT LEN(CHRTRAN(m.id," ",""))=8
	Messagebox('Please check the ID again.',64)
	ThisForm.Text1.SetFocus()
	RETURN .F.
ENDIF
IF EMPTY(m.name) OR ISNULL(m.name)
	Messagebox('Please check the name again.',64)
	ThisForm.Text3.SetFocus()
	RETURN .F.
ENDIF

rp=RECNO()
IF INDEXSEEK(m.id)
	IF person.id = m.id AND ;
		person.name = m.name AND ;
		person.logon = m.logon
			wait window 'Same stuff'
	ELSE
		Messagebox('This Person ID is already in the database.'+CHR(13)+ ;
					'Duplicate Records will not be saved!',64)
		m.id = person.id
		m.name = person.name
		m.logon = person.logon
	ENDIF
ELSE
	SET DELETED OFF
	IF SEEK(m.id)
		IF DELETED()
			RECALL
			REPLACE name WITH m.name, ;
					logon WITH m.logon
			SET DELETED ON
		ELSE
			IF mode = 'E'
				GOTO rp
				REPLACE id WITH m.id, ;
					logon WITH m.logon, ;
					name WITH m.name, ;
					uplog WITH ALLTRIM(GETENV("USR")), ;
					updated WITH DATE()
				SET DELETED ON
			ELSE  && mode = 'A'
				INSERT INTO person (id,logon,name) VALUES (m.id,m.logon,m.name)
				REPLACE uplog WITH ALLTRIM(GETENV("USR")), ;
						updated WITH DATE()
				SET DELETED ON
			ENDIF
		ENDIF
	ELSE
		IF mode = 'E'
			GOTO rp
			REPLACE id WITH m.id, ;
				logon WITH m.logon, ;
				name WITH m.name, ;
				uplog WITH ALLTRIM(GETENV("USR")), ;
				updated WITH DATE()
			SET DELETED ON
		ELSE  && mode = 'A'
			INSERT INTO person (id,logon,name) VALUES (m.id,m.logon,m.name)
			REPLACE uplog WITH ALLTRIM(GETENV("USR")), ;
					updated WITH DATE()
			SET DELETED ON
		ENDIF
	ENDIF
ENDIF
Sorry to post my 'whole' code in here just like that. Reason is I believe it would be easier to see what I have done to the whole 'Save' button (snipped out the ThisForm.Refresh stuff at end). Please feel free to change anything you see fit.

As I am looking at this once again, I think I am repeating something or just something is not right? If you don't mind, please look it over. BTW, when the form comes up, the PERSON table is already selected. The 'mode' are 'A' for the 'Add' button and 'E' for the 'Edit' button. There are only three fields (m.id, m.name, m.logon) the the user can change and the two other hidden fields (uplog and updated) are for tracking who changed the data. Yeah, I did NOT want to use memory variables, but this is what my supervisor wants (who thinks that VFP is like the DOS dBASE). If I have to change the textbox from memory variable to real fields (m.id, m.name, etc), that's fine.

Again, sorry if this whole code posting is offense. Seriously, I think I am losing my mind in this position, am considering seeking a different job so I can do VFP more liberaty

I did read the whole thing about INDEXSEEK() and still trying to understand it completely (it does not move the record pointer, but it can move it too...)?

Chuck.

>Chuck,

>Looks like you need the following:
>IF INDEXSEEK(m.ID, .T., "Person", "ID")
>    Messagebox('This Person ID is already in the database.'+CHR(13)+ ;
>        'Duplicate Records will not be saved!',64)
>
>    *!* m.ID is already correct.
>    *!* "Refresh" Name and Logon, even if they are the same
>    *!* who cares if they are already the same
>    m.Name = Person.Name
>    m.Logon = Person.Logon
>ELSE
>    *!* Do whatever you do with a new record
>ENDIF
Today is tomorrow's yesterday.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform