Click here to Skip to main content
16,014,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//every time i execute the NewBind() it subtract all of the same product name in the inventory out and update the inventory.
C#
private void NewBind()
{
    try
    {
        MySqlConnection con = new MySqlConnection("Server=localhost;UID=root;Database=db_cignal");
        con.Open();
        MySqlCommand cmd = con.CreateCommand();
        cmd.CommandText = "update inventoryOut.TotalPrice = (inventory.TotalPrice - inventoryout.TotalPrice) where inventory.Product = @Products";
        cmd.Parameters.AddWithValue("@Products", cbProductOut.SelectedItem.ToString());
        cmd.Prepare();
        cmd.ExecuteNonQuery();
        BindGridInventory();
        con.Close();
    }
    catch(Exception t)
    {
        MessageBox.Show(t.Message);
    }
}

//sample
inventory DB(lets assume that this is already deducted product 1 10 stocks)
Product 1   100 stocks   1000 Total Price
Product 2   50  stocks   500  Total Price

inventoryOUT BD(let assume the last value is the updated)
Product 1   10  stocks   100  Total Price
Product 1   50  stocks   500  Total Price

..not desired output
newBind():
inventory DB
Product 1   40  stocks    400 Total Price
Product 2   50  stocks    500 total Price

..desired output
newBind():
inventory DB
Product 1   50  stocks    500 Total Price
Product 2   50  stocks    500 total Price
Posted
Updated 11-Mar-15 5:26am
v3
Comments
ZurdoDev 11-Mar-15 11:39am    
What exactly is your question?
_bluRe_ 11-Mar-15 11:43am    
i want to produce the desired output.. subtracting the same product with the latest inputed values in inventoryout.

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