Hi,
Using ASP.NET 2.0 C# I am looking to get some idea how to reduce the quantity as the user buys a product. In my database i have a quantity column and when the user buys an amount of a certain product i would like it to deduct this from my quantity available. Does anyone have any hints where to start with this?
I am certain i am starting in the right place with:

    protected void btnBuyNow_Click(object sender, EventArgs e)
    {
        //I NEED CODE HERE TO DEDUCT VALUE??
        Response.Redirect("Order.aspx");
    }

Thanks

Recommended Answers

All 3 Replies

When user buy a product then deduct it with present quantity. Check must be applied for quantity value. And update the new reading in the database.

Assuming you understand the SQL UPDATE command, you simply execute a command on the database (command.executeNonquery in .Net)to set the quantity to the new quantity based on the product code.

UPDATE products_table SET quantity = quantity - 2 WHERE product_code = ?code;

Obviously the table name, column name and quantity to subtract will differ for you.

update your qty and minus your sold qty from main qty.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.