コード例 #1
0
        /// <summary>
        /// Загрузка авторов из БД
        /// </summary>
        /// <returns></returns>
        public AuthorList LoadAuthors()
        {
            if (ds != null)
            {
                ds.Dispose();
            }
            ds = new DataSet();
            AuthorList list = new AuthorList();

            using (SQLiteCommand mycommand = new SQLiteCommand(conn))
            {
                mycommand.CommandText = "select * from authors";
                da = new SQLiteDataAdapter();
                da.SelectCommand = mycommand;
                System.Data.SQLite.SQLiteCommandBuilder cb = new System.Data.SQLite.SQLiteCommandBuilder(da);
                da.Fill(ds, "authors");
                foreach (DataRow row in ds.Tables["authors"].Rows)
                {
                    var author = Xml2Author(row["author_xml"].ToString());
                    if (author != null)
                    {
                        author.Changed = false;
                        list.Add(author);
                    }
                }
            }
            return(list);
        }
コード例 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AuthorList.Add(DefaultAuthor);
            UseAuthor.IsChecked = true;

            KeywordTextBox.Text  = this.Keyword;
            UseKeyword.IsChecked = true;
        }
コード例 #3
0
        public static void AddAuthor(Author author)
        {
            author.Id = AuthorList.Max(a => a.Id) + 1;
            AuthorList.Add(author);

            foreach (var book in author.Books)
            {
                AddBookForAuthor(author.Id, book);
            }
        }
コード例 #4
0
 private void OkButton_Click(object sender, RoutedEventArgs e)
 {
     if ((UseKeyword.IsChecked ?? false) || (UseAuthor.IsChecked ?? false))
     {
         this.Keyword = string.IsNullOrWhiteSpace(KeywordTextBox.Text) ? "*" : KeywordTextBox.Text;
         if (AuthorList.Count == 0)
         {
             AuthorList.Add("*");
         }
         this.DialogResult = true;
     }
 }
コード例 #5
0
 private void AddAuthor(Author author)
 {
     AuthorList.Add(author);
 }
コード例 #6
0
        /// <summary>
        /// Загрузка авторов из БД
        /// </summary>
        /// <returns></returns>
        public AuthorList LoadAuthors()
        {
            var list = new AuthorList();
            if (server == null) return null;

            try
            {
                var task = Task.Factory.StartNew(
                    () =>
                        {
                            using (var documentStore = server.OpenClient())
                            {
                                var authors =
                                    documentStore.Query<AuthorDb4o>(
                                    x => x != null && !x.author.IsDeleted);
                                foreach (var author in authors)
                                {
                                    author.author.Changed = false;
                                    list.Add(author.author);
                                }

                            }
                        });
            task.Wait();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка выборки данных из БД." + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return list;
        }
コード例 #7
0
 /// <summary>
 /// Загрузка авторов из БД
 /// </summary>
 /// <returns></returns>
 public AuthorList LoadAuthors()
 {
     if (ds != null) ds.Dispose();
     ds = new DataSet();
     AuthorList list = new AuthorList();
     using (SQLiteCommand mycommand = new SQLiteCommand(conn))
     {
         mycommand.CommandText = "select * from authors";
         da = new SQLiteDataAdapter();
         da.SelectCommand = mycommand;
         System.Data.SQLite.SQLiteCommandBuilder cb = new System.Data.SQLite.SQLiteCommandBuilder(da);
         da.Fill(ds, "authors");
         foreach (DataRow row in ds.Tables["authors"].Rows)
         {
             var author = Xml2Author(row["author_xml"].ToString());
             if (author != null)
             {
                 author.Changed = false;
                 list.Add(author);
             }
         }
     }
     return list;
 }