Exemple #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (cboVenue.SelectedItem == null || txtTitle.Text == "" ||
                txtTicketsAvailable.Text == "" || txtTime.Text == "" || txtPrice.Text == "")
            {
                MessageBox.Show("One or more fields have been left empty! Please enter all required details.", "Empty Field(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dialogResult = MessageBox.Show("Confirm this information?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                if (!Event.checkEventTitle(txtTitle.Text, Venue.getIDFromName(cboVenue.SelectedItem.ToString())))
                {
                    String name    = Convert.ToString(cboVenue.SelectedItem);
                    Event  myEvent = new Event();

                    DateTime dt1 = DateTime.Parse(dtpDate.Value.ToString("yyyy-MM-dd"));
                    DateTime dt2 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));

                    if (dt1.Date >= dt2.Date)
                    {
                        myEvent.setEventID(Convert.ToInt32(txtID.Text));
                        myEvent.setVenueID(Venue.getIDFromName(name));
                        myEvent.setVenueName(name);
                        myEvent.setTitle(Convert.ToString(txtTitle.Text));
                        myEvent.setDescription(Convert.ToString(txtDescription.Text));
                        myEvent.setEventDate(dtpDate.Value.ToString("yyyy-MM-dd"));
                        myEvent.setEventTime(txtTime.Text);
                        myEvent.setTicketsAvailable(Convert.ToInt32(txtTicketsAvailable.Text));
                        myEvent.setPrice(Convert.ToDouble(txtPrice.Text));

                        if (myEvent.isVenueFree(myEvent.getEventDate()))
                        {
                            int ticks = Venue.getMaxCapacity(cboVenue.Text);

                            if (Convert.ToInt32(txtTicketsAvailable.Text) <= ticks)
                            {
                                try
                                {
                                    myEvent.AddEvent();
                                    MessageBox.Show("All Done!");
                                    grdAddEvent.DataSource = Event.getActiveEventsMini().Tables["aem"];
                                    txtID.Text             = Convert.ToString(Event.getNextID());

                                    txtTitle.Text       = "";
                                    txtDescription.Text = "";
                                    dtpDate.Refresh();
                                    txtTime.Text             = "";
                                    txtPrice.Text            = "";
                                    txtTicketsAvailable.Text = "";
                                }
                                catch (Oracle.ManagedDataAccess.Client.OracleException)
                                {
                                    MessageBox.Show("The price or time format you have entered is incorrect! " +
                                                    "Try and put a decimal point in the price (eg. 120.00) or a colon (:) in the time box!");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Cannot have more than " + ticks + " tickets for this venue!");
                                return;
                            }
                        }
                        else
                        {
                            MessageBox.Show("This venue already has an event that day!");
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Event must be in the future!");
                    }
                }
                else
                {
                    MessageBox.Show("Event with this title and venue already exists.");
                    return;
                }
            }
        }
Exemple #2
0
        private void cboVenue_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ticks = Venue.getMaxCapacity(cboVenue.Text);

            txtTicketsAvailable.Text = Convert.ToString(ticks);
        }