private void btnSubmit_Click(object sender, EventArgs e) { // show new style of view when submit is clicked textBoxId.Focus(); btnShowCustomers.Show(); lblMessage.Show(); int id; if (int.TryParse(textBoxId.Text, out id)) { string customer = currentCoord.getCustomerInfoById(id); if (currentCoord.customerExists(id)) { labelBookings.Text = "Bookings"; string[] customerFields = customer.Split(';'); labelNumberInfo.Text = customerFields[0]; labelNameInfo.Text = customerFields[1]; labelPhoneInfo.Text = customerFields[2]; labelBookingsInfo.Text = customerFields[3]; lblMessage.Hide(); } else { clearCustomers(); labelBookings.Text = ""; lblMessage.Text = customer; } } else { clearCustomers(); lblMessage.Text = "Invalid input for ID search"; } textBoxId.Text = ""; }
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"; } }
private void btnSubmit_Click(object sender, EventArgs e) { btnShowCustomers.Show(); lblMessage.Show(); clearCustomers(); int id; if (int.TryParse(textBoxId.Text, out id)) { if (currentCoord.customerExists(id)) { // change to customer view for deletion confirmation string customer = currentCoord.getCustomerInfoById(id); labelBookings.Text = "Bookings"; string[] customerFields = customer.Split(';'); labelNumberInfo.Text = customerFields[0]; labelNameInfo.Text = customerFields[1]; labelPhoneInfo.Text = customerFields[2]; labelBookingsInfo.Text = customerFields[3]; lblMessage.Text = "Are you sure you want to delete customer with ID " + id + "?"; btnConfirm.Show(); btnDeny.Show(); textBoxId.Hide(); labelCusId.Hide(); btnSubmit.Hide(); } else { lblMessage.Text = "Customer with ID " + id + " was not found.."; } } else { lblMessage.Text = "Invalid input for ID search"; } }