private void DeleteGadget_Click(object sender, RoutedEventArgs e) { if (gadgetGrid.SelectedItem == null) { MessageBox.Show("No Item selected!"); } else { Gadget selectedGadget = (Gadget)gadgetGrid.SelectedItem; deleteGadget deleteWindow = new deleteGadget(selectedGadget); deleteWindow.Show(); deleteWindow.Yes_Button.Click += delegate { if (service.DeleteGadget(selectedGadget)) { //MessageBox.Show("Gadget successfully deleted!"); deleteWindow.Close(); } else { MessageBox.Show("Operation failed!"); } }; deleteWindow.Closed += delegate(object s, EventArgs a) { RefreshGadgets(); }; } }
public void RemoveGadget() { try { if (SelectedGadget != null) { MessageBoxResult dialogResult = MessageBox.Show($"Sind Sie sicher, dass Sie{Environment.NewLine}{Environment.NewLine}{SelectedGadget.FullDescription()}{Environment.NewLine}{Environment.NewLine}löschen möchten?", "Löschen bestätigen", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { if (libraryAdminService.DeleteGadget(SelectedGadget)) { Gadgets.Remove(SelectedGadget); } else { MessageBox.Show("Fehler beim Löschen des Gadgets. Bitte versuchen Sie es nochmals.", "Löschen fehlgeschlagen", MessageBoxButton.OK); } } } } catch (InvalidCastException exception) { MessageBox.Show("Fehler beim Löschen des Gadgets. Bitte versuchen Sie es nochmals.", "Löschen fehlgeschlagen", MessageBoxButton.OK); Debug.Print(exception.ToString()); } }
private void Delete() { if (MessageBox.Show(Properties.Resources.DELETE_CONFIRMATION_TEXT, Properties.Resources.DELETE_CONFIRMATION_TITLE, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { libraryAdminService.DeleteGadget(SelectedGadget); Gadgets.Remove(SelectedGadget); SelectedGadget = Gadgets.ElementAt(0); } }
private void btnDeleteGadget_Click(object sender, RoutedEventArgs e) { Gadget gadget = (Gadget)dataGridView.SelectedItem; service.DeleteGadget(gadget); MainWindow main = (MainWindow)Window.GetWindow(this); // Update DataGrid main.RefreshDataGrid(); }
private void funcsureGadget(Window window) { if (service.DeleteGadget(delGadget)) { //Close the window, if the operation was succesfull window.Close(); } else { // Print an error message if the operation failed. MessageBox.Show("It didn't work. Check your connection to the server and try it again."); } }
private void ButtonDelete_OnClick(object sender, RoutedEventArgs e) { if (SelectedGadget != null) { string message = $"Are you sure that you want to delete the {Environment.NewLine}{SelectedGadget.Name} with ID {SelectedGadget.InventoryNumber}"; string title = "Are you sure?"; if (MessageBox.Show(message, title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _service.DeleteGadget(SelectedGadget); LoadData(); } } }
public static void Delete(Gadget gadget) { MessageBoxResult messageBoxResult = MessageBox.Show(String.Format("Are you sure you want delete this gadget:\n{0} ({1})", gadget.Name, gadget.Manufacturer), "Delete Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { if (Service.DeleteGadget(gadget)) { Gadgets.Remove(gadget); } else { messageBoxResult = MessageBox.Show("Could not delete selected gadget.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public void DeleteGadget(Gadget gadget) { DialogResult messageBoxResult = MessageBox.Show($"Are you sure to delete {gadget.Name} (InvNr:{gadget.InventoryNumber}) ?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (messageBoxResult == DialogResult.Yes) { if (_service.DeleteGadget(gadget)) { LoadServerData(); } else { throw new Exception("Delete Gadget Failed!"); } } }
/// <summary> /// demonstrates the use of the admin functions to add/remove /// new objects to/from the gadgeothek /// </summary> public void ShowAdminInteraction() { var service = new LibraryAdminService(ServerUrl); var gadget = new Gadget("XBOX360") { Manufacturer = "Microsoft" }; if (!service.AddGadget(gadget)) { Console.WriteLine($"{gadget} konnte nicht hinzugefügt werden..."); return; } var gadgets = service.GetAllGadgets(); PrintAll(gadgets, "Gadgets (NEW)"); gadget.Condition = Condition.Damaged; if (!service.UpdateGadget(gadget)) { Console.WriteLine($"{gadget} konnte nicht aktualisiert werden..."); return; } gadgets = service.GetAllGadgets(); PrintAll(gadgets, "Gadgets (NEW 2)"); if (!service.DeleteGadget(gadget)) { Console.WriteLine($"{gadget} konnte nicht gelöscht werden..."); return; } gadgets = service.GetAllGadgets(); PrintAll(gadgets, "Gadgets (NEW 3)"); }
private void Button_Delete_Event(object sender, RoutedEventArgs e) { if (GadgetListBox.SelectedIndex < 0) { return; } Gadget selectedGadget = (Gadget)GadgetListBox.SelectedValue; string messageBoxText = "Do you want to delete " + selectedGadget.ToString() + " ?"; if (MessageBox.Show(messageBoxText, "Security", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { var url = ConfigurationManager.AppSettings["server"]; var service = new LibraryAdminService(url); if (!service.DeleteGadget(selectedGadget)) { System.Console.WriteLine("Could not delete Gadget " + GadgetListBox.SelectedValue.ToString()); } else { bool ret = GadgetItems.Remove(selectedGadget); } } }
public bool DeleteGadget(Gadget gadget) { return(Service.DeleteGadget(gadget)); }
public void toDeleteGadget(Gadget gadget) { allGadgets.Remove(gadget); service.DeleteGadget(gadget); }