0

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
4
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by GeekByChoiCe
0

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

0

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.

0

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?

0
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.

Edited by prathapsv3: n/a

0

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);
        }
0

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

1

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"))

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.