private void Buy_Button_Click(object sender, RoutedEventArgs e) { try { ServiceReference1.FlightAirportDto flight = (ServiceReference1.FlightAirportDto)dgFlightsAirportsBuyTicket.SelectedItem; ServiceReference1.PassengerDto pass = (ServiceReference1.PassengerDto)dgPassengersBuyTicket.SelectedItem; ServiceReference1.TicketDto ticket = new ServiceReference1.TicketDto(); ServiceReference1.TicketDto[] tickets = proxyTicket.GetTickets(); List <ServiceReference1.TicketDto> ticks = new List <ServiceReference1.TicketDto>(tickets); int max = ticks.Max(x => x.TicketId); ticket.TicketId = max + 1; ticket.Price = 100; ticket.FlightId = flight.FlightId; ticket.PassengerId = pass.PassengerId; proxyTicket.AddTicket(ticket); var passengers = proxyPassenger.GetPassengers(); var flights = proxyFlight.GetFlights(); tickets = proxyTicket.GetTickets(); var flightsAirports = proxyFlight.GetFlightsAirports(); dgPassengers.ItemsSource = passengers; dgPassengersBuyTicket.ItemsSource = passengers; dgFlights.ItemsSource = flights; dgTickets.ItemsSource = tickets; dgFlightsAirports.ItemsSource = flightsAirports; dgFlightsAirportsBuyTicket.ItemsSource = flightsAirports; } catch (Exception ex) { MessageBox.Show("Add proper params", "PARAMS !!", MessageBoxButton.OK); return; } }
private void DgFlightsAirportsBuyTicket_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { ServiceReference1.FlightAirportDto flightAirport = (ServiceReference1.FlightAirportDto)dgFlightsAirportsBuyTicket.SelectedItem; BuyTicketArrivalDeparture.Content = flightAirport.TimeArrival; BuyTicketTimeDeparture.Content = flightAirport.TimeDeparture; BuyTicketAimArrivalCity.Content = flightAirport.AimArrivalCity; BuyTicketAimDepartureCity.Content = flightAirport.AimDepartureCity; }