Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tableupdate()
Message
From
29/02/2016 13:14:32
 
 
To
29/02/2016 13:04:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01632291
Message ID:
01632293
Views:
51
Hi Tariq

Looks fine; 1 observation though: in case of !m.result, you should execute ROLLBACK

>Dear Expert
>
>I am trying to convert my single user system to multiuser system.
>
>I wrote follwing codes behind SAVE button.
>
>Do not know that are reliable or not.
>
>Please review and help me
>
>
>sno1=thisform.text1.value
>	date1=thisform.text2.value
>	code1=thisform.text4.value
>	partyname=thisform.text5.value
>
>*--- delete current invoice if found
>	select sales
>	delete all for sno=thisform.text1.value in sales
>	tableupdate(.t.,.t.,'sales')
>
>*--- get NEW sno (refresh sno if some one has saved invoices greater than text1.value)
>	maxsno=0
>	calculate max(sno) for !deleted() to maxsno
>	thisform.text1.value=maxsno+1
>
>	Begin transaction
>
>		*---prepare credit entry
>			select  temp
>			repl all credit with round(credit,0),type with [P],detail with thisform.text3.value,;
>				sno with thisform.text1.value,dates with date1,	code2 with code1,;
>				credit with round(credit,0),edmode with .t. for !empty(codes)
>
>			update temp set names =products.names from products where temp.codes=products.codes
>
>			select sales
>			append from dbf("temp")  for !empty(codes) and !deleted()
>
>			result=tableupdate(.t.,.t.,'sales')
>			
>			*---error trapping routine
>			if !result
>				= aerror(laerror)
>				tablerevert( .t., "sales" )
>				= messagebox('Error #' + ltrim(str(laerror[1])) + ': ' + laerror[2] + ;
>					' occurred while saving.')
>			endif result
>
>		*---prepare debit entry
>			select temp
>			repl all code2 with codes, codes with code1,names with partyname,detail with thisform.text3.value,;
>				sno with thisform.text1.value,debit with round(credit,0),;
>				credit with 0 type with "" ,edmode with .t. for !empty(codes)
>
>			select sales
>			append from dbf("temp")  for !empty(codes) and !deleted()
>
>			result=tableupdate(.t.,.t.,'sales')
>
>			*---error trapping routine
>			if !result
>				= aerror(laerror)
>				tablerevert( .t., "sales" )
>				= messagebox('Error #' + ltrim(str(laerror[1])) + ': ' + laerror[2] + ;
>					' occurred while saving.')
>			endif result
>
>	end transaction
>
>	flush in sales force
>
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Previous
Reply
Map
View

Click here to load this message in the networking platform