//搜索框文本改变时,改变显示的建议
        private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            suggestions.Clear();
            ObservableCollection <string[]> books = BookDB.findBookFromStore(sender.Text);

            foreach (string[] book in books)
            {
                string      title        = (string)book[0];
                string      catalog      = (string)book[1];
                string      tags         = (string)book[2];
                string      info         = (string)book[3];
                string      image        = (string)book[4];
                string      bookId       = (string)book[5];
                string      author       = (string)book[6];
                string      compatibeMen = (string)book[7];
                string      nowChac      = (string)book[8];
                BookInStore item         = new BookInStore(title, catalog, tags, info, image,
                                                           bookId, author, compatibeMen, nowChac);
                suggestions.Add(item);
            }
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                sender.ItemsSource = suggestions;
            }
        }
Beispiel #2
0
        //第 0 個參數佔 30 字元(靠右); 第 1 個參數格式化為 #.##
        //{ System.Console.WriteLine("{0,30} = {1:#.##}", b.Title, b.Price); }
        //http://blog.csdn.net/xrongzhen/article/details/5477075

        // Execution starts here.
        static void Main()
        {
            BookDB bookDB = new BookDB(); //為命名空間 Bookstore 之類別 BookDB 建立實體

            // Initialize the database with some books:
            bookDB.AddBook("The C Programming Language", "Brian W.", 19.95m, true);
            bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true);
            System.Console.WriteLine("Paperback Book Titles:");

            // Create a new delegate object associated with the static
            // method PrintTitle: 指向靜態方法之委派
            bookDB.ProcessPaperbackBooks(PrintTitle); //書籍名稱 (逐本處理)

            // Get the average price of a paperback by using a PriceTotaller object:
            PriceTotaller totaller = new PriceTotaller(); //為類別 PriceTotaller 建立實體(價格加總)

            // Create a new delegate object associated with the nonstatic
            // method AddBookToTotal on the object totaller: 指向非靜態方法之委派
            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal); //書籍加總 (逐本處理)

            System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                                     totaller.AveragePrice());

            string nop = System.Console.ReadLine();
        }
Beispiel #3
0
        //用于初始化数据库,在项目最开始使用
        public async static void initTheDataBase()
        {
            string[] tag = { "小说同人", "动漫同人", "影视同人", "游戏同人", "耽美同人" };
            for (int i = 3; i < 5; i++)
            {
                for (int page = 0; page < 1; page++)
                {
                    string      Catalog      = "同人";
                    string      Tags         = tag[i];
                    string      compatibeMen = "female";
                    string      start        = (page * 50).ToString();
                    BooksObject myNewBook    = await GetNewBooks.GetNewBook("hot", Catalog, Tags, start, "15", compatibeMen);

                    for (int bookcount = 0; bookcount < 10; bookcount++)
                    {
                        string           bookid       = myNewBook.books[bookcount]._id;
                        BookDetailObject myBookDetail = await BookDetail.GetBookDetail(bookid);

                        ChapterObject myChapter = await Chapter.GetChapter(bookid);

                        //string link = myChapter.mixToc.chapters[0].link;
                        string Title   = myNewBook.books[bookcount].title;
                        string Info    = myNewBook.books[bookcount].shortIntro;
                        string Image   = "http://statics.zhuishushenqi.com" + myNewBook.books[bookcount].cover;
                        string author  = myNewBook.books[bookcount].author;
                        string nowChac = "1";
                        BookDB.addToBookStore(Title, Catalog, Tags, Info, Image,
                                              bookid, author, compatibeMen, nowChac);
                    }
                }
            }
        }
Beispiel #4
0
 private static void AddBooks(BookDB bookDB)
 {
     bookDB.AddBook("The C Programming Lanugage", "Brian W. Kernigham and Dennis M. Ritchie", 19.95m, true);
     bookDB.AddBook("Default book title 1", "Default author(s) 1", 22.95m, true);
     bookDB.AddBook("Default book title 2", "Default author(s) 2", 99.95m, false);
     bookDB.AddBook("Default book title 3", "Default author(s) 3", 35.95m, true);
 }
