I am creating a program that simulates a flight reservation system. An admin will create each flight. The user will then fill in required search fields, and the flights matching those fields will be found and print out. With each match, there is a 'book' button. My question is, how can I make it so that when the user clicks the button, it runs the code based on that specific flight?
Ex: Clicking the 'book' button on a flight from L.A. to Chicago would differ from clicking the 'book' button on a flight from New York to Dallas.
The code for creating a flight is as follows:
public void addFlight()
{
Maintenance maint = new Maintenance();
btn.Text = "Book";
airline.Add(maint.airlineMaintComboBox.Text);
price.Add(int.Parse(maint.minPriceMaintTextBox.Text));
originCity.Add(maint.cityOriginMaintTextBox.Text);
originState.Add(maint.stateOriginMaintComboBox.Text);
destCity.Add(maint.cityDestMaintTextBox.Text);
destState.Add(maint.stateDestMaintComboBox.Text);
dateChosen = maint.dateMaintPicker.Value.ToString();
date.Add(maint.dateMaintPicker.Value.ToString());
seats.Add(int.Parse(maint.peopleMaintComboBox.Text));
buttons.Add(btn);
totalFlights++;
}
Basically just adds the data to lists, then later the index list gets printed out.