SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 18th, 2004, 03:08 PM
mateoc15's Avatar
mateoc15 mateoc15 is offline
C A R D S
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 773 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 10 m 50 sec
Reputation Power: 13
CFGRIDUPDATE error checking

I have a single page that, if CGI.REQUEST_METHOD IS "post" runs a CFGRIDUPDATE on a grid that is located in the same page. One of the columns in the page, PONumber, is a foreign key from another parent table.

I have to allow that column to be edited so that the other columns can be edited, but how can I check to see if the PONumber entered into this form for OrderItem acutally exists in MerchandiseOrder (I.E. - an order item cannont be entered with PONumber 1 if the MerchandiseOrder table does not have a record with PONumber 1).

Here's the code: http://cislab2.cbpa.louisville.edu/...7/orderItem.cfm
Code:
<CFIF CGI.REQUEST_METHOD IS "post">
	<CFGRIDUPDATE datasource="#DataSource#" tablename="OrderItem" grid="orderItemGrid" keyonly="no">
</CFIF>

<CFQUERY datasource="#DataSource#" name="orderItemQuery">
	SELECT	PONumber, ItemID, Quantity, Cost
	FROM	OrderItem
	ORDER BY PONumber
</CFQUERY>

<HTML>
<BODY>
<CFFORM action="orderItem.cfm">
<CFGRID	name="orderItemGrid" query="orderItemQuery" insert="yes" delete="yes" griddataalign="left" gridlines="yes" rowheaders="no" colheaders="yes" colheaderalign="center" colheaderbold="yes" selectmode="edit" insertbutton="Insert Record" deletebutton="Delete Record"	width="400"height="250">
	<CFGRIDCOLUMN name="PONumber" header="P.O. Number">
	<CFGRIDCOLUMN name="ItemID" header="Item I.D.">
	<CFGRIDCOLUMN name="Quantity" header="Quantity Ordered">
	<CFGRIDCOLUMN name="Cost" header="Purchase Cost" numberformat="$999.99">
</CFGRID>
<BR>
<INPUT type="submit" value="Save Changes">
</CFFORM>
</BODY>
</HTML>


ERD for the database is available here:
http://cislab1.cbpa.louisville.edu/...t5/petstore.jpg

I just need to print a message saying something like "PO Number does not exist" if that is true, or process the insert if the PO Number entered IS valid. Thanks in advance!
__________________
Reinventing the wheel again

Reply With Quote
  #2  
Old April 18th, 2004, 09:31 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Based on your ERD, the database should already be throwing an error when you try to insert a PONumber for an OrderItem that does not have a matching PONumber in the MerchandiseOrder table. Just catch the error with CFCATCH and display whatever message you want to.

Reply With Quote
  #3  
Old April 18th, 2004, 11:22 PM
mateoc15's Avatar
mateoc15 mateoc15 is offline
C A R D S
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 773 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 10 m 50 sec
Reputation Power: 13
AAAH! see, being a CF newbie i was unaware of the CFCATCH clause... thanks a bunch!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CFGRIDUPDATE error checking


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway