Example #1
0
 public void loadData(string[] TitleStartWith)
 {
     using (new WaitCursor())
         using (IDbCommand cmd = BDPPCDatabase.getCommand())
         {
             StringBuilder SQL = new StringBuilder();
             SQL.Append("SELECT * FROM ALBUMS A INNER JOIN SERIES S ON A.REFSERIE = S.REFSERIE");
             if (TitleStartWith != null && TitleStartWith.Length > 0)
             {
                 SQL.Append("\nWHERE");
                 for (int i = 0; i < TitleStartWith.Length; i++)
                 {
                     SQL.Append((i == 0 ? "" : "\nOR") + "\nUPPERTITREALBUM LIKE ?");
                     cmd.Parameters.Add(BDPPCDatabase.getParameter("@P" + i.ToString(), TitleStartWith[i].ToUpper() + "%"));
                 }
             }
             SQL.Append("\nORDER BY A.UPPERTITREALBUM");
             cmd.CommandText = SQL.ToString();
             using (IDataReader result = cmd.ExecuteReader())
                 using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Album)))
                     if (result != null)
                     {
                         dataReader.fillList(this);
                     }
         }
 }
Example #2
0
 public void loadData(string[] TitleStartWith)
 {
     using (new WaitCursor())
         using (IDbCommand cmd = BDPPCDatabase.getCommand())
         {
             StringBuilder SQL = new StringBuilder();
             SQL.Append("SELECT REFEMPRUNTEUR, NOMEMPRUNTEUR FROM EMPRUNTEURS");
             if (TitleStartWith != null && TitleStartWith.Length > 0)
             {
                 SQL.Append("\nWHERE");
                 for (int i = 0; i < TitleStartWith.Length; i++)
                 {
                     SQL.Append((i == 0 ? "" : "\nOR") + "\nUPPERNOMEMPRUNTEUR LIKE ?");
                     cmd.Parameters.Add(BDPPCDatabase.getParameter("@P" + i.ToString(), TitleStartWith[i].ToUpper() + "%"));
                 }
             }
             SQL.Append("\nORDER BY UPPERNOMEMPRUNTEUR");
             cmd.CommandText = SQL.ToString();
             using (IDataReader result = cmd.ExecuteReader())
                 using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Emprunteur)))
                     if (result != null)
                     {
                         dataReader.fillList(this);
                     }
         }
 }
Example #3
0
 public void loadData(string[] TitleStartWith)
 {
     using (new WaitCursor())
         using (IDbCommand cmd = BDPPCDatabase.getCommand())
         {
             StringBuilder SQL = new StringBuilder();
             SQL.Append("SELECT * FROM SERIES S LEFT JOIN EDITEURS E ON S.REFEDITEUR = E.REFEDITEUR LEFT JOIN COLLECTIONS C ON S.REFCOLLECTION=C.REFCOLLECTION");
             if (TitleStartWith != null && TitleStartWith.Length > 0)
             {
                 SQL.Append("\nWHERE");
                 for (int i = 0; i < TitleStartWith.Length; i++)
                 {
                     SQL.Append((i == 0 ? "" : "\nOR") + "\nUPPERTITRESERIE LIKE ?");
                     cmd.Parameters.Add(BDPPCDatabase.getParameter("@P" + i.ToString(), TitleStartWith[i].ToUpper() + "%"));
                 }
             }
             SQL.Append("\nORDER BY S.UPPERTITRESERIE");
             cmd.CommandText = SQL.ToString();
             using (IDataReader result = cmd.ExecuteReader())
                 using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Serie)))
                     if (result != null)
                     {
                         dataReader.fillList(this);
                     }
         }
 }
