private static List <RouteSheet> Get(string request) { List <RouteSheet> resultList = new List <RouteSheet>(); try { SqlDataReader reader = DatabaseConnection.shared.Get(request); while (reader.Read()) { int credentialsInfoId = Convert.ToInt32(reader.GetValue(0)); int itineraryId = Convert.ToInt32(reader.GetValue(1)); string routeDateString = Convert.ToString(reader.GetValue(2)); string driverName = Convert.ToString(reader.GetValue(3)); string conductorName = Convert.ToString(reader.GetValue(4)); int quantity = Convert.ToInt32(reader.GetValue(5)); CredentialsInfo credentialsInfo = GetCredentialsInfo(credentialsInfoId); Itinerary itinerary = GetItinerary(itineraryId); DateTime routeDate = DateTime.Parse(routeDateString); RouteSheet newRouteSheet = new RouteSheet(credentialsInfo, itinerary, routeDate, driverName, conductorName, quantity); resultList.Add(newRouteSheet); } DatabaseConnection.shared.CloseLastConnection(); } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("PersonList is Empty"); } return(resultList); }
public RouteSheet(CredentialsInfo credentialsInfo, Itinerary itinerary, DateTime routeDate, string driverName, string conductorName, int quantity) { this.credentialsInfo = credentialsInfo; this.itinerary = itinerary; this.routeDate = routeDate; this.driverName = driverName; this.conductorName = conductorName; this.quantity = quantity; }
private static List <CredentialsInfo> Get(string request) { List <CredentialsInfo> resultList = new List <CredentialsInfo>(); try { SqlDataReader reader = DatabaseConnection.shared.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); int busId = Convert.ToInt32(reader.GetValue(1)); string categoryString = Convert.ToString(reader.GetValue(2)); string positionString = Convert.ToString(reader.GetValue(3)); string firstWorkDayDateString = Convert.ToString(reader.GetValue(4)); int personId = Convert.ToInt32(reader.GetValue(5)); Bus bus = GetBus(busId); Category category = new Category(categoryString); Position position = new Position(positionString); Person person = GetPerson(personId); DateTime firstWorkDayDate = DateTime.Parse(firstWorkDayDateString); if (position.type == Position.PositionType.Undentified) { Console.WriteLine($"Data Corruption Error: Position is Undentified for id({person.id}) - name({person.name})"); continue; } CredentialsInfo newCredentialsInfo = new CredentialsInfo(id, bus, category, position, firstWorkDayDate, person); resultList.Add(newCredentialsInfo); } DatabaseConnection.shared.CloseLastConnection(); } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("CredentialsInfoList is Empty"); } return(resultList); }