示例#1
0
        /// <summary>
        /// Créer une nouvelle bibliothèque
        /// </summary>
        /// <param name="selectedPath">Chemin de destination</param>
        private void Option_CreateNew(string _selectedPath, string _selectedName, bool _display)
        {
            Manuel manuel = new Manuel();

            if ((Directory.Exists(_selectedPath)))
            {
                if (!File.Exists(_selectedPath + "\\data.sqlite"))
                {
                    SQLiteConnection.CreateFile(_selectedPath + "\\data.sqlite");
                    Database = new ConnectSQLite(_selectedPath + "\\" + "data.sqlite");
                    Database.OuvrirBDD();
                    Database.Requete(File.ReadAllText("sqlite.sql"));
                    Database.FermerBDD();
                    if (_display)
                    {
                        MessageBox.Show("Bibliothèque créée", "Bibliothèque", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    SetCurrent(_selectedPath, _selectedName);
                    manuel.CopyManuelEpub(Database, _selectedPath);
                }
                else
                {
                    MessageBox.Show("Une bibliothèque existe déjà à cet emplacement", "Bibliothèque", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Le dossier " + _selectedPath + " n'existe pas.", "Bibliothèque", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        /// <summary>
        /// Redéfinie la base de donnée et l'emplacement actuel
        /// </summary>
        /// <param name="_path">Chemin de la bibliothèque</param>
        private void SetCurrent(string _path, string _name)
        {
            CurrentPath = _path;
            CurrentName = _name;
            XmlAttribute attr = doc.CreateAttribute("name");

            attr.Value = _name;
            doc.SelectSingleNode("Bibliotheque/CurrentBib").Attributes.Append(attr);
            doc.SelectSingleNode("Bibliotheque/CurrentBib").InnerText = _path;

            doc.Save("Config.xml");

            //Si le fichier base de donnée n'existe pas, database = null, sinon ouvre une connexion
            if (!File.Exists(_path + "\\data.sqlite"))
            {
                Database = null;
            }
            else
            {
                Database = new ConnectSQLite(_path + "\\data.sqlite");
                Database.OuvrirBDD();
                GetAllBooks();
            }
        }