public static ObservableCollection<TicketType> GetTicketType() { ObservableCollection<TicketType> ocTicketType = new ObservableCollection<TicketType>(); string sSql = "Select * from TicketType"; DbDataReader reader = DbAccess.GetData(sSql); while (reader.Read()) { TicketType tt = new TicketType() { ID = (int)reader[0], Name = (string)reader[1], //Price = (double)reader[2], AvailableTickets = (int)reader[3] }; ocTicketType.Add(tt); } return ocTicketType; }
public static ObservableCollection<Ticket> GetTickets() { ObservableCollection<Ticket> ocTicket = new ObservableCollection<Ticket>(); string sSql = "Select * from Ticket INNER JOIN TicketType on Ticket.TicketType = TicketType.Id"; DbDataReader reader = DbAccess.GetData(sSql); while (reader.Read()) { TicketType tt = new TicketType() { ID = (int)reader[5], Name = (string)reader[6], Price = (double)reader[7], AvailableTickets = (int)reader[8] }; Ticket tick = new Ticket() { ID = (int)reader[0], Ticketholder = (string)reader[1], TicketholderEmail = (string)reader[2], TicketType = tt, Amount = (int)reader[4] }; ocTicket.Add(tick); } return ocTicket; }