Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2007, 05:11 PM
Authorized User
 
Join Date: Sep 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating products quantity when order item insert

Hie

I am modifying the Webshop and have come to the stage of handling orders and products.I added a quantity column to the product table which stores the quantity for each product and want the value to be updated each time items are inserted into the OrderDetail table.

Can someone advice me on how to come up with the stored procedure to do that and were exacly to call it in code.I am kind of blank on where to start.

Thanks in advance.

 
Old June 7th, 2007, 02:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Tawanda,

I think the first advice is: step back from your computer, take a piece of paper and a pen (or, if you're attached to your computer use something like Visio) and draw the process.

Once you do that, things will clear up. You'll see how and where people put stuff in their cart, when they are about to finalize their order and when they actually do finalize their order.

That's the point where you need to hook into your supply system. Basically, whenever someone confirms the order, that's where you need subtract the ordered quantity from the stock.

So, in the stored procedure that finalizes the order, you can add additional code to decrease the stock. Something like:

UPDATE Product SET Stock = Stock = @quantity WHERE Id = @productId

Just an example, but hopefully you get the idea.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating Products in the WebShop ASPLee BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 March 10th, 2007 11:24 PM
Insert into & order by... kiwikencox SQL Server 2000 5 October 13th, 2005 05:06 AM
SELECT/ORDER/INSERT Stuart Stalker SQL Server DTS 1 July 24th, 2005 01:00 AM
updating unit_in_stock column after order olambe SQL Server 2000 7 June 7th, 2004 04:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.