private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex > (articles.Count - 1) || e.RowIndex < 0) { return; } var senderGrid = (DataGridView)sender; var column = senderGrid.Columns[e.ColumnIndex]; if (column.Tag == null) { return; } if (column.Tag.ToString() != ADD_QUANT_COLUMN_NAME && column.Tag.ToString() != SUB_QUANT_COLUMN_NAME && column.Tag.ToString() != UPDATE_PRICE_NAME && column.Tag.ToString() != DELETE_NAME ) { return; } if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { String input = ""; int quant = 0; try { var article = articles[e.RowIndex]; if (column.Tag.ToString() == ADD_QUANT_COLUMN_NAME) { input = ChangeQuantPrompt.ShowDialog("Menge: ", "Menge hinzufügen fur " + article.GetArtNo()); if (String.IsNullOrEmpty(input)) { return; } quant = Int32.Parse(input); ArticleService.AddQuant(article, quant); } else if (column.Tag.ToString() == SUB_QUANT_COLUMN_NAME) { input = ChangeQuantPrompt.ShowDialog("Menge: ", "Menge subtrahieren fur " + article.GetArtNo()); if (String.IsNullOrEmpty(input)) { return; } quant = Int32.Parse(input); ArticleService.SubQuant(article, quant); } else if (column.Tag.ToString() == UPDATE_PRICE_NAME) { input = ChangePricePrompt.ShowDialog("Preis :", "Preis ändern fur " + article.GetArtNo()); if (String.IsNullOrEmpty(input)) { return; } var price = Decimal.Parse(input, Thread.CurrentThread.CurrentCulture.NumberFormat); ArticleService.UpdatePrice(article, price); } else if (column.Tag.ToString() == DELETE_NAME) { var result = ConfirmationPrompt.ShowDialog("Möchten Sie es wirklich löschen?", "Löschen", "Ja", "Nein"); if (result) { ArticleService.Delete(article); } } LoadArticles(); } catch (ArgumentException ex) { MessageBox.Show("Ungültige Eingabe"); } catch (FormatException ex) { MessageBox.Show("Ungültige Eingabe"); } catch (Exception ex1) { MessageBox.Show(ex1.Message); } } }