Hello Guys! i am working on entity framework database in my c# application but some thing here is so difficult like i click on image then product name and product price add in listbox but when i again add same item so item will add no issue with it price is not update in same product name
Here is the code:
Button b = (Button)sender;
tblProduct tp = (tblProduct)b.Tag;
string product = tp.productName;
lbProductsToBuy.Text = tp.ToString();
if (lbProductsToBuy.Items.Contains(tp))
{
MessageBox.Show("Items is already in listbox", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
lbProductsToBuy.Items.Add(tp.productPrice);
}
else
{
}
{
products.Add(tp);
total += (decimal)tp.productPrice;
What I have tried:
Button b = (Button)sender;
tblProduct tp = (tblProduct)b.Tag;
string product = tp.productName;
lbProductsToBuy.Text = tp.ToString();
if (lbProductsToBuy.Items.Contains(tp))
{
MessageBox.Show("Items is already in listbox", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
lbProductsToBuy.Items.Add(tp.productPrice);
}
else
{
}
{
products.Add(tp);
total += (decimal)tp.productPrice;