Exemple #1
0
        private void btnUpdateEvent_Click_1(object sender, EventArgs e)
        {
            //validate Data

            if (txtTitle.Text != "" && cboTypes.SelectedIndex != -1 && txtDate.Text != "" &&
                txtHour.Text != "" && txtMin.Text != "" && txtTickets.Text != "" && txtPrice.Text != "")
            {
                //if there are other events on same date with same venueID
                //Error- Clashing Events
                Event newEvent = new Event();
                newEvent.setTitle(cboEventTitles.Text);
                newEvent.setEventDetails();

                Venue eventVenue = new Venue();
                eventVenue.setID(newEvent.getVenueId());
                eventVenue.setVenueDetails();

                newEvent.setTickets(Convert.ToInt32(txtTickets.Text));

                //Tickets Available cannot be more than Capacity
                //Error - Capacity Exceeded
                if (newEvent.isVenueBigEnough())
                {
                    Type eventType = new Type();
                    eventType.setName(cboTypes.Text);
                    eventType.setTypeDetails();

                    newEvent.setType(eventType.getID());
                    newEvent.setDate(txtDate.Text);

                    string time;
                    int    hour = Convert.ToInt32(txtHour.Text);
                    int    mins = Convert.ToInt32(txtMin.Text);

                    if ((hour > 0 && hour < 13) && (mins >= 0 && mins < 60))
                    {
                        //If pm add 12 hours to make 24 hr format
                        if (cboAmPm.Text.Equals("pm") && hour < 12)
                        {
                            hour += 12;
                        }

                        time = hour + ":" + txtMin.Text;

                        newEvent.setTime(time);
                        newEvent.setPrice(Convert.ToDouble(txtPrice.Text));


                        //check if event is on the same date in the same venue
                        if (newEvent.isVenueFree())
                        {
                            newEvent.setTitle(txtTitle.Text);
                            newEvent.setDesc(txtDescription.Text);


                            //Ask user to confirm
                            DialogResult confirmation = MessageBox.Show("The new Event details you have entered are: \n" +
                                                                        newEvent.toString() + "\n\nWould you like to update the event?,",
                                                                        "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                            if (confirmation == DialogResult.Yes)
                            {
                                //if yes System save data to Events File
                                newEvent.updateEvent();

                                //Email Customers with Updates

                                MessageBox.Show("Event has been updated - Customers with existing tickets will be contacted and updated", "New Event!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                //Reset UI
                                cboEventTitles.SelectedIndex = -1;
                                pnlUpdateEvent.Visible       = false;
                                txtTitle.Clear();
                                txtDescription.Clear();
                                cboTypes.SelectedIndex = -1;
                                txtDate.Refresh();
                                txtHour.Clear();
                                txtMin.Clear();
                                txtTickets.Clear();
                                txtPrice.Clear();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Your Venue already has an event scheduled for " + newEvent.getDate(), "Existing Event!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtDate.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Enter a valid time", "Invalid Time!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtHour.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("For Health & Safety reasons you may NOT sell more tickets than the capacity of your Venue!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTickets.Clear();
                    txtTickets.Focus();
                }
            }
            else
            {
                MessageBox.Show("Information Missing", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private void frmAnalyseVenue_Load(object sender, EventArgs e)
        {
            List <String> venues = Venue.fillComboBox();

            cboVenueNames.Items.AddRange(venues.ToArray());
        }
        private void btnUpdateVenue_Click(object sender, EventArgs e)
        {
            //Validate data entered

            if (!txtVenueName.Text.Equals("") && !txtStreet.Text.Equals("") && !txtTown.Text.Equals("") && !txtEmail.Text.Equals("") &&
                !txtCapacity.Text.Equals("") && !txtContactNo.Text.Equals("") && !txtPassword.Text.Equals(""))
            {
                Venue myVenue = new Venue();


                myVenue.setName(txtVenueName.Text);
                myVenue.setVenueDetails();
                myVenue.setStreet(txtStreet.Text);
                myVenue.setTown(txtTown.Text);
                myVenue.setCapacity(Convert.ToInt32(txtCapacity.Text));
                myVenue.setContactNo(txtContactNo.Text);
                myVenue.setEmail(txtEmail.Text);
                myVenue.setPassword(txtPassword.Text);



                if (!myVenue.isRegisteredWithID())
                {
                    //Ask user to confirm
                    DialogResult confirmation = MessageBox.Show("The new Venue details you have entered are: \n" +
                                                                myVenue.toString() + "\n\nWould you like to update this venue?,",
                                                                "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (confirmation == DialogResult.Yes)
                    {
                        myVenue.updateVenue();

                        MessageBox.Show("Your venue details have been updated.", "Venue Updated!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //Reset UI
                        //Reset Combo Box

                        txtVenueName.Clear();
                        txtStreet.Clear();
                        txtTown.Clear();
                        txtCapacity.Clear();
                        txtContactNo.Clear();
                        txtEmail.Clear();
                        txtPassword.Clear();
                        cboVenueNames.SelectedIndex = -1;
                        cboVenueNames.Focus();
                        pnlUpdateVenue.Visible = false;
                    }
                }
                else
                {
                    MessageBox.Show("Venue Name already exists", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtVenueName.Clear();
                    txtVenueName.Focus();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Information Missing", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStreet.Focus();
                return;
            }
        }