private void addtocartbtn_Click_1(object sender, RoutedEventArgs e) { try { Cart cartAdded = CheckNulls(); string username = ""; AddToCartBL cartBL = new AddToCartBL(); //Check for null values if (!string.IsNullOrEmpty(txtusername1.Text)) { username = txtusername1.Text;//username textbox } bool result = cartBL.AddCartBL(cartAdded, username); if (result == true) { MessageBox.Show("Ingredient Added to Cart!"); this.Close(); OrderIngredient orderpage = new OrderIngredient(txtusername1.Text); //Redirect to order page orderpage.Show(); } else { MessageBox.Show("Ingredient Not Added to Cart!"); } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } }
//view ingredients of selected recipe private void viewbtn_Click(object sender, RoutedEventArgs e) { try { if (txtid.Text != null) { int recipeid = Convert.ToInt32(txtid.Text); AddToCartBL addtocartBL = new AddToCartBL(); //get list of recipe ingredients listofingredients.ItemsSource = addtocartBL.GetIngredientBL(recipeid); } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } //listofingredients.ItemsSource = dt.DefaultView; }