Hi all,
Check this code and please tell me a solution.I have 2 buttons (Pizza & pepsi),the price should display in textbox8 when i click on button, here the price had shown in Textbox8,but it is not getting added with next price when i click second button.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        con.ConnectionString = str
        TextBox8.Text = 0.0
        adp = New SqlDataAdapter("select Item,Price from Bill where Id = '1'", con)
        adp.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        TextBox8.Text = ds.Tables(0).Rows(0)("Price") + TextBox8.Text 
    End Sub

Show the price for item in textbox and ask the user to enter the Quanity he wants then
TextBox8.Text =Quantity*Actualprice..

thanks Pgmer.
actually what i need is the price of the current item(Pizza) which i've just clicked should get added to the price of next item(Pepsi)when i click pepsi, and the result should be displayed in same textbox.

That can be done.. But how ur calculating the how much quantity of Pizza has been taken or pepsi has been taken? Can you share ur code?

con.ConnectionString = str
        TextBox8.Text = 0.0
        adp = New SqlDataAdapter("select Count,Item,Price from Bill where Id = '1'", con)
        adp.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        TextBox8.Text = Convert.ToString(ds.Tables(0).Rows(0)("Price")) + Val(TextBox8.Text)

Once we click on menu button count,item and price will be displayed in datagridview
eg:
Count Item Price
1 Pizza 90.00

the count should increment by 1 when i click again the same menu.

just check out this code it may give you small idea how to do it.

private void button1_Click(object sender, EventArgs e)
        {

            int i = 0;
            if (textBox2.Text.ToString()!= "")
            {
                i = Convert.ToInt32(textBox2.Text);
            }
            int j = Convert.ToInt32(textBox1.Text);
            textBox2.Text = Convert.ToString(i + j);
        }

thanks pritesh
i dont know how to do it in datagridview.Please help

con.ConnectionString = str
TextBox8.Text = 0.0
adp = New SqlDataAdapter("select Count,Item,Price from Bill where Id = '1'", con)
adp.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
TextBox8.Text = Convert.ToString(ds.Tables(0).Rows(0)("Price")) + Val(TextBox8.Text)

On line 2 you set the textbox value to "0.0" and at the end you add this value to your database output. So what you are doing is "result + 0.0".

1. Remove line 2
2. Change last line to: TextBox8.Text += Convert.ToDouble(ds.Tables(0).Rows(0)("Price"))

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.