private void btnUpdateRecipe_Click(object sender, RoutedEventArgs e) { WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter rta = new FoodProjectDataSetTableAdapters.RecipeTableAdapter(); int rid = (int)App.Current.Properties["rid"]; string image_url = (string)App.Current.Properties["image_url"]; int rating = int.Parse(lblRating.Content.ToString()); rta.UpdateRecipe(txtName.Text, descriptionTextBox.Text, image_url, rating, rid); unsavedChanges = false; this.Close(); }
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (unsavedChanges) { MessageBoxResult res = MessageBox.Show("Uppskrift hefur verið breytt. Viltu vista breytingar?", "Vista breytingar", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Yes); if (res == MessageBoxResult.Yes) { WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter rta = new FoodProjectDataSetTableAdapters.RecipeTableAdapter(); int rid = (int)App.Current.Properties["rid"]; string image_url = (string)App.Current.Properties["image_url"]; int rating = int.Parse(lblRating.Content.ToString()); rta.UpdateRecipe(txtName.Text, descriptionTextBox.Text, image_url, rating, rid); } if (res == MessageBoxResult.Cancel) { e.Cancel = true; } } }