Beispiel #1
0
 public static List<Play> PlList(int? id = null)
 {
     OleDbConnection conn = MyConnection.GetConnection();
     OleDbCommand cmd = new OleDbCommand(SelectAll, conn);
     OleDbDataReader rdr = cmd.ExecuteReader();
     pList.Clear();
     Play p = null;
     selPur = null;
     int idPlays = -1;
     int idP=0;
     while (rdr.Read())
     {
         idP = rdr.GetInt32(0);
         if (idP != idPlays)
         {
             if (p != null)
                 pList.Add(p);
             idPlays = idP;
             p = new Play(idPlays, rdr.GetString(1));
             if (p.ID == id) selPur = p;
         }
         p.Addl(rdr.GetString(2),rdr.GetString(3),rdr.GetDateTime(4));
     }
     if (p != null)
         pList.Add(p);
     return pList;
 }
Beispiel #2
0
        public static Play SelectPlay(int id)
        {
            Play p = null;
            OleDbConnection conn = MyConnection.GetConnection();
            OleDbCommand cmd = new OleDbCommand(SelectOneName, conn);
            cmd.Parameters.AddWithValue("@id", id);
            OleDbDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())
            {
                string name = rdr.GetString(0);
                HashSet<string> genres = new HashSet<string>();
                HashSet<string> authors = new HashSet<string>();
                cmd.CommandText = SelectOneAutors;
                cmd.Parameters.AddWithValue("@id", id);
                rdr.Close();
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    authors.Add(rdr.GetString(0));
                }
                cmd.CommandText = SelectOneGenres;
                cmd.Parameters.AddWithValue("@id", id);
                rdr.Close();
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    genres.Add(rdr.GetString(0));
                }
                p = new Play(id, name, genres, authors, null);
            }
            return p;
        }