Beispiel #5
0
            // Execution starts here.
            static void Main()
            {
                BookDB bookDB = new BookDB();

                // Initialize the database with some books:
                AddBooks(bookDB);

                // Print all the titles of paperbacks:
                System.Console.WriteLine("Paperback Book Titles:");

                // Create a new delegate object associated with the static
                // method Test.PrintTitle:
                bookDB.ProcessPaperbackBooks(PrintTitle);
                //        bookDB.ProcessPaperbackBooks(Console.WriteLine);

                // Get the average price of a paperback by using
                // a PriceTotaller object:
                PriceTotaller totaller = new PriceTotaller();

                // Create a new delegate object associated with the nonstatic
                // method AddBookToTotal on the object totaller:
                ProcessBookDelegate myfunc = totaller.AddBookToTotal;

                myfunc += totaller.FindDistinctAuthors;

                bookDB.ProcessPaperbackBooks(myfunc);

                System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                                         totaller.AveragePrice());

                totaller.ShowAllAuthors();
            }
        static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();

            // Initialize the database with some books
            AddBooks(bookDB);

            // Print all the titles of paperbacks
            Console.WriteLine("Paperback Book Titles: ");

            // create a new delegate object associated with the static method Test.PrintTitle
            ProcessBookDelegate printTitleDelegate = PrintTitle;

            bookDB.ProcessPaperbackBooks(printTitleDelegate);

            // Get the average price of a paperback by usinf a Pricetotaller object:
            PriceTotaller totaller = new PriceTotaller();

            // Create a new delegate object associated with the nonstatic method AddBookToTotal on the object totaller
            ProcessBookDelegate totallerDelegate = totaller.AddBookToTotal;

            bookDB.ProcessPaperbackBooks(totallerDelegate);

            Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                              totaller.AveragePrice());
        }
Beispiel #7
0
        // Execution starts here.
        static void Main()
        {
            BookDB bookDB = new BookDB();

            // Initialize the database with some books:
            AddBooks(bookDB);

            // Print all the titles of paperbacks:
            Console.WriteLine("Paperback Book Titles:");

            // FIXME en hier is het nog eens!
            // Create a new delegate object associated with the static
            // method Test.PrintTitle:
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));

            // Get the average price of a paperback by using
            // a PriceTotaller object:
            PriceTotaller totaller = new PriceTotaller();

            // Create a new delegate object associated with the nonstatic
            // method AddBookToTotal on the object totaller:
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
            Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                              totaller.AveragePrice());
        }
Beispiel #8
0
 // Initialize the book database with some test books:
 static void AddBooks(BookDB bookDB)
 {
     bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true);
     bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true);
     bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false);
     bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true);
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);
            // Print all the titles of paperbacks:
            System.Console.WriteLine("Paperback Book Titles:");

            // Create a new delegate object associated with the static
            // method Test.PrintTitle:
            bookDB.ProcessPaperbackBooks(PrintTitle);

            // Get the average price of a paperback by using
            // a PriceTotaller object:
            PriceTotaller totaller = new PriceTotaller();

            // Create a new delegate object associated with the nonstatic
            // method AddBookToTotal on the object totaller:
            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal);

            System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                                     totaller.AveragePrice());

            System.Console.ReadLine();
        }
Beispiel #10
0
        // Execution starts here.
        static void Main()
        {
            BookDB bookDB = new BookDB();    //

            // Initialize the database with some books:
            AddBooks(bookDB);           //添加书的方法写在最下面

            // Print all the titles of paperbacks:
            System.Console.WriteLine("Paperback Book Titles:");

            //声明了委托类型后,必须创建委托对象并使之与特定方法关联。
            //通过按下面示例中的方式将 PrintTitle 方法传递到 ProcessPaperbackBooks 方法来实现这一点
            //ProcessPaperbackBooks以委托作为参数方便传入方法
            bookDB.ProcessPaperbackBooks(PrintTitle);   //注意这里只是方法引用赋值给委托,所以没有()

            PriceTotaller totaller = new PriceTotaller();

            //ProcessPaperbackBooks()的参数是委托类型的,传入的是totaller.AddBookToTotal方法
            //通过遍历将金额相加
            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal);

            System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                                     totaller.AveragePrice());
            Console.ReadKey();
        }
