// bruges til mail system - sender personale info public IList <Personale> GetHvorHvem() { const string selectAllLyde = "SELECT Personale.Navn, Personale.Telf, Personale.Email, Steder.Sted FROM Personale INNER JOIN Steder ON Personale.[FK StedId]=Steder.IdSted"; using (SqlConnection databaseConnection = new SqlConnection(ConnectionString)) { databaseConnection.Open(); using (SqlCommand selectCommand = new SqlCommand(selectAllLyde, databaseConnection)) { using (SqlDataReader reader = selectCommand.ExecuteReader()) { List <Personale> personList = new List <Personale>(); while (reader.Read()) { string personale = reader.GetString(0); int telefon = reader.GetInt32(1); string email = reader.GetString(2); string sted = reader.GetString(3); Personale l1 = new Personale() { Navn = personale, Sted = sted, Telf = telefon, Email = email }; personList.Add(l1); } return(personList); } } } }
// Henter personale fra db (hardcoded ind for at vise ekspempel) public IList <Personale> GetAllPersonale() { { const string selectAllLyde = "Select * from Personale"; using (SqlConnection databaseConnection = new SqlConnection(ConnectionString)) { databaseConnection.Open(); using (SqlCommand selectCommand = new SqlCommand(selectAllLyde, databaseConnection)) { using (SqlDataReader reader = selectCommand.ExecuteReader()) { List <Personale> personaleList = new List <Personale>(); while (reader.Read()) { string navn = reader.GetString(1); int telf = reader.GetInt32(2); string email = reader.GetString(3); Personale l1 = new Personale() { Navn = navn, Telf = telf, Email = email }; personaleList.Add(l1); } return(personaleList); } } } } }