private void btnCusSubmit_Click(object sender, EventArgs e) { int cusId, eventId; lblCusMessage.Text = ""; lblEventMessage.Text = ""; // will only work when both customer and event id are integers if (int.TryParse(textBoxCusId.Text, out cusId) && int.TryParse(textBoxEventId.Text, out eventId)) { if (!currentCoord.customerExists(cusId)) { lblCusMessage.Text = "No customer with the ID " + cusId; } if (!currentCoord.eventExists(eventId)) { lblEventMessage.Text = "No event with the ID " + eventId; } // will only work if both customer and event exist, and if the event is not full or customer has not already registered if (currentCoord.customerExists(cusId) && currentCoord.eventExists(eventId) && !currentCoord.eventIsFull(eventId) && !currentCoord.customerRegisteredForEvent(eventId, cusId)) { Event ev = currentCoord.getEvent(eventId); Customer cust = currentCoord.getCustomer(cusId); currentCoord.addRegistration(ev, cust); ev.addAttendee(cust); cust.addBooking(); lblMessage.ForeColor = System.Drawing.Color.Black; lblCusMessage.Text = "RSVP Successfully added"; textBoxCusId.Text = ""; textBoxEventId.Text = ""; } else if (currentCoord.customerExists(cusId) && currentCoord.eventExists(eventId)) { lblCusMessage.Text = "RSVP was not added"; textBoxCusId.Text = ""; textBoxEventId.Text = ""; } } else { lblCusMessage.Text = "Please enter valid IDs in the fields"; } }