private void deleteProduct_Button_Click(object sender, EventArgs e) { string vendor = vendor_TextBox.Text; string name = name_TextBox.Text; using (EnterpriseTestContext context = new EnterpriseTestContext()) { var temp = context.AssociatedProducts.Where(y => y.AssociatedProductId == _selectedProductId); if (temp.Count() == 0) { MessageBox.Show("Name and Vendor don't exist in the database to delete", "Product Delete Error", MessageBoxButtons.OK); return; } else { AssociatedProduct del = temp.First(); context.DeleteObject(del); context.SaveChanges(); LoadPage(); } if (context.AssociatedProducts.Count() == 0) { editProduct_Button.Enabled = false; } } deleteProduct_Button.Enabled = false; }
private void delete_ToolStripButton_Click(object sender, EventArgs e) { SoftwareInstaller selected = Selected; if (selected != null && MessageBox.Show("Delete {0}?".FormatWith(selected.Description), "Delete Software Installer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _installers.Remove(selected); _dataContext.DeleteObject(selected); RefreshInstallerGrid(); } }
private void remove_ToolStripButton_Click(object sender, EventArgs e) { InstallerSettingRow selected = SelectedSetting; if (selected != null && MessageBox.Show("Remove {0} from this package?".FormatWith(selected.InstallerSetting.SoftwareInstaller.Description), "Remove Software Installer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _settings.Remove(selected); _dataContext.DeleteObject(selected.InstallerSetting); RebuildInstallOrder(); } }