Beispiel #11
0
 public BookDetailsPage()
 {
     Title = "Book Details";
     InitializeComponent();
     Debug.WriteLine("Creating book details page");
     _bookdb = new BookDB();
 }
Beispiel #12
0
        static void Main()
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);
            Console.WriteLine("paperback book titles: ");

            Console.WriteLine("DELEGATE CALL 1");
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));//METODER SOM TAR EMOT BOK SOM INPARAMETER OCH RETURNERAR VOID

            PriceTotaller totaller = new PriceTotaller();

            Console.WriteLine("DELEGATE CALL 2");
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));//inserting pricetotaller object into delegate that only takes book? //METODER SOM TAR EMOT BOK SOM INPARAMETER OCH RETURNERAR VOID
            Console.WriteLine("Average paperback book price ${0:#.##}", totaller.AveragePrice());
            Console.ReadKey();


            //random test
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("_________________________");
            TextAdderToBook adder = new TextAdderToBook();

            bookDB.ProcessPaperbackBooks(adder.AddTextToBookTitle);
            Console.ResetColor();
        }
Beispiel #13
0
 static void AddBooks(BookDB bookDB)
 {
     //(string title, string author, decimal price, DateTime publish_date, string description, bool paperBack, string isbn10, string isbn13)
     bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, new DateTime(1988, 3, 22), "hoge", true, "0131103628", "978-0131103627");
     bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, new DateTime(2000, 10, 01), "fuga", true, "0131103628", "978-0131103627");
     bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, new DateTime(2000, 10, 01), "piyo", false, "0131103628", "978-0131103627");
     bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, new DateTime(2000, 10, 01), "piyopiyo", true, "0131103628", "978-0131103627");
 }
Beispiel #14
0
        public HttpResponseMessage Put(int id, [FromBody] Book value)
        {
            var foundValue = BookDB.Books.Find(value.Id);

            BookDB.Entry(foundValue).CurrentValues.SetValues(value);
            BookDB.Entry(foundValue).State = EntityState.Modified;
            return(ToJson(BookDB.SaveChanges()));
        }
Beispiel #15
0
        //添加到书架
        public void AddBookItem(string title)
        {
            BookInShelf item = new BookInShelf(title);

            this.shelfItems.Add(item);
            BookDB.addToBookShelf(item.Id, item.Title, item.Pages);
            UpdateTile();
        }
Beispiel #16
0
 //修改书架上书本已经阅读的页码
 public void changePages(string id, string Pages)
 {
     for (int i = 0; i < ShelfItems.Count; i++)
     {
         if (ShelfItems[i].Id == id)
         {
             ShelfItems[i].Pages = Pages;
         }
     }
     BookDB.changePages(id, Pages);
 }
Beispiel #17
0
 internal Book Map(BookDB dbBook)
 {
     if (dbBook == null)
     {
         return(null);
     }
     return(new Book()
     {
         Id = dbBook.Id, BookTitle = dbBook.BookTitle, ISBN = dbBook.ISBN
     });
 }
Beispiel #18
0
        static void Main0()
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);
            Console.WriteLine("Paperback Book Titles:");
            bookDB.ProcessPaperbackBooks(PrintTitle);
            PriceTotaller totaller = new PriceTotaller();

            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal);
            Console.WriteLine("Average Parperback Book Price:${0:#.##}", totaller.AveragePrice());
        }
