public TripCollection SelectList() { TripCollection collection = new TripCollection(); IDataReader Reader = DataAccess.SelectList(); while (Reader.Read()) { TripInfo tripInfo = new TripInfo(); tripInfo.TripID = Convert.ToString(Reader["TripID"]); tripInfo.TripCode = Convert.ToString(Reader["TripCode"]); tripInfo.TripDate = Convert.ToDateTime(Reader["Date"]); tripInfo.TimeID = Convert.ToString(Reader["TimeID"]); tripInfo.Time = Convert.ToString(Reader["Time"]); tripInfo.RouteID = Convert.ToString(Reader["RouteID"]); tripInfo.RouteName = Convert.ToString(Reader["RouteName"]); tripInfo.BusID = Convert.ToString(Reader["BusID"]); tripInfo.BusNo = Convert.ToString(Reader["BusNo"]); tripInfo.Driver1ID = Convert.ToString(Reader["Driver1ID"]); tripInfo.Driver1Name = Convert.ToString(Reader["DriverName"]); tripInfo.Driver2ID = Convert.ToString(Reader["Driver2ID"]); tripInfo.Driver2Name = Convert.ToString(Reader["DriverName"]); tripInfo.Price = Convert.ToDecimal(Reader["Price"]); collection.Add(tripInfo); } Reader.Close(); return(collection); }
public TripInfo SelectBusTripID(string routeID, DateTime date, string timeID) { TripInfo tripInfo = new TripInfo(); IDataReader reader = DataAccess.SelectBusTripID(routeID, date, timeID); if (reader.Read()) { tripInfo.TripID = Convert.ToString(reader["TripID"]); tripInfo.BusID = Convert.ToString(reader["BusID"]); tripInfo.BusNo = Convert.ToString(reader["BusNo"]); tripInfo.Price = Convert.ToInt32(reader["Price"]); } reader.Close(); return(tripInfo); }
public TripCollection SelectTime(string routeID, DateTime date) { TripCollection tripCollection = new TripCollection(); IDataReader reader = DataAccess.SelectTime(routeID, date); while (reader.Read()) { TripInfo tripInfo = new TripInfo(); tripInfo.TimeID = Convert.ToString(reader["TimeID"]); tripInfo.Time = Convert.ToString(reader["Time"]); tripCollection.Add(tripInfo); } reader.Close(); return(tripCollection); }
public TripCollection SelectDateByRouteID(string routeID) { TripCollection tripCollection = new TripCollection(); IDataReader Reader = DataAccess.SelectDateByRouteID(routeID); while (Reader.Read()) { TripInfo tripInfo = new TripInfo(); tripInfo.TripDate = Convert.ToDateTime(Reader["Date"]); tripCollection.Add(tripInfo); } Reader.Close(); return(tripCollection); }
public TripDetailCollection SelectDetailByTripID(string tripID) { TripInfo tripInfo = new TripInfo(); string TripID = Convert.ToString(tripInfo.TripID); IDataReader Reader = DataAccess.SelectDetailByTripID(tripID); TripDetailCollection collection = new TripDetailCollection(); while (Reader.Read()) { TripDetailInfo tripDeatilInfo = new TripDetailInfo(); tripDeatilInfo.TripID = TripID; tripDeatilInfo.SeatNo = Convert.ToString(Reader["SeatNo"]); tripDeatilInfo.Status = Convert.ToString(Reader["Status"]); collection.Add(tripDeatilInfo); } Reader.Close(); return(collection); }
public void Insert(TripInfo tripInfo, TripDetailCollection tripDetailCollection) { try { DataControlBaseDataAccess.StartTransaction(); string TripID = DataAccess.Insert(tripInfo.TripID, tripInfo.TripCode, tripInfo.TripDate, tripInfo.TimeID, tripInfo.RouteID, tripInfo.Driver1ID, tripInfo.Driver2ID, tripInfo.BusID, tripInfo.Price); foreach (TripDetailInfo tripDetailInfo in tripDetailCollection) { TripDetailDataAccess.InsertDetail(tripDetailInfo.TripDetailID, TripID, tripDetailInfo.SeatNo, tripDetailInfo.Status); } DataControlBaseDataAccess.CommitTransaction(); } catch (Exception ex) { DataControlBaseDataAccess.RollBackTransaction(); throw ex; } }
public TripInfo SelectByTripID(string tripID) { TripInfo tripInfo = new TripInfo(); IDataReader Reader = DataAccess.SelectByTripID(tripID); if (Reader.Read()) { tripInfo.TripID = Convert.ToString(Reader["TripID"]); tripInfo.TripCode = Convert.ToString(Reader["TripCode"]); tripInfo.TripDate = Convert.ToDateTime(Reader["Date"]); tripInfo.TimeID = Convert.ToString(Reader["TimeID"]); tripInfo.Time = Convert.ToString(Reader["Time"]); tripInfo.RouteID = Convert.ToString(Reader["RouteID"]); tripInfo.Driver1ID = Convert.ToString(Reader["Driver1ID"]); tripInfo.Driver2ID = Convert.ToString(Reader["Driver2ID"]); tripInfo.BusID = Convert.ToString(Reader["BusID"]); tripInfo.Price = Convert.ToDecimal(Reader["Price"]); } Reader.Close(); return(tripInfo); }