コード例 #1
0
 public void FullLoad(string filename)
 {
     OpenDatbase(filename);
     LoadChapters();
     LoadIntros();
     LoadSummary();
     FilteredIntros    = IntroItems.ToList();
     FilteredSummaries = SummaryItems.ToList();
     FilteredChapters  = ChapterItems.ToList();
 }
コード例 #2
0
        /////load Intros
        public void LoadIntros()
        {
            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,Para FROM [tblIntroduction]";
                try
                {
                    //await DataStore.GetItemsAsync(true);
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            IntroRead item = new IntroRead();
                            // Pull values back into class
                            item.Id   = Convert.ToString(reader[0]);
                            item.Para = Convert.ToString(reader[1]);

                            IntroItems.Add(item);
                        }
                    }
                }

                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    IsBusy = false;
                }
            }
            // Should we close the connection to the database
            if (shouldClose)
            {
                conn.Close();
            }
        }