Example #1
0
        public void LoadChapters()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            bool shouldClose = false;

            // Is the database already open?
            if (conn.State != ConnectionState.Open)
            {
                shouldClose = true;
                conn.Open();
            }

            // Execute query
            using (var command = conn.CreateCommand())
            {
                // Create new command
                command.CommandText = "SELECT Id,Chapter,Reading FROM [tblChapters]";
                try
                {
                    //await DataStore.GetItemsAsync(true);
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ChapterRead item = new ChapterRead();
                            // Pull values back into class
                            item.Id      = Convert.ToString(reader[0]);
                            item.Chapter = Convert.ToString(reader[1]);
                            item.Reading = Convert.ToString(reader[2]);

                            ChapterItems.Add(item);
                        }
                    }
                }

                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    IsBusy = false;
                }
            }
            // Should we close the connection to the database
            if (shouldClose)
            {
                conn.Close();
            }
        }
Example #2
0
 public void FullLoad(string filename)
 {
     OpenDatbase(filename);
     LoadChapters();
     LoadIntros();
     LoadSummary();
     FilteredIntros    = IntroItems.ToList();
     FilteredSummaries = SummaryItems.ToList();
     FilteredChapters  = ChapterItems.ToList();
 }