예제 #1
0
        private void btnDelVenue_Click(object sender, EventArgs e)
        {
            //Validation
            string selected = cboVenueNames.Text;

            Venue selectedVenue = new Venue();

            selectedVenue.setName(selected);

            selectedVenue.setVenueDetails();


            //Check that Venue has no events beyond todays date
            if (!selectedVenue.checkIfUpcomingEvents())
            {
                //if no upcoming events

                //Ask user to confirm
                DialogResult confirmation = MessageBox.Show("Are you sure you want to delete Venue?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (confirmation == DialogResult.Yes)
                {
                    selectedVenue.deleteVenue();
                    //if yes set status of venue to "Unavailable" in the Venues File
                    MessageBox.Show("Venue has been removed from the system", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                //Display error message
                MessageBox.Show("Please cancel upcoming events before deregistering from the system.", "Cancel Events", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txtVenueName.Clear();
            txtStreet.Clear();
            txtTown.Clear();
            txtCapacity.Clear();
            txtContactNo.Clear();
            txtEmail.Clear();
            pnlDeleteVenue.Visible      = false;
            cboVenueNames.SelectedIndex = -1;
            cboVenueNames.Focus();
        }