private void AddToCart_Click(object sender, EventArgs e) { var ingredients = GetIngredients().ToList(); var row = FoodItemsGrid.CurrentRow; var item = new CartItem { Quantity = (int)ItemQuantity.Value, Ingredients = ingredients, FoodItemId = (int)row.Cells["ItemId"].Value, Name = row.Cells["ItemName"].Value.ToString(), ShopId = _id, Price = (double)row.Cells["Price"].Value }; _service.Cart.Add(item); ItemQuantity.Value = 1; AddToCart.Enabled = false; IngredientsGrid.DataSource = null; FoodItemsGrid.DataSource = null; CategoriesGrid.ClearSelection(); var currentPrice = double.Parse(Price.Text); var itemPrice = item.Quantity * (item.Price + item.Ingredients.Sum(y => y.Price)); var finalPrice = currentPrice + itemPrice; Price.Text = finalPrice.ToString(); }
private void FormShown(object sender, EventArgs e) { CategoriesGrid.ClearSelection(); }