コード例 #1
0
 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.";
 }
コード例 #2
0
 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);
 }