private void Add_Click(object sender, RoutedEventArgs e) { if (!fk.Text.Equals("") && !seats.Text.Equals("")) { Flights flights = new Flights { FK_Route = Convert.ToInt32(fk.Text), PK_Flight = Convert.ToInt32(pk.Text), SeatCount = Convert.ToInt32(seats.Text) }; db.Flights.Add(flights); db.SaveChanges(); Flight_DB.Items.Refresh(); pk.Text = (Convert.ToInt32(pk.Text) + 1).ToString(); Refreshh(); } }
private void Update_Click(object sender, RoutedEventArgs e) { _listBoxItemFlight = new ObservableCollection <FlightTable>( (from flights in db.Flights join Routes in db.RoutePass on flights.FK_Route equals Routes.PK_Route select new FlightTable { PK_Flight = flights.PK_Flight, FK_Route = flights.FK_Route, SeatCount = flights.SeatCount, DeparturePoint = Routes.DeparturePoint, ArrivalPoint = Routes.ArrivalPoint, DepartureDate = Routes.DepartureDate, ArrivalDate = Routes.ArrivalDate })); DB.ItemsSource = _listBoxItemFlight; DB.Items.Refresh(); db.SaveChanges(); }