private void SelectABook(Object sender, SelectionChangedEventArgs e)
        {
            var          books = (LongListSelector)sender;
            BookListItem book  = books.SelectedItem as BookListItem;

            NavigationService.Navigate(new Uri("/ReadingRecordPage.xaml?BookISBN=" + book.ISBN, UriKind.Relative));
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.TryGetValue("BookISBN", out ISBN))
            {
                dbPath = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "jadeface.sqlite"));
                dbConn = new SQLiteConnection(dbPath);
                SQLiteCommand command = dbConn.CreateCommand("select * from booklistitem where isbn = '" + ISBN + "'");
                List<BookListItem> books = command.ExecuteQuery<BookListItem>();
                if (books.Count == 1)
                {
                    book = books.First();
                    //BookDetailGrid.DataContext = book;
                }

            }
            else
            {
                MessageBox.Show("详细信息页面加载出错!");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }

            bookService = BookService.getInstance();
            showNoteList();
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string ISBN = "";

            if (NavigationContext.QueryString.TryGetValue("BookISBN", out ISBN))
            {
                currentISBN = ISBN;
                dbPath = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "jadeface.sqlite"));
                dbConn = new SQLiteConnection(dbPath);
                SQLiteCommand command = dbConn.CreateCommand("select * from booklistitem where isbn = '" + ISBN + "'");
                List<BookListItem> books = command.ExecuteQuery<BookListItem>();
                if (books.Count == 1)
                {
                    book = books.First();
                    BookInformationGrid.DataContext = book;

                    StartPage.Text = "";
                    EndPage.Text = "";
                    ReadingRecordPanel.DataContext = record;
                }
                Debug.WriteLine("[DEBUG]Navigate to ReadingRecordPage...");
                bookService = BookService.getInstance();
                RefreshReadingRecord();
            }
            else
            {
                MessageBox.Show("读书记录页面加载出错!");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
Beispiel #4
0
        public static List <BookListItem> parse(string content)
        {
            List <BookListItem> books = new List <BookListItem>();
            BookListItem        book;
            JObject             json = JObject.Parse(content);

            for (int i = 0; i < 5; i++)
            {
                int   PageNo;
                float Marking;
                book        = new BookListItem();
                book.Title  = (string)json["books"][i]["title"];
                book.ISBN   = (string)json["books"][i]["isbn10"];
                book.Author = (string)(json["books"][i]["author"].First);
                float.TryParse((string)json["books"][i]["rating"]["average"], out Marking);
                book.Marking = Marking;
                int.TryParse((string)json["books"][i]["pages"], out PageNo);
                book.PageNo       = PageNo;
                book.HaveReadPage = 0;
                book.Publisher    = (string)json["books"][i]["publisher"];
                book.Image        = (string)json["books"][i]["images"]["small"];
                book.Summary      = (string)json["books"][i]["summary"];
                books.Add(book);
            }
            return(books);
        }
 public static List<BookListItem> parse(string content)
 {
     List<BookListItem> books = new List<BookListItem>();
     BookListItem book;
     JObject json = JObject.Parse(content);
     for (int i = 0; i < 5; i++)
     {
         int PageNo;
         float Marking;
         book = new BookListItem();
         book.Title = (string)json["books"][i]["title"];
         book.ISBN = (string)json["books"][i]["isbn10"];
         book.Author = (string)(json["books"][i]["author"].First);
         float.TryParse((string)json["books"][i]["rating"]["average"], out Marking);
         book.Marking = Marking;
         int.TryParse((string)json["books"][i]["pages"], out PageNo);
         book.PageNo = PageNo;
         book.HaveReadPage = 0;
         book.Publisher = (string)json["books"][i]["publisher"];
         book.Image = (string)json["books"][i]["images"]["small"];
         book.Summary = (string)json["books"][i]["summary"];
         books.Add(book);
     }
     return books;
 }
        private void BookDetail_Click(object sender, RoutedEventArgs e)
        {
            Button       b    = (Button)sender;
            BookListItem book = b.DataContext as BookListItem;

            NavigationService.Navigate(new Uri("/BookDetailPage.xaml?BookISBN=" + book.ISBN, UriKind.Relative));
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string ISBN = "";

            if (NavigationContext.QueryString.TryGetValue("BookISBN", out ISBN))
            {
                currentISBN = ISBN;
                dbPath      = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "jadeface.sqlite"));
                dbConn      = new SQLiteConnection(dbPath);
                SQLiteCommand       command = dbConn.CreateCommand("select * from booklistitem where isbn = '" + ISBN + "'");
                List <BookListItem> books   = command.ExecuteQuery <BookListItem>();
                if (books.Count == 1)
                {
                    book = books.First();
                    BookInformationGrid.DataContext = book;

                    StartPage.Text = "";
                    EndPage.Text   = "";
                    ReadingRecordPanel.DataContext = record;
                }
                Debug.WriteLine("[DEBUG]Navigate to ReadingRecordPage...");
                bookService = BookService.getInstance();
                RefreshReadingRecord();
            }
            else
            {
                MessageBox.Show("读书记录页面加载出错!");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.TryGetValue("BookISBN", out ISBN))
            {
                dbPath = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "jadeface.sqlite"));
                dbConn = new SQLiteConnection(dbPath);
                SQLiteCommand       command = dbConn.CreateCommand("select * from booklistitem where isbn = '" + ISBN + "'");
                List <BookListItem> books   = command.ExecuteQuery <BookListItem>();
                if (books.Count == 1)
                {
                    book = books.First();
                    //BookDetailGrid.DataContext = book;
                }
            }
            else
            {
                MessageBox.Show("详细信息页面加载出错!");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }

            bookService = BookService.getInstance();
            showNoteList();
        }
        public void BookServiceDeleteBoundaryTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret2 = service.delete(book, "");       //边界测试3,删除,username为空
            Assert.IsTrue(ret2 == false);
        }
        public void BookServiceInsertBoundaryTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret = service.insert(book);            //边界测试1,插入,Book内容为空
            Assert.IsTrue(ret == false);
        }
        public void BookServiceUpdateBoundaryTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret3 = service.update(book);           //边界测试4,更新,Book内容为空
            Assert.IsTrue(ret3 == false);
        }