Example #4
0
        public static bool checkVersion(bool Force)
        {
            using (IDbCommand cmd = BDPPCDatabase.getCommand())
            {
                cmd.CommandText = "SELECT VALEUR FROM OPTIONS WHERE Nom_option = 'Version'";
                string   version  = (string)cmd.ExecuteScalar();
                Assembly assembly = Assembly.GetExecutingAssembly();
                if (version == null)
                {
                    version         = "0.0.0.0";
                    cmd.CommandText = "INSERT INTO OPTIONS (Nom_Option, Valeur) VALUES ('Version', ?)";
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@version", version));
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch
                    {
                    }
                }

                string msg = "BDthèque ne peut pas utiliser cette base de données.\nVersion de la base de données: " + version;

                int compareValue = assembly.GetName().Version.CompareTo(new Version(version));
                if (compareValue < 0)
                {
                    MessageBox.Show(msg);
                    return(false);
                }

                if (compareValue > 0)
                {
                    if (!(Force || MessageBox.Show(msg + "\nVoulez-vous la mettre à jour?", "BDPPC", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes))
                    {
                        return(false);
                    }

                    // process de mise à jour à mettre ici

                    cmd.CommandText = "UPDATE OPTIONS SET Valeur = ? WHERE Nom_Option = 'Version'";
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@version", assembly.GetName().Version.ToString()));
                    cmd.ExecuteNonQuery();
                    if (!Force)
                    {
                        MessageBox.Show("Mise à jour terminée");
                    }
                }
            }
            return(true);
        }
Example #5
0
 public override void Fill(int Reference)
 {
     if (Reference == 0)
     {
         return;
     }
     using (new WaitCursor())
         using (IDbCommand cmd = BDPPCDatabase.getCommand())
         {
             cmd.CommandText = "SELECT REFEDITEUR, NOMEDITEUR, SITEWEB FROM EDITEURS WHERE REFEDITEUR = ?";
             cmd.Parameters.Add(BDPPCDatabase.getParameter("@refediteur", Reference));
             using (IDataReader result = cmd.ExecuteReader())
                 using (BaseDataReader dataReader = new BaseDataReader(result, this.GetType()))
                     if (result != null && result.Read())
                     {
                         dataReader.loadData(this);
                     }
         }
 }
Example #6
0
        public override void Fill(int Reference)
        {
            if (Reference == 0)
            {
                return;
            }
            using (new WaitCursor())
                using (IDbCommand cmd = BDPPCDatabase.getCommand())
                {
                    cmd.CommandText = "SELECT REFPERSONNE, NOMPERSONNE, SITEWEB, BIOGRAPHIE FROM PERSONNES WHERE REFPERSONNE = ?";
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@refpersonne", Reference));
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader dataReader = new BaseDataReader(result, this.GetType()))
                            if (result != null && result.Read())
                            {
                                dataReader.loadData(this);
                            }

                    // UpperTitreSerie en premier pour forcer l'union à trier sur le titre
                    cmd.CommandText  = "SELECT UPPERTITRESERIE, s.REFSERIE";
                    cmd.CommandText += " FROM ALBUMS al";
                    cmd.CommandText += "  INNER JOIN AUTEURS au ON al.refalbum = au.refalbum AND au.refpersonne = ?";
                    cmd.CommandText += "  INNER JOIN SERIES s ON s.refserie = al.refserie";
                    cmd.CommandText += " union ";
                    cmd.CommandText += "SELECT UPPERTITRESERIE, s.REFSERIE";
                    cmd.CommandText += " FROM auteurs_series au";
                    cmd.CommandText += "  INNER JOIN SERIES s ON s.refserie = au.refserie AND au.refpersonne = ?";
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@refpersonne1", Reference));
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@refpersonne2", Reference));
                    Series.Clear();
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader dataReader = new BaseDataReader(result, typeof(SerieComplet)))
                            if (result != null)
                            {
                                while (result.Read())
                                {
                                    Series.Add(new SerieCompletPPC(dataReader.GetInt(1), this.RefAuteur));
                                }
                            }
                }
        }
