private void btnSearchEvent_Click(object sender, EventArgs e)
        {
            lblEventId.Text    = "";
            lblEventName.Text  = "";
            lblEventVenue.Text = "";
            lblEventDate.Text  = "";
            lblRegAttend.Text  = "";
            lblAvailSpace.Text = "";
            txtAttendList.Text = "";
            lblSuccessMsg.Text = "";

            if (!validId(txtEventID.Text))
            {
                lblSuccessMsg.Text      = "Ivalid ID Entered";
                lblSuccessMsg.ForeColor = Color.OrangeRed;
                txtEventID.Text         = "";
                return;
            }

            int eventId = Convert.ToInt32(txtEventID.Text);

            if (eCoord.eventExists(eventId))
            {
                Event eventFound = eCoord.getEvent(eventId);
                lblEventId.Text         = Convert.ToString(eventFound.getEventId());
                lblEventName.Text       = eventFound.getEventName();
                lblEventVenue.Text      = eventFound.getVenue();
                lblEventDate.Text       = eventFound.getEventDate().ToString();
                lblRegAttend.Text       = Convert.ToString(eventFound.getNumAttendees());
                lblAvailSpace.Text      = Convert.ToString(eventFound.getAvailableSpace());
                txtAttendList.Text      = eventFound.getAttendees();
                lblSuccessMsg.ForeColor = Color.MediumSpringGreen;
                txtEventID.Text         = "";
                lblSuccessMsg.Text      = "Event Found";
            }
            else
            {
                txtEventID.Text         = "";
                lblSuccessMsg.ForeColor = Color.OrangeRed;
                lblSuccessMsg.Text      = "No Event Found";
            }
        }
예제 #2
0
        private void btnSubmitCustomer_Click(object sender, EventArgs e)
        {
            int eventId, custId;

            t = new Timer();

            //specific validations give feedback to user on what went wrong
            if (!validId(txtCustId.Text))
            {
                lblSuccessMsg.Text      = "Invalid Customer ID";
                lblCustomerID.ForeColor = Color.OrangeRed;
                txtCustId.Text          = "";
                return;
            }

            if (!validId(txtEventId.Text))
            {
                lblSuccessMsg.Text   = "Invalid Event ID";
                lblEventID.ForeColor = Color.OrangeRed;
                txtEventId.Text      = "";
                return;
            }

            eventId = Convert.ToInt32(txtEventId.Text);
            custId  = Convert.ToInt32(txtCustId.Text);

            if (eventCoord.customerExists(custId) && eventCoord.eventExists(eventId))
            {
                Event    resEvent = eventCoord.getEvent(eventId);
                Customer resCust  = eventCoord.getCustomerById(custId);

                if (resEvent.getNumAttendees() >= resEvent.getMaxAttendees())
                {
                    lblSuccessMsg.ForeColor = Color.OrangeRed;
                    lblSuccessMsg.Text      = "Max Attendees Reached, Reservation Not Added";
                    return;
                }

                if (eventCoord.customerAlreadyRegistered(custId, eventId))
                {
                    lblSuccessMsg.ForeColor = Color.OrangeRed;
                    lblSuccessMsg.Text      = "Customer Already Registered";
                    return;
                }

                if (eventCoord.addReservation(DateTime.Now.ToString(), resEvent, resCust))
                {
                    progress.Style          = ProgressBarStyle.Blocks;
                    progress.Value          = progress.Maximum;
                    lblCustomerID.ForeColor = Color.SpringGreen;
                    lblEventID.ForeColor    = Color.SpringGreen;
                    lblSuccessMsg.ForeColor = Color.SpringGreen;
                    lblCustomerID.BackColor = Color.Black;
                    lblEventID.BackColor    = Color.Black;
                    lblSuccessMsg.Text      = "Reservation Successfully Added";
                    t.Interval = 2000;
                    t.Tick    += new EventHandler(timer_Tick);
                    t.Start();;
                }
                else
                {
                    lblSuccessMsg.ForeColor = Color.OrangeRed;
                    lblSuccessMsg.Text      = "Error Occured, Event Not Added";
                }
            }
            else
            {
                if (eventCoord.customerExists(custId))
                {
                    lblSuccessMsg.ForeColor = Color.OrangeRed;
                    lblSuccessMsg.Text      = "Invalid Event ID";
                }
                else
                {
                    lblSuccessMsg.ForeColor = Color.OrangeRed;
                    lblSuccessMsg.Text      = "Invalid Customer ID";
                }
            }
        }