Click here to Skip to main content
15,921,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

i have two table
1. inventory with item_id,Item Name,Rate,Quantity,Total Amount
2. Order with order id,item_name,quantity

now i am making order for 2 item how we calculate with these two table like deduct total amount and quantity from inventory table.

suppose 2 item rate is 10rs per item then 20rs is amount so deduct from inventory table is minus 2 item and minus 20rs from total amount.

how can i make it is possible.

thanks
Posted

1 solution

I am not too clear about your question.
As far as i understood, you need to use SqlTransactions.
After making orders for items, just update the inventory table for that particular item_id.
Put all Commands under a SqlTransaction.
 
Share this answer
 
Comments
call to .net 16-Sep-10 2:16am    
Inventory table
item id Name quantity Rate Amt total
1 pepsi 5 10 50
2 coke 6 2 12
3 soda 2 100 200

Order Table
order id Name quantity
1 coke 1
2 soda 2
3 soda 2

now calculate how many items order that will be deduct from inventory table and calculate rate for this order and deduct from total amount from inventory table
nagendrathecoder 16-Sep-10 2:21am    
Ok, refer my solution, it'll exectly do your need.
Basically, your tables are not normalised, instead of item_name, use item_id in your Order table.
Then after every entry in Order table, update subsequent entry in Inventory table for that item_id.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900