public static IntermediateStation GetIntermediateStationByName(string name)
        {
            IntermediateStation result = null;
            Hashtable           pars   = new Hashtable();

            pars.Add("@name", name);
            try
            {
                using (DBManager db = new DBManager())
                {
                    db.Open();
                    using (SqlDataReader reader = db.ExecuteQuery(GetIntermediateStationQueryByName, pars))
                    {
                        result = GetIntermediateStationFromDataReader(reader);
                        reader.Close();
                    }
                    db.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        private static IntermediateStation GetIntermediateStationFromDataReader(SqlDataReader reader)
        {
            reader.Read();
            IntermediateStation t = new IntermediateStation()
            {
                Id_IntermediateStation = reader.GetInt32(0),
                Id_id_Station          = reader.GetInt32(1),
                Station       = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                Id_id_Trip    = reader.GetInt32(2),
                DepartureDate = reader.GetDateTime(3).ToShortDateString(),
                ArrivalDate   = reader.GetDateTime(5).ToShortDateString(),
                DepartureTime = reader.GetValue(4).ToString(),
                ArrivalTime   = reader.GetValue(6).ToString()
            };

            return(t);
        }
        private static List <IntermediateStation> GetIntermediateStationsListFromDataReader(SqlDataReader reader)
        {
            List <IntermediateStation> result = new List <IntermediateStation>();

            while (reader.Read())
            {
                IntermediateStation t = new IntermediateStation()
                {
                    Id_IntermediateStation = reader.GetInt32(0),
                    Id_id_Station          = reader.GetInt32(1),
                    Station       = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                    Id_id_Trip    = reader.GetInt32(2),
                    DepartureDate = reader.GetDateTime(3).ToShortDateString(),
                    ArrivalDate   = reader.GetDateTime(5).ToShortDateString(),
                    DepartureTime = reader.GetValue(4).ToString(),
                    ArrivalTime   = reader.GetValue(6).ToString()
                };
                result.Add(t);
            }
            return(result);
        }