Beispiel #1
0
        public static List <Tram> LaadTrams()
        {
            List <Tram> trams = new List <Tram>();

            try
            {
                connection.Open();
                OracleCommand command = new OracleCommand("SELECT * FROM TRAM");
                command.CommandType = CommandType.Text;
                command.Connection  = connection;

                OracleDataReader reader = command.ExecuteReader();

                if (!reader.HasRows)
                {
                    return(trams);
                }
                else
                {
                    while (reader.Read())
                    {
                        int      id                 = Convert.ToInt32(reader["ID"]);
                        Tramtype tramtype           = (Tramtype)Convert.ToInt32(reader["Tramtype_ID"]) - 1;
                        int      nummer             = Convert.ToInt32(reader["Nummer"]);
                        int      lengte             = Convert.ToInt32(reader["Lengte"]);
                        string   status             = Convert.ToString(reader["Status"]);
                        Remise   remise             = RemiseManager.remiseViaId(Convert.ToInt32(reader["Remise_ID_Standplaats"]));
                        bool     vervuild           = convertBool(Convert.ToString(reader["Vervuild"]));
                        bool     defect             = convertBool(Convert.ToString(reader["Defect"]));
                        bool     conducteurGeschikt = convertBool(Convert.ToString(reader["ConducteurGeschikt"]));
                        bool     beschikbaar        = convertBool(Convert.ToString(reader["Beschikbaar"]));

                        trams.Add(new Tram(id, tramtype, nummer, lengte, status, remise, vervuild, defect, conducteurGeschikt, beschikbaar));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
            return(trams);
        }
Beispiel #2
0
        public static List <Spoor> LaadSporen()
        {
            List <Spoor> sporen = new List <Spoor>();

            try
            {
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                OracleCommand command = new OracleCommand("SELECT * FROM SPOOR");
                command.CommandType = CommandType.Text;
                command.Connection  = connection;

                OracleDataReader reader = command.ExecuteReader();

                if (!reader.HasRows)
                {
                    return(sporen);
                }
                else
                {
                    while (reader.Read())
                    {
                        int    id            = Convert.ToInt32(reader["ID"]);
                        Remise remise        = RemiseManager.remiseViaId(Convert.ToInt32(reader["Remise_ID"]));
                        int    nummer        = Convert.ToInt32(reader["Nummer"]);
                        int    lengte        = Convert.ToInt32(reader["Lengte"]);
                        bool   beschikbaar   = convertBool(Convert.ToString(reader["Beschikbaar"]));
                        bool   inUitrijSpoor = convertBool(Convert.ToString(reader["InUitRijspoor"]));

                        sporen.Add(new Spoor(id, remise, nummer, lengte, beschikbaar, inUitrijSpoor, RemiseManager.sectorenVanSpoor(id)));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
            return(sporen);
        }