Пример #1
0
        // Deletes the currently selected package
        private void btnPkgDelete_Click(object sender, EventArgs e)
        {
            //Delete Package
            DialogResult confirmation = DialogResult.No;

            confirmation = MessageBox.Show("Are you sure you want to delete the package '" +
                                           selectedPackage.Name + "'?", "Confirm Delete", MessageBoxButtons.YesNo,
                                           MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            if (confirmation != DialogResult.Yes)
            {
                return;
            }

            int rowsDeleted = 0;

            try
            {
                rowsDeleted = PackageDB.Delete(selectedPackage);
                if (rowsDeleted > 0)
                {
                    //package deleted. Refill combo box and display result
                    FillPackageComboBox(btnPkgDelete, EventArgs.Empty);
                    lblPkgStatus.Text = "Package deleted";
                    MessageBox.Show("Package deleted");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Deleting Package");
            }
        }