public void UcitajSveLetove() { using (SqlConnection conn = new SqlConnection()) { Letovi.Clear(); conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Letovi WHERE aktivan=1"; SqlDataAdapter daLetovi = new SqlDataAdapter(); DataSet dsLetovi = new DataSet(); daLetovi.SelectCommand = command; daLetovi.Fill(dsLetovi, "Letovi"); foreach (DataRow row in dsLetovi.Tables["Letovi"].Rows) { Let let = new Let(); let.Id = (int)row["Id"]; let.Sifra = (string)row["Sifra"]; let.Pilot = (string)row["Pilot"]; let.BrojLeta = (int)row["BrojLeta"]; let.Odrediste = (string)row["Odrediste"]; let.Destinacija = (string)row["Destinacija"]; let.VremePolaska = (DateTime)Convert.ToDateTime(row["VremePolaska"]); let.VremeDolaska = (DateTime)Convert.ToDateTime(row["VremeDolaska"]); let.Cena = (double)Convert.ToDouble(row["Cena"]); let.Aktivan = (bool)row["Aktivan"]; Letovi.Add(let); } } }
public void UcitajLetove() { Letovi.Clear(); foreach (Let l in LetDAO.VratiLetove()) { this.Letovi.Add(l); } }