Restaurant Automation Question with Listbox?

17.05.2012 18:08, Yigit Yilmaz wrote:
good day I would like to ask you for help on a subject.
I am preparing restaurant automation for project homework, I created the database
I added the products and prices into it
I created a restaurant menu in form1e, I created a restaurant menu on the buttons in the database
exactly as it is registered, the names of the products are written
when I click this button, how can I pull the price of the product from the database and print it to
listbox.
Of course we can help.
First of all DB:
In the
urunler table: urun_kodu | urun_adi | urun price in the form of 3 fields in our table. You have already pulled the button name from the urun_adi field. The rest is to write code to the click event of the button.
private void HESAPLA(string gelen_urun)
{
SqlConnection con = new SqlConnection("server=localhost;database=lokanta;user id=admin;password=1234");
SqlCommand com = new SqlCommand("Select * from urunler where urun_adi='" + gelen_urun + "'",con);
con.Open();
SqlDataReader rdr = com.ExecuteReader();
if(rdr.HasRows)
{
Double fiyat = Convert.ToDouble(rdr["urun_fiyati"].ToString());
}
rdr.Close();
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string buton_adi = button1.Text;
HESAPLA(buton_adi);
Listbox1.Items.Add(fiyat);
}C#MAKE A COMMENT
COMMENTS - 0 COMMENTS