Beispiel #19
0
 //从书架删除
 public void RemoveBookItem(string id)
 {
     for (int i = 0; i < ShelfItems.Count; i++)
     {
         if (ShelfItems[i].Id == id)
         {
             BookDB.removeFromBookShelf(ShelfItems[i].Id);
             shelfItems.Remove(ShelfItems[i]);
         }
     }
     UpdateTile();
 }
 private static void ValidateBook(Book book, BookDB bookDb)
 {
     Assert.Equal(book.AverageRating, bookDb.AverageRating);
     Assert.Equal(book.Description, bookDb.Description);
     Assert.Equal(book.Isbn, bookDb.Isbn);
     Assert.Equal(book.Language, bookDb.Language);
     Assert.Equal(book.MaturityRating, bookDb.MaturityRating);
     Assert.Equal(book.PageCount, bookDb.PageCount);
     Assert.Equal(book.PublishedDate, bookDb.PublishedDate);
     Assert.Equal(book.Publisher, bookDb.Publisher);
     Assert.Equal(book.Title, bookDb.Title);
 }
Beispiel #21
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string name  = txtName.Text;
            float  price = float.Parse(txtPrice.Text);
            BookDB db    = new BookDB();

            db.addNewBook(new Book()
            {
                BookName = name, BookPrice = price
            });
            this.Close();
        }
Beispiel #22
0
 private Book Map(BookDB bookDB)
 {
     if (bookDB == null)
     {
         return(null);
     }
     return(new Book()
     {
         Id = bookDB.Id,
         BookTitle = bookDB.BookTitle,
         ISBN = bookDB.ISBN
     });
 }
Beispiel #23
0
        public static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);
            Console.WriteLine("PaperBack Book Titles:");
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));
            PriceTotaller totaller = new PriceTotaller();

            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal);
            Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice());
            Console.ReadKey();
        }
Beispiel #24
0
        static void Main()
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);

            Console.WriteLine("Paperback book titles:");
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));

            PriceTotaller totaller = new PriceTotaller();

            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
            Console.WriteLine("Average Paperback book price: {0:#.##}", totaller.AveragePrice());
        }
Beispiel #25
0
        //从数据库初始化书架信息
        public void ImportDB()
        {
            shelfItems.Clear();
            ObservableCollection <string[]> books = BookDB.getBooksFromShelf();

            foreach (string[] book in books)
            {
                string      id    = book[0];
                string      title = book[1];
                string      pages = book[2];
                BookInShelf item  = new BookInShelf(id, title, pages);
                shelfItems.Add(item);
            }
        }
Beispiel #26
0
        public BookListPage(List <Book> books)
        {
            Title = "Book List";
            InitializeComponent();

            _database  = new BookDB();
            this.books = new ObservableCollection <Book>(books);
            if (this.books == null)
            {
                this.books = new ObservableCollection <Book>(_database.GetBooks().ToList());
            }
            // var books = _database.GetBooks();
            //if (SearchBookPage.seachpicker.text == "Book Title")
            //{
            // var books = _database.SearchBookByTitle("book");
            //}
            BookListView.ItemsSource = this.books;
        }
