CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.commerce_starter_kit Tags:
Item Type: NewsGroup Date Entered: 10/25/2005 5:19:43 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 22 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
siva123
Asp.Net User
Update Stock in Products Table10/25/2005 5:19:43 PM

0/0

Hi ,
I have Customised the Products table.
Added new field stock. When Customer Finish ordering product its executes "OrdersAdd" StoreProcedure.
Is that any way we can run Updating Product table stock filed from the Shopping Cart table

Thanks
Siva
Sivakumar.A

Senior Developer
Spire128
Asp.Net User
Re: Update Stock in Products Table10/25/2005 10:17:54 PM

0/0

Hi

Try these ammended SP's


ALTER Procedure CMRC_ShoppingCartAddItem

(

@CartID nvarchar(50),
@ProductID
int,
@Quantity
int

)

As

DECLARE @CountItems int
DECLARE @StockCount int


SELECT
@StockCount = Stock
FROM
CMRC_Products
WHERE
ProductID = @ProductID

IF @StockCount > 0

UPDATE CMRC_Products
SET
Stock = (Stock - @Quantity)
WHERE
ProductID = @ProductID


SELECT
@CountItems = Count(ProductID)
FROM
CMRC_ShoppingCart
WHERE
ProductID = @ProductID
AND
CartID = @CartID

IF @CountItems > 0 /* There are items - update the current quantity */

UPDATE
CMRC_ShoppingCart
SET
Quantity = (@Quantity + CMRC_ShoppingCart.Quantity)
WHERE
ProductID = @ProductID
AND
CartID = @CartID

ELSE /* New entry for this Cart. Add a new record */

INSERT INTO CMRC_ShoppingCart

(

CartID,
Quantity,
ProductID

)

VALUES

(

@CartID,
@Quantity,
@ProductID

)

and to replace the stock if shopping cart updated

ALTER Procedure CMRC_ShoppingCartUpdate(

@CartID nvarchar(50),
@ProductID
int,
@Quantity
int

)

AS

UPDATE CMRC_Products

SET
Stock = (Stock + @Quantity)
FROM
CMRC_Products
WHERE
ProductID = @ProductID

UPDATE CMRC_ShoppingCart

SET

Quantity = @Quantity
WHERE
CartID = @CartID
AND
ProductID = @ProductID

and remove item

ALTER Procedure CMRC_ShoppingCartRemoveItem

(

@CartID nvarchar(50),
@ProductID
int

)

AS

DECLARE @Quantity int

SELECT

@Quantity= Quantity
FROM
CMRC_ShoppingCart
WHERE
CartID = @CartID
AND
ProductID = @ProductID

UPDATE CMRC_Products

SET
Stock = (Stock + @Quantity)
FROM
CMRC_Products
WHERE
ProductID = @ProductID

DELETE FROM CMRC_ShoppingCart

WHERE
CartID = @CartID
AND
ProductID = @ProductID

I have not tested the above sp's but I think u should be okay, and there may be a better way of writing the Sp's as I am not a Sql wizz I know about enough to get by so hope that helps a litte.
You woud also need to look at the CMRC_ShoppingCartRemoveAbandoned Sp and perhaps do something with that but it's to late here for that at the moment.





 

siva123
Asp.Net User
Re: Update Stock in Products Table10/25/2005 10:26:58 PM

0/0

Hi

Thank you for your SP.

Actually I want to deduct the stock when we get order confirmation (When we insert order details from shopping cart table)

Anyway thanks for your reply.

 

Regards

Siva


Sivakumar.A

Senior Developer
Spire128
Asp.Net User
Re: Update Stock in Products Table10/25/2005 11:29:56 PM

0/0

Hi

Sorry I misunderstood try this

ALTER Procedure CMRC_OrdersAdd

(

@CustomerID int,
@CartID
nvarchar(50),
@OrderDate
datetime,
@ShipDate
datetime,
@OrderID
int OUTPUT

)

AS

BEGIN TRAN AddOrder

/* Create the Order header */

