private void btnSearchCustomer_Click(object sender, EventArgs e)
        {
            lblSuccessMsg.Text = "";

            //checks for letters in id input
            if (!validId(txtCustomerID.Text))
            {
                lblSuccessMsg.ForeColor = Color.OrangeRed;
                lblSuccessMsg.Text      = "Invalid ID Entered";
                txtCustomerID.Text      = "";
                return;
            }

            int customerIdToDel = Convert.ToInt32(txtCustomerID.Text);

            //check if that customer id exists
            if (eCoord.customerExists(customerIdToDel))
            {
                Customer custToDel = eCoord.getCustomerById(customerIdToDel);
                lblConfirmDelete.Text = "Delete Customer " + custToDel.getId() + " (" + custToDel.getFirstName() + " " + custToDel.getLastName() + ")?";
                btnYes.Visible        = true;
                btnCancel.Visible     = true;
            }
            else
            {
                txtCustomerID.Text = "";
                lblSuccessMsg.Text = "Customer Not 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";
                }
            }
        }