TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
357
121.8k
Quantity minus UnitsInStock
May 5 2012 7:54 AM
Hi
I have a table in my DB called Products.
Products has various columns but in particular one named ProductId and one named UnitsInStock.
ProductId starts at 1 and increments by 1 and I have a total of 2000 products.
UnitInStock holds the amount of stock for each product ie 5000, 6000 and so on.
I have a SubmitOrder method which persists the data from the ShoppingCart back to the DB in particular the Quantity.
What I would like to do is implement a solution in order to minus the Quantity from the UnitsInStock to enable me to display this on each of the product details.
What I was thinking was to get the UnitsInStock for each ProductId from the Products table and then get the Quantity placed from the Order Details table then subtract one from the other to get a total.
My approach is to get the ProductId and Quanity from the SubmitOrder method ie
OrderDetail od = new OrderDetail();
var getProductId = od.ProductId;
var getQuantity = od.Quantity;
Then somehow call on the Products table getting the UnitsInStock for the particular ProductId passed in and then subtract the Quantity from the UnitsInStock.
Im guessing some sort of Query will be required but im stuck on how to write this.
Thanks
Steven
Reply
Answers (
11
)
2-tier architecture
.net 2008