private static Collection <HistorieMaterialu> Read(SqlDataReader reader, bool complete) { Collection <HistorieMaterialu> historieMaterialuCollection = new Collection <HistorieMaterialu>(); while (reader.Read()) { HistorieMaterialu hm = new HistorieMaterialu(); int i = -1; hm.IdHistorie = reader.GetInt32(++i); hm.DatumZmeny = DateTime.Parse(reader.GetString(++i)); hm.TypZmeny = reader.GetString(++i); hm.IdVyukovyMaterial = reader.GetInt32(++i); hm.Nazev = reader.GetString(++i); hm.Text = reader.GetString(++i); hm.Vlozen = DateTime.Parse(reader.GetString(++i)); if (complete) { hm.Material = new VyukovyMaterial(); hm.Material.IdVyukovyMaterial = hm.IdVyukovyMaterial; hm.Material.Nazev = reader.GetString(++i); hm.Material.Text = reader.GetString(++i); hm.Material.IdKurz = reader.GetInt32(++i); hm.Material.IdVyucujici = reader.GetInt32(++i); } historieMaterialuCollection.Add(hm); } return(historieMaterialuCollection); }
private static void PrepareCommand(SqlCommand command, HistorieMaterialu hm) { command.Parameters.AddWithValue("@IdHistorie", hm.IdHistorie); command.Parameters.AddWithValue("@DatumZmeny", hm.DatumZmeny); command.Parameters.AddWithValue("@TypZmeny", hm.TypZmeny); command.Parameters.AddWithValue("@IdVyukovyMaterial", hm.IdVyukovyMaterial); command.Parameters.AddWithValue("@Nazev", hm.Nazev); command.Parameters.AddWithValue("@Text", hm.Text); command.Parameters.AddWithValue("@Vlozen", hm.Vlozen); }