Example #7
0
        public static void Proc_Auteurs(ArrayList list, int RefAlbum, int RefSerie)
        {
            using (new WaitCursor())
                using (IDbCommand cmd = BDPPCDatabase.getCommand())
                {
                    if (RefAlbum != -1)
                    {
                        cmd.CommandText = "select p.refpersonne, p.nompersonne, a.refalbum, NULL as refserie, a.metier "
                                          + "from personnes p inner join auteurs a on a.refpersonne = p.refpersonne "
                                          + "where a.refalbum = ? "
                                          + "order by a.metier, p.uppernompersonne";
                        cmd.Parameters.Add(BDPPCDatabase.getParameter("@RefAlbum", RefAlbum));

                        using (IDataReader result = cmd.ExecuteReader())
                            using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Auteur)))
                                if (result != null)
                                {
                                    dataReader.fillList(list);
                                }
                    }

                    if (RefSerie != -1)
                    {
                        cmd.CommandText = "select p.refpersonne, p.nompersonne, NULL as refalbum, a.refserie, a.metier "
                                          + "from personnes p inner join auteurs_series a on a.refpersonne = p.refpersonne "
                                          + "where a.refserie = ? "
                                          + "order by a.metier, p.uppernompersonne";
                        cmd.Parameters.Add(BDPPCDatabase.getParameter("@RefSerie", RefSerie));

                        using (IDataReader result = cmd.ExecuteReader())
                            using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Auteur)))
                                if (result != null)
                                {
                                    dataReader.fillList(list);
                                }
                    }
                }
        }
Example #8
0
        public override void Fill(int Reference)
        {
            if (Reference == 0)
            {
                return;
            }
            using (new WaitCursor())
                using (IDbCommand cmd = BDPPCDatabase.getCommand())
                {
                    cmd.CommandText = "SELECT REFSERIE, TITRESERIE, TERMINEE, SUJETSERIE, REMARQUESSERIE, SITEWEB, S.REFEDITEUR, S.REFCOLLECTION, NOMCOLLECTION "
                                      + "FROM SERIES S LEFT JOIN COLLECTIONS C ON S.REFCOLLECTION = C.REFCOLLECTION "
                                      + "WHERE REFSERIE = ?";
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@refserie", Reference));
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader dataReader = new BaseDataReader(result, this.GetType()))
                            if (result != null && result.Read())
                            {
                                dataReader.loadData(this);
                                Terminee = dataReader.GetInt(2, -1);
                                Editeur.Fill();
                            }

                    cmd.CommandText = "SELECT REFALBUM, TITREALBUM, INTEGRALE, HORSSERIE, TOME, TOMEDEBUT, TOMEFIN, REFSERIE "
                                      + "FROM ALBUMS "
                                      + "WHERE REFSERIE = ? ";
                    if (FIdAuteur != -1)
                    {
                        cmd.CommandText += "AND REFALBUM IN (SELECT REFALBUM FROM AUTEURS WHERE REFPERSONNE = ?) ";
                    }
                    cmd.CommandText += "ORDER BY COALESCE(HORSSERIE, -1), COALESCE(INTEGRALE, -1), COALESCE(TOME, -1)";
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@RefSerie", Reference));
                    if (FIdAuteur != -1)
                    {
                        cmd.Parameters.Add(BDPPCDatabase.getParameter("@FIdAuteur", FIdAuteur));
                    }

                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader dataReader = new BaseDataReader(result, typeof(Album)))
                            if (result != null)
                            {
                                dataReader.fillList(Albums);
                            }

                    cmd.CommandText = "SELECT Genre "
                                      + "FROM GenreSeries s INNER JOIN Genres g ON g.RefGenre = s.RefGenre "
                                      + "WHERE RefSerie = ?";
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(BDPPCDatabase.getParameter("@RefSerie", Reference));
                    Genres.Clear();
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader dataReader = new BaseDataReader(result, null))
                            while (result.Read())
                            {
                                Genres.Add(dataReader.GetString(0, string.Empty));
                            }

                    ArrayList Auteurs = new ArrayList();
                    StoredProcedures.Proc_Auteurs(Auteurs, -1, Reference);
                    Scenaristes.Clear();
                    Dessinateurs.Clear();
                    Coloristes.Clear();
                    foreach (Auteur auteur in Auteurs)
                    {
                        switch (auteur.Metier)
                        {
                        case 0:
                        {
                            Scenaristes.Add(auteur);
                            break;
                        }

                        case 1:
                        {
                            Dessinateurs.Add(auteur);
                            break;
                        }

                        case 2:
                        {
                            Coloristes.Add(auteur);
                            break;
                        }
                        }
                    }
                }
        }