/// <summary> /// Handles the Click event of the btn_ProdDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void btn_ProdDelete_Click(object sender, EventArgs e) { try { int selectedIndex = comboBox_ProdChoose.SelectedIndex; Product selectedItem = (Product)comboBox_ProdChoose.SelectedItem; using (ProductController prodDelete = new ProductController()) { System.Windows.Forms.DialogResult result; if (prodDelete.CheckIfProductIsAllocatedToAnyProject(selectedItem.Product_Id)) { result = MessageBox.Show("Das Produkt ist einem oder mehreren Projekten zugeordnet.\n" + "Wollen Sie das ausgeählte Produkt wirklich löschen?", "Löschbestätigung", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { result = MessageBox.Show("Wollen Sie das ausgeählte Produkt wirklich löschen?", "Löschbestätigung", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (result == DialogResult.Yes) { prodDelete.DeleteProductFromDb(selectedItem.Product_Id); RefreshDropdown(); } } } catch (Exception x) { MessageBox.Show(x.Message); } }
/// <summary> /// Handles the Click event of the btn_ProdDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void btn_ProdDelete_Click(object sender, EventArgs e) { try { int selectedIndex = comboBox_ProdChoose.SelectedIndex; Product selectedItem = (Product)comboBox_ProdChoose.SelectedItem; using (ProductController prodDelete = new ProductController()) { System.Windows.Forms.DialogResult result; if (prodDelete.CheckIfProductIsAllocatedToAnyProject(selectedItem.Product_Id)) { result = MessageBox.Show("Das Produkt ist einem oder mehreren Projekten zugeordnet.\n" + "Wollen Sie das ausgeählte Produkt wirklich löschen?", "Löschbestätigung", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { result = MessageBox.Show("Wollen Sie das ausgeählte Produkt wirklich löschen?", "Löschbestätigung", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (result == DialogResult.Yes) { prodDelete.DeleteProductFromDb(selectedItem.Product_Id); RefreshDropdown(); } } } catch (Exception x) { MessageBox.Show(x.Message); } }