public static void Transactions() { //created a command Command.CommandText = "select * from Transactions"; Reader = Command.ExecuteReader(); while (Reader.Read()) { string SerialNumber = (string)Reader["SerialNumber"]; string CustomerId = (string)Reader["CustomerId"]; string TripId = (string)Reader["TripId"]; string TypeOfTicket = (string)Reader["TypeOfTicket"]; double Price = (double)Reader["Price"]; int NumberOfSeats = (int)Reader["NumberOfSeats"]; Customer CurrentCustomer = SelectCustomer(CustomerId); Trip CurrentTrip = SelectTrip(TripId); if (CurrentCustomer == null || CurrentTrip == null) { continue; } Ticket CurrentTicket = new Ticket(SerialNumber, CurrentTrip, TypeOfTicket, Price, NumberOfSeats); CurrentCustomer.AddTicket(CurrentTicket); CurrentTrip.AddTicket(CurrentTicket); } Reader.Close(); return; }
private static void Transactions() { //created a command Command.CommandText = "select * from Transactions"; Reader = Command.ExecuteReader(); while (Reader.Read()) { string SerialNumber = (string)Reader["SerialNumber"]; string CustomerId = (string)Reader["CustomerId"]; string TripId = (string)Reader["TripId"]; string TypeOfTicket = (string)Reader["TypeOfTicket"]; string TypeOfTrip = (string)Reader["TypeOfTrip"]; double Price = (double)Reader["Price"]; int NumberOfSeats = (int)Reader["NumberOfSeats"]; Customer CurrentCustomer = SelectCustomer(CustomerId); Trip CurrentTrip = SelectTrip(TripId); if (CurrentCustomer == null || CurrentTrip == null) { continue; } //gets typeoftrip TripType tripType = null; if (TypeOfTrip == "Family") { tripType = new Family(); } else if (TypeOfTrip == "Couple") { tripType = new Couple(); } else if (TypeOfTrip == "General") { tripType = new General(); } else if (TypeOfTrip == "Lonely") { tripType = new Lonely(); } else if (TypeOfTrip == "Friends") { tripType = new Friends(); } Ticket CurrentTicket = new Ticket(SerialNumber, CurrentTrip, TypeOfTicket, tripType, Price, NumberOfSeats); CurrentCustomer.AddTicket(CurrentTicket); CurrentTrip.AddTicket(CurrentTicket); } Reader.Close(); return; }