INSERT INTO CMRC_Orders

(

CustomerID,
OrderDate,
ShipDate

)

VALUES

(

@CustomerID,
@OrderDate,
@ShipDate

)

SELECT

@OrderID = @@Identity

/* Copy items from given shopping cart to OrdersDetail table for given OrderID*/

INSERT INTO CMRC_OrderDetails

(

OrderID,
ProductID,
Quantity,
UnitCost

)

SELECT

@OrderID,
CMRC_ShoppingCart.ProductID,
Quantity,
CMRC_Products.UnitCost

FROM

CMRC_ShoppingCart

INNER JOIN CMRC_Products ON CMRC_ShoppingCart.ProductID = CMRC_Products.ProductID

WHERE
CartID = @CartID

/* Removal of items from user's shopping cart will happen on the business layer*/

EXEC CMRC_ShoppingCartEmpty @CartID

/* Update the Stock in The Products Table*/

UPDATE CMRC_Products
SET CMRC_Products.Stock = CMRC_Products.Stock - CMRC_OrderDetails.Quantity

FROM
CMRC_Products, CMRC_OrderDetails
WHERE
CMRC_OrderDetails.OrderID = @OrderID
AND
CMRC_Products.ProductID = CMRC_OrderDetails.ProductID
AND
CMRC_Products.Stock > 0

COMMIT TRAN AddOrder

 See if this works it's what I currently use

siva123
Asp.Net User
Re: Update Stock in Products Table10/26/2005 7:59:59 AM

0/0

Hi

Thank You Very Much.

It's works nicely.

Regards

Siva


Sivakumar.A

Senior Developer
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Software Process Improvement: 12th European Conference, EuroSPI 2005, Budapest, Hungary, November 9-11, 2005 : Proceedings Authors: Ita Richardson, Pekka Abrahamsson, Richard Messnarz, Pages: 213, Published: 2005
SQL: The Complete Reference Authors: James R. Groff, Paul N. Weinberg, Pages: 1050, Published: 2002
BTEC National IT Practitioners Authors: J. Lawson, J. Lawson, B Wasyliw, Alan Jarvis, J. Philips, K. Anderson, A Smith, Allen Kaye, Peter Blundell, K. Anderson, Peter Blundell, A Smith, J. Philips, Allen Kaye, Alan Jarvis, B Wasyliw, Pages: 360, Published: 2007
Beginning SQL Server 2005 Programming Authors: Robert Vieira, Pages: 688, Published: 2006
Oracle Database 10g SQL: Master SQL and PL/SQL Authors: Jason Price, Pages: 608, Published: 2004
Mastering SQL Server 2000 Authors: Mike Gunderloy, Joseph L. Jorden, Joe Jorden, Pages: 1201, Published: 2000
Cooperative Databases and Applications '99: The Proceedings of the Second International Symposium on Cooperative Database Systems for Advanced Applications (CODAS '99), Wollongong, Australia, March 27-28, 1999 Authors: Yanchun Zhang, Marek Rusinkiewicz, Yahiko Kambayashi, Pages: 377, Published: 1999
Microsoft Access Version 2002 Inside Out Authors: Helen Feddema, Pages: 1105, Published: 2002
Universal Access in Human-computer Interaction: Ambient Interaction, 4th International Conference on Universal Access in Human-Computer Interaction, UAHCI 2007, Held as Part of HCI International 2007, Beijing,China, July 22-27, 2007, Proceedings, Part II Authors: Constantine Stephanidis, Pages: 1066, Published: 2007
Challenges of Information Technology Management in the 21st Century: 2000 Information Resources Management Association International Conference, Anchorage, Alaska, USA, May 21-24, 2000 Authors: Information Resources Management Association International Conference, Mehdi Khosrowpour, Pages: 1227, Published: 2000

Web:
Update Stock in Products Table - ASP.NET Forums Update Stock in Products Table. Last post 10-26-2005 3:59 AM by siva123. 4 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Using MS Access: MS ACESS update records in a table, quantity ... Subject: MS ACESS update records in a table Question ... And after each transaction entry, the stock level in product table will be automatically updated. ...
Updating stock levels from a CSV file or another table - MySQL In the CSV file there are products I do not list and in my table there ... UPDATE Product, Csv SET Product.stock = Csv.stock; WHERE Product. ...
Running a update stock control query from a button - Access World ... Running a update stock control query from a button Queries. ... like to deduct it from the quantityinstock field in the products table. ...
Updating Rowsets (OLE DB Templates) Update(); // Update row 100 now // Change the values of columns "Name" and " Units in Stock" in the 101st row of the Product table product. ...
osCommerce Community Add-Ons initial sort order is by product quantity. At the end you update stock because it's ... Since we're only updating the products table this is not necessary. ...
Automate Product Price and Stock Update - Zen Cart Support Automate Product Price and Stock Update First Steps & General ... update each one individually, I run a Query on my products database table. ...
UPDATE 1 - Macedonian Stock Indices Drop Sharply This Week ... (adds table) ... UPDATE 1 - Macedonian Stock Indices Drop Sharply This Week, .... The gross domestic product will slow its growth due to the lower level of ...
Update International UPDATE: Steam Table Pan, 1/3 Size, 4 in Deep ... Update International UPDATE: Steam Table Pan, 1/3 Size, 4 in Deep, Anti-Jam, ... 50000+ items in stock. Same day shipping on buffet products! ...
full size steam table pans - compare prices, research products ... Update International 1dz Full Size Steam Table Pans - 6 Deep NJP-1006 ... Full Size Disposable Steam Table Pan Read More. In Stock ...

Videos:
Andy Nyman's Killer Elite Pro by Alakazam Magic Andy Nyman's Killer Elite was not only one of the most successful tricks of its time. It was also voted "Trick of the Year" but unfortunately it ceas...
QualityStocks Daily Video 5/25/2007 Welcome to The Daily Stock Report...brought to you by QualityStocks.Net, performance tracked daily. I'm Cathy Rankin and for Friday May 25th we're ...
QualityStocks Daily Video 02/05/2007 Welcome to The Daily Stock Report...brought to you by QualityStocks.Net, performance tracked daily. I'm Cathy Rankin and for Monday, February 5th.....
Lec 25 | MIT 3.091 Introduction to Solid State Chemistry Solutions: Solute, Solvent, Solution, Solubility Rules, Solubility Product View the complete course at: http://ocw.mit.edu/3-091F04 License: Creati...
Charlie Rose - Fouad Ajami / Dov Charney Segment 1: Fouad Ajami discusses his book, "The Foreigner's Gift: The Americans, the Arabs, and the Iraqis in Iraq". Segment 2: Dov Charney, founder...
Lec 19 | MIT 3.091 Introduction to Solid State Chemistry Defects in Crystals: Point Defects, Line Defects, Interfacial Defects, Voids View the complete course at: http://ocw.mit.edu/3-091F04 License: Crea...
Long Beach City Council Meeting Long Beach City Council Meeting




Search This Site:










register a third party dll

regular expression problem

connection changes

hide forward and next button

retrive data from dll?

file upload - uploading files greater than 4 mb

designtimedragdrop attribute

sln file in .net

get one record from database

sql query from database assigned to dropdownlist

making submission form properly.

email

authed screen scrape

problem populating a datagrid field from a clob field held in a refcursor

prevent pages from being loaded when url is typed in

virtual studio - setting up

what is xml based resource file(.resx)?

can load index.htm remotely and locally, and default.aspx locally, but not remotely.

error trying to generate a random password

date que

request.params[] doesn't work with plus signs in the param?

check email

can i use httpwebrequest to keep my asp.net app alive?

if textbox1.text = "" then

placing the checkboxes inside the listbox

how can i validate to see if the same selected item is selected out of five drop down lists

using enter key as a button click

tabstrip

download file from a web page!

how to manage division by 0

  Privacy | Contact Us
All Times Are GMT