/// <summary>
        /// Method is executed to save a solutions content into the filesystem
        /// (Save As dialog should be called before this function if required
        /// This method executes after a user approved a dialog to Save in this
        /// location with this name).
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="solutionRoot"></param>
        /// <returns></returns>
        private bool SaveSolutionFile(string sourcePath
                                      , ISolutionModel solutionRoot)
        {
            SolutionModelsLib.SQLite.SolutionDB db = new SolutionModelsLib.SQLite.SolutionDB();
            db.SetFileNameAndPath(sourcePath);

            Console.WriteLine("1) Writting data into SQLite file: '{0}'", db.DBFileNamePath);
            int recordCount   = 0;
            int itemTypeCount = 0;

            try
            {
                // Overwrites the existing file (if any)
                db.OpenConnection(true);

                if (db.ConnectionState == false)
                {
                    Console.WriteLine("ERROR: Cannot open Database connectiton.\n" + db.Status);
                    return(false);
                }

                db.ReCreateDBTables(db);

                // Write itemtype enumeration into file
                var names  = Enum.GetNames(typeof(SolutionModelsLib.Enums.SolutionModelItemType));
                var values = Enum.GetValues(typeof(SolutionModelsLib.Enums.SolutionModelItemType));
                itemTypeCount = db.InsertItemTypeEnumeration(names, values);

                // Write solution tree data file
                recordCount = db.InsertSolutionData(solutionRoot);
            }
            catch (Exception exp)
            {
                Console.WriteLine("\n\nAN ERROR OCURRED: " + exp.Message + "\n");
            }
            finally
            {
                db.CloseConnection();
            }

            Console.WriteLine("{0:000} records written to itemtype enumeration table...", itemTypeCount);
            Console.WriteLine("{0:000} records written to solution data table...", recordCount);

            return(true);
        }
        /// <summary>
        /// Method is executed to load a solutions content from the filesystem
        /// (Open file dialog should be called before this function if required).
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        private ISolutionModel LoadSolutionFile(string sourcePath, out int recordCount)
        {
            recordCount = 0;
            ISolutionModel solutionRoot = null;

            var db = new SolutionModelsLib.SQLite.SolutionDB();

            try
            {
                db.SetFileNameAndPath(sourcePath);

                db.OpenConnection();

                if (db.ConnectionState == false)
                {
                    MessageBox.Show("ERROR: Cannot open Database connectiton.\n" + db.Status);
                    return(null);
                }

                solutionRoot = SolutionModelsLib.Factory.CreateSolutionModel();  // Select Result from Database

                var  mapKeyToItem = db.ReadItemTypeEnum();
                bool checkResult  = CompareItemTypeEnums(mapKeyToItem);

                if (checkResult == false)
                {
                    MessageBox.Show("ERROR: Cannot open file: itemtype enumeration is not consistent.");
                    return(null);
                }

                recordCount = db.ReadSolutionData(solutionRoot, db);
            }
            catch (Exception exp)
            {
                MessageBox.Show("\n\nAN ERROR OCURRED: " + exp.Message + "\n");
            }
            finally
            {
                db.CloseConnection();
            }

            return(solutionRoot);
        }