Beispiel #12
0
        public void BookServiceInsertBoundaryTest()                    //BookService边界测试
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret = service.insert(book);            //边界测试1,插入,Book内容为空

            Assert.IsTrue(ret == false);
        }
        public void BookListItemTest()
        {
            BookListItem item = new BookListItem();

            item.Author = "test";
            Assert.IsTrue(item.Author.Equals("test"));

            item.CurPageNo = 100;
            Assert.IsTrue(item.CurPageNo == 100);
        }
        public void BookServiceSearchBoundaryTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据
            List<BookListItem> list;

            list = service.searchByISBN(book.ISBN, "");
            Assert.IsTrue(list == null);                //边界测试2,查询,username为空
        }
Beispiel #15
0
        public void BookServiceUpdateBoundaryTest()                    //BookService边界测试
        {
            BookService service = BookService.getInstance();

            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret3 = service.update(book);           //边界测试4,更新,Book内容为空

            Assert.IsTrue(ret3 == false);
        }
        private void FinishRead_Click(object sender, RoutedEventArgs e)
        {
            BookListItem book = readingProgressBar.DataContext as BookListItem;

            book.HaveReadPage = book.PageNo;
            book.Status       = BookStatus.FINISHED;
            bookService.update(book);
            MessageBox.Show("又读完了一本书!");
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
Beispiel #17
0
 public bool delete(BookListItem book, string username)
 {
     if (username.Equals("") || username == null)
     {
         return false;
     }
     Debug.WriteLine("delete from booklistitem where isbn = " + book.ISBN + " and userid = '" + username + "'");
     SQLiteCommand command = dbConn.CreateCommand("delete from booklistitem where isbn = " + book.ISBN + " and userid = '" + username + "'");
     command.ExecuteQuery<BookListItem>();
     return true;
 }
Beispiel #18
0
        public void BookServiceDeleteBoundaryTest()                    //BookService边界测试
        {
            BookService service = BookService.getInstance();


            BookListItem book = new BookListItem();     //边界测试需要的数据

            bool ret2 = service.delete(book, "");       //边界测试3,删除,username为空

            Assert.IsTrue(ret2 == false);
        }
Beispiel #19
0
        public void BookServiceSearchBoundaryTest()                    //BookService边界测试
        {
            BookService service = BookService.getInstance();


            BookListItem        book = new BookListItem(); //边界测试需要的数据
            List <BookListItem> list;

            list = service.searchByISBN(book.ISBN, "");
            Assert.IsTrue(list == null);                //边界测试2,查询,username为空
        }
Beispiel #20
0
        public bool delete(BookListItem book, string username)
        {
            if (username.Equals("") || username == null)
            {
                return(false);
            }
            Debug.WriteLine("delete from booklistitem where isbn = " + book.ISBN + " and userid = '" + username + "'");
            SQLiteCommand command = dbConn.CreateCommand("delete from booklistitem where isbn = " + book.ISBN + " and userid = '" + username + "'");

            command.ExecuteQuery <BookListItem>();
            return(true);
        }
        private void FinishRead_Click(object sender, RoutedEventArgs e)
        {
            Button       b    = (Button)sender;
            BookListItem book = b.DataContext as BookListItem;

            book.HaveReadPage = book.PageNo;
            book.Status       = BookStatus.FINISHED;
            bookService.update(book);
            MessageBox.Show("又读完了一本书!");
            RefreshWishBookList();

            //RefreshFinishBookList();
        }
 private void BookListItem_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("确认从书单中删除?", "确认", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
     {
         Button       tb   = (Button)sender;
         BookListItem book = tb.DataContext as BookListItem;
         BookListItems.ItemsSource.Remove(book);
         DeleteBookListItem(book);
         //booksTable.DeleteAsync(book);
         MessageBox.Show("删除完毕!");
         RefreshBookList();
     }
 }
Beispiel #23
0
        public bool update(BookListItem book)
        {
            if (book.UserId == null || book.Title == null || book.ISBN == null || book.UserId.Equals("") || book.Title.Equals("") || book.ISBN.Equals(""))
            {
                return(false);
            }

            if (dbConn.Update(book) > 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #24
0
        public void BookServiceUpdateFuncTest()               //BookService功能测试
        {
            BookService         service = BookService.getInstance();
            List <BookListItem> list;

            list = service.searchByISBN("10010", "TestUser");    //正常测试需要的数据
            BookListItem book2 = list[0];

            book2.Author = "TestAuthorx";

            bool ret5 = service.update(book2);                   //正常测试3,更新

            Assert.IsTrue(ret5 == true);
        }
        private void SelectAWishBook(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var          books = (LongListSelector)sender;
            BookListItem book  = books.SelectedItem as BookListItem;

            if (book == null)
            {
                return;
            }

            (sender as LongListSelector).SelectedItem = null;

            NavigationService.Navigate(new Uri("/BookDetailPage.xaml?BookISBN=" + book.ISBN, UriKind.Relative));
        }
        private void SelectABook(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var          books = (LongListSelector)sender;
            BookListItem book  = books.SelectedItem as BookListItem;

            if (book == null)
            {
                return;
            }

            (sender as LongListSelector).SelectedItem = null;

            Debug.WriteLine("[DEBUG]ISBN is " + book.ISBN);
            NavigationService.Navigate(new Uri("/ReadingRecordPage.xaml?BookISBN=" + book.ISBN, UriKind.Relative));
        }
        private void Reading_Click(object sender, RoutedEventArgs e)
        {
            Button       b    = (Button)sender;
            BookListItem book = b.DataContext as BookListItem;

            book.Status = BookStatus.READING;
            bookService.update(book);
            MessageBox.Show("已经将本书添加到正在阅读的列表中!");

            //RefreshWishBookList();


            RefreshWishBookList();
            //RefreshFinishBookList();
        }
        public void BookServiceInsertFuncTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book2 = new BookListItem();    //正常测试需要的数据
            book2.UserId = "TestUser";
            book2.Title = "TestBook";
            book2.PageNo = 100;
            book2.CurPageNo = 0;
            book2.Id = 0;
            book2.Publisher = "TestPublisher";
            book2.Author = "TestAuthor";
            book2.ISBN = "10010";

            bool ret4 = service.insert(book2);                   //正常测试1,插入
            Assert.IsTrue(ret4 == true);
        }
        public void BookServiceDeleteFuncTest()
        {
            BookService service = BookService.getInstance();

            BookListItem book2 = new BookListItem();    //正常测试需要的数据
            book2.UserId = "TestUser";
            book2.Title = "TestBook";
            book2.PageNo = 100;
            book2.CurPageNo = 0;
            book2.Id = 0;
            book2.Publisher = "TestPublisher";
            book2.Author = "TestAuthor";
            book2.ISBN = "10010";

            bool ret6 = service.delete(book2, "TestUser");       //正常测试4,删除
            Assert.IsTrue(ret6 == true);
        }
        private void BookRatingSave(object sender, RoutedEventArgs e)
        {
            Button       bt   = (Button)sender;
            BookListItem book = bt.DataContext as BookListItem;

            //book.Rating = ;
            Debug.WriteLine("[DEBUG]Rating is " + book.Rating);
            bookService.update(book);
            MessageBox.Show("本书的评分已经更新。");


            //RefreshWishBookList();


            RefreshBookList();
            //RefreshFinishBookList();
        }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            //获取选中的menuItem对象
            MenuItem menuItem = (MenuItem)sender;
            //获取对象的标题头的内容
            string header = (sender as MenuItem).Header.ToString();
            //获取选中的LonglistSelectorItem
            //BookListItem book = this.BookListItems.SelectedItem as BookListItem;
            BookListItem book = (BookListItem)menuItem.DataContext;

            //如果没有选中则返回
            if (book == null)
            {
                return;
            }
            Debug.WriteLine("[DEBUG]Book is : " + book.Title);
            Debug.WriteLine("[DEBUG]Book Status is : " + book.Status);

            if (menuItem.Header.ToString() == "以后再读吧")
            {
                book.Status = BookStatus.WISH;
                Debug.WriteLine("[DEBUG]Book Status is : " + book.Status);
                bookService.update(book);
                RefreshBookList();
            }
            else if (menuItem.Header.ToString() == "已经默默地读完了")
            {
                book.Status = BookStatus.FINISHED;
                bookService.update(book);
                RefreshBookList();
            }
            else if (menuItem.Header.ToString() == "删除")
            {
                //只删除书籍信息,不删除书籍相关的记录等
                bookService.delete(book, phoneAppServeice.State["username"].ToString());
                RefreshBookList();
            }
        }
Beispiel #32
0
        public bool update(BookListItem book)
        {
            if (book.UserId == null || book.Title == null || book.ISBN == null || book.UserId.Equals("") || book.Title.Equals("") || book.ISBN.Equals(""))
            {
                return false;
            }

            if (dbConn.Update(book) > 0)
            {
                return true;
            }

            return false;
        }
        private void SearchItemClick(object sender, RoutedEventArgs e)
        {
            CustomMessageBox box = new CustomMessageBox();

            box.Title = "添加到...";

            RadioButton rb1 = new RadioButton();

            rb1.Content = "想读的书";
            RadioButton rb2 = new RadioButton();

            rb2.Content = "在读的书";
            RadioButton rb3 = new RadioButton();

            rb3.Content = "读完的书";
            StackPanel rbl = new StackPanel();

            rbl.Children.Add(rb1);
            rbl.Children.Add(rb2);
            rbl.Children.Add(rb3);
            box.Content = rbl;

            box.LeftButtonContent  = "确定";
            box.RightButtonContent = "取消";

            box.Show();

            box.Dismissed += (s1, e1) =>
            {
                Button       tb   = (Button)sender;
                BookListItem book = tb.DataContext as BookListItem;
                book.UserId = phoneAppServeice.State["username"].ToString();
                book.Rating = 3;
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:
                    if ((bool)rb1.IsChecked)
                    {
                        Debug.WriteLine("[DEBUG]A Wish Book Added.");
                        book.Status = BookStatus.WISH;
                    }
                    if ((bool)rb2.IsChecked)
                    {
                        Debug.WriteLine("[DEBUG]A Reading Book Added.");
                        book.Status = BookStatus.READING;
                    }
                    if ((bool)rb3.IsChecked)
                    {
                        Debug.WriteLine("[DEBUG]A Finish Book Added.");
                        book.HaveReadPage = book.PageNo;
                        book.Status       = BookStatus.FINISHED;
                    }
                    List <BookListItem> items = bookService.searchByISBN(book.ISBN, phoneAppServeice.State["username"].ToString());

                    if (items.Count == 0)
                    {
                        bookService.insert(book);
                        //InsertBookListItem(book);
                        //RefreshWishBookList();

                        //新增
                        RefreshReadingPlanItems();

                        RefreshBookList();
                        //RefreshFinishBookList();
                    }
                    else
                    {
                        MessageBox.Show("你已经添加过这本书,无需再次添加!");
                        return;
                    }
                    MessageBox.Show("添加完毕!");
                    break;

                case CustomMessageBoxResult.RightButton:
                    break;

                case CustomMessageBoxResult.None:
                    break;

                default:
                    break;
                }
            };
        }
        public void BookServiceSearchFuncTest()
        {
            BookService service = BookService.getInstance();

            List<BookListItem> list;

            BookListItem book2 = new BookListItem();    //正常测试需要的数据
            book2.UserId = "TestUser";
            book2.Title = "TestBook";
            book2.PageNo = 100;
            book2.CurPageNo = 0;
            book2.Id = 0;
            book2.Publisher = "TestPublisher";
            book2.Author = "TestAuthor";
            book2.ISBN = "10010";

            list = service.searchByISBN(book2.ISBN, "TestUser");
            Assert.IsTrue(list.Count == 1);                      //正常测试2,查询
        }
 private void DeleteBookListItem(BookListItem book)
 {
     bookService.delete(book, phoneAppServeice.State["username"].ToString());
 }
 private void DeleteBookListItem(BookListItem book)
 {
     bookService.delete(book, phoneAppServeice.State["username"].ToString());
 }