public Ticket GetTicketFromList() { object item = lstActiveTickets.SelectedItem; if (item != null) { string ticketID = item.ToString().Substring(1, 7); return(activeTickets.GetTicket(ticketID)); } return(null); }
private void btnPayForTicket_Click(object sender, EventArgs e) { int index = lstActiveTickets.SelectedIndex; if (index != -1) { Ticket ticket; ticket = activeTickets.GetTicket(index); paymentMachine.PayTicket(ticket); UpdateDisplay(); } else { MessageBox.Show("Please select the ticket that you want to pay for"); } }