private static PeopleList BuildAuthorList(DbDataReader reader) { if (reader != null && reader.HasRows) { PeopleList authors = new PeopleList(); Random r = new Random(); while (reader.Read()) { Author auth = new Author(); auth.ID = reader["au_ID"].ToString(); auth.FirstName = reader["au_fname"].ToString(); auth.LastName = reader["au_lname"].ToString(); auth.Age = r.Next(16, 110); //Simulate age auth.Phone = reader["phone"].ToString(); auth.Address = reader["address"].ToString(); auth.City = reader["city"].ToString(); auth.State = reader["state"].ToString(); auth.Zip = reader["zip"].ToString(); auth.HasContract = bool.Parse(reader["contract"].ToString()); authors.AddPerson(auth); } return(authors); } return(null); }
private void btnSubmit_Click(object sender, EventArgs e) { PeopleList authors = AuthorsDB.GetAuthors(); BindingSource bs = new BindingSource(); bs.DataSource = authors; gvAuthors.DataSource = bs; }