public void LoadSeats() { SeatAvailable.Clear(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Seat"; SqlDataAdapter daSeats = new SqlDataAdapter(); DataSet dsSeats = new DataSet(); daSeats.SelectCommand = command; daSeats.Fill(dsSeats, "Seats"); foreach (DataRow row in dsSeats.Tables["Seats"].Rows) { Seat seat = new Seat(); seat.Id = (int)row["Id"]; seat.SeatLabel = (string)row["SeatLabel"]; seat.SeatClass = (EClass)row["SeatClass"]; seat.SeatState = (bool)row["SeatState"]; seat.AirplaneId = (string)row["AirplaneId"]; seat.Active = (bool)row["Active"]; SeatAvailable.Add(seat); } } }
public ObservableCollection <Seat> SeatsEconomy(int rowNum, int colNum, int input) { ObservableCollection <Seat> seatE = new ObservableCollection <Seat>(); for (int i = 0; i < SeatLabels(rowNum, colNum).Count; i++) { if (i >= input) { Seat seatEconomy = new Seat(); seatEconomy.SeatLabel = SeatLabels(rowNum, colNum)[i]; seatEconomy.SeatClass = EClass.ECONOMY; seatEconomy.SeatState = true; seatEconomy.Active = false; seatE.Add(seatEconomy); SeatAvailable.Add(seatEconomy); } } return(seatE); }
public ObservableCollection <Seat> SeatsBusiness(int rowNum, int colNum, int input) { ObservableCollection <Seat> seatB = new ObservableCollection <Seat>(); for (int i = 0; i < SeatLabels(rowNum, colNum).Count; i++) { if (i < input) { Seat seat = new Seat(); seat.SeatLabel = SeatLabels(rowNum, colNum)[i]; seat.SeatClass = EClass.BUSINESS; seat.SeatState = true; seat.Active = false; seatB.Add(seat); SeatAvailable.Add(seat); } } return(seatB); }