public string Add(Product aProduct) { foreach (Product newProduct in Products) { if (newProduct.ID == aProduct.ID) { newProduct.Quantity += aProduct.Quantity; return "Successfully Added."; } } Products.Add(aProduct); return "New Iteam Added."; }
private void addIteamButton_Click(object sender, EventArgs e) { Product aProduct = new Product(productTextBox.Text, Convert.ToInt16(quantityTextBox.Text)); string msg = aShop.Add(aProduct); MessageBox.Show(msg); }