public List<Huur> GetAllHuren() { List<Huur> ret = new List<Huur>(); try { Con.Open(); Cmd.CommandText = "SELECT * FROM HUUR"; OracleDataReader dr = Cmd.ExecuteReader(); while (dr.Read()) { Cmd.Parameters.Clear(); int huurid = dr.GetInt32(0); Cmd.CommandText = "SELECT Naam FROM boothuur WHERE Huurid = :hid"; Cmd.Parameters.Add("hid", huurid); OracleDataReader dr2 = Cmd.ExecuteReader(); dr2.Read(); Boot bname = new Spierkrachtboot(); if (dr2.HasRows) { bname.Naam = dr2.GetString(0); } Cmd.CommandText = "SELECT NAAM FROM KLANT WHERE KLANTID = :kid"; Cmd.Parameters.Add("kid", dr.GetInt32(1)); OracleDataReader dr3 = Cmd.ExecuteReader(); dr3.Read(); string kname = null; if (dr3.HasRows) { kname = dr3.GetString(0); } Huur add = new Huur { Huurdernaam = kname, Boot = bname, HuurBegin = dr.GetDateTime(2), HuurEind = dr.GetDateTime(3) }; ret.Add(add); } Con.Close(); return ret; } catch(OracleException e) { Console.WriteLine("Oh noes OracleException: " + e.Message); Con.Close(); return null; } }
public List<Boot> GetBoats(string type) { List<Boot> ret = new List<Boot>(); try { Con.Open(); Cmd.CommandText = "SELECT * FROM BOOT WHERE Type = :tp"; Cmd.Parameters.Add("tp", type); OracleDataReader dr = Cmd.ExecuteReader(); while (dr.Read()) { if (type == "Motorboot") { Motorboot add = new Motorboot(dr.GetInt32(2), dr.GetString(0), dr.GetString(3)); ret.Add(add); } else { Spierkrachtboot adds = new Spierkrachtboot(dr.GetString(0), dr.GetString(3)); ret.Add(adds); } } Cmd.Parameters.Clear(); Con.Close(); return ret; } catch (OracleException e) { Console.WriteLine("Oh noes OracleException: " + e.Message); Con.Close(); return null; } }