示例#1
0
        public List <Bestelling> GetAllBestellingen()
        {
            // Breng de database verbinding tot stand en voer een query uit
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            DBConnectie.Open();
            SqlCommand    command = new SqlCommand("SELECT * FROM Bestelling", DBConnectie);
            SqlDataReader reader  = command.ExecuteReader();

            // Maak een list met Bestelling
            List <Bestelling> bestellingen = new List <Bestelling>();

            // Vul de list met alle records die geretourneerd worden
            while (reader.Read())
            {
                Bestelling bestelling = new Bestelling();

                bestelling.Id = reader.GetInt32(0);
                bestelling.CommentaarKlant = reader.GetString(1);
                bestelling.TafelId         = reader.GetInt32(2);
                bestelling.MedewerkerId    = reader.GetInt32(3);
                bestelling.Totaalprijs     = reader.GetDouble(4);
                bestelling.Betaald         = reader.GetString(5);
                bestelling.Btw             = reader.GetDouble(6);
                bestelling.Fooi            = reader.GetDouble(7);
                bestelling.BetaalWijze     = reader.GetString(8);

                bestellingen.Add(bestelling);
            }

            reader.Close();
            DBConnectie.Close();

            return(bestellingen);
        }