Beispiel #27
0
        // 下面开始执行。
        public static void ProcessBookMethods()
        {
            BookDB bookDB = new BookDB();

            // 用一些书初始化数据库:
            AddBooks(bookDB);

            // 打印所有平装本的书名:
            Console.WriteLine("Paperback Book Titles:");
            // 创建一个与静态方法 Test.PrintTitle 关联的
            // 新委托对象:

            Console.WriteLine("方法1 使用自定义委托类型");
            bookDB.ProcessPaperbackBooksDelegate(new ProcessBookDelegate(PrintTitle));//方法1 使用自定义委托类型

            Console.WriteLine("方法2 使用内置委托类型");
            bookDB.ProcessPaperbackBooksAction(new Action <Book>(PrintTitle));//方法2 使用内置委托类型

            Console.WriteLine("方法3 使用Lambda");
            bookDB.ProcessPaperbackBooksAction(b => Console.WriteLine("   {0}", b.Title));//方法3 使用Lambda

            // 使用 PriceTotaller 对象
            // 获取平装本的平均价格:
            PriceTotaller totaller = new PriceTotaller();

            // 创建一个与对象 totaller 的非静态方法
            // AddBookToTotal 关联的新委托对象:

            Console.WriteLine("方法1 使用自定义委托类型");
            bookDB.ProcessPaperbackBooksDelegate(new ProcessBookDelegate(totaller.AddBookToTotal));//方法1 使用自定义委托类型

            Console.WriteLine("方法2 使用内置委托类型");
            bookDB.ProcessPaperbackBooksAction(new Action <Book>(totaller.AddBookToTotal));//方法2 使用内置委托类型

            Console.WriteLine("方法3 使用Lambda");
            bookDB.ProcessPaperbackBooksAction(new Action <Book>(b => totaller.AddBookToTotal(b)));//方法3 使用Lambda

            Console.WriteLine("Paperback Book TotalPrice: ${0:#.##}", totaller.TotalPrice());
            Console.WriteLine("Paperback Book TotalCount: ${0:#.##}", totaller.TotalCount());
            Console.WriteLine("Paperback Book Average Price: ${0:#.##}", totaller.AveragePrice());
        }
        //搜索时切换ViewModel内容
        public void ChangeViewModel(string input)
        {
            storeItems.Clear();
            ObservableCollection <string[]> books = BookDB.findBookFromStore(input);

            foreach (string[] book in books)
            {
                string      title        = (string)book[0];
                string      catalog      = (string)book[1];
                string      tags         = (string)book[2];
                string      info         = (string)book[3];
                string      image        = (string)book[4];
                string      bookId       = (string)book[5];
                string      author       = (string)book[6];
                string      compatibeMen = (string)book[7];
                string      nowChac      = (string)book[8];
                BookInStore item         = new BookInStore(title, catalog, tags, info, image,
                                                           bookId, author, compatibeMen, nowChac);
                storeItems.Add(item);
            }
        }
        public BookManagementTests()
        {
            var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent;
            var dbDir         = string.Empty;

            if (directoryInfo != null)
            {
                dbDir = Path.Combine(directoryInfo.FullName, "test.db");

                if (File.Exists(dbDir))
                {
                    File.Delete(dbDir);
                }
            }

            _dbManager = new DBManager(dbDir);

            _dummyAuthor = new Author
            {
                ID   = Guid.NewGuid(),
                Name = "DummyAuthor"
            };

            _dummyBookDB = new BookDB
            {
                Authors = new List <Guid> {
                    _dummyAuthor.ID
                },
                AverageRating  = 10,
                Description    = "TestBook",
                ID             = Guid.NewGuid(),
                Isbn           = "xxxxxxxxxxxxx",
                Language       = "en",
                MaturityRating = "MA",
                PageCount      = 10,
                PublishedDate  = DateTime.Parse("11/06/1987"),
                Publisher      = "BookManagement_Should_Add_Book_To_DB Developer",
                Title          = "BookManagement_Should_Add_Book_To_DB Book"
            };
        }
Beispiel #30
0
        // 下面开始执行。
        static void Main()
        {
            BookDB bookDB = new BookDB();

            // 用一些书初始化数据库:
            AddBooks(bookDB);

            // 打印所有平装本的书名:
            Console.WriteLine("Paperback Book Titles:");
            // 创建一个与静态方法 Test.PrintTitle 关联的
            // 新委托对象:
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));

            // 使用 PriceTotaller 对象
            // 获取平装本的平均价格:
            PriceTotaller totaller = new PriceTotaller();

            // 创建一个与对象 totaller 的非静态方法
            // AddBookToTotal 关联的新委托对象:
            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
            Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                              totaller.AveragePrice());
        }
Beispiel #31
0
 //protected static TaskRepository me;
 public BookRepository(SQLiteConnection conn, string dbLocation)
 {
     db = new BookDB(conn, dbLocation);
 }