private void CommentButton_Click(object sender, EventArgs e) { if (IsInternetAvailable()) { UserComment = new Comment(); UserComment.User_id = Global.user.User_id; UserComment.Book_id = currentBook.Book_id; UserComment.Content = WriteCommentBox.Text.ToString(); UserComment.Content = UserComment.Content.Replace("\\", "\\\\"); UserComment.Content = UserComment.Content.Replace("'", "\\'"); int commitSuccess = DatabaseUtility.setComment(ref UserComment); CommentsBox.Clear(); DatabaseUtility.getComments(ref bookComments, currentBook); for (int j = 0; j < bookComments.Count; j++) { Comment newCommentItem = (Comment)bookComments[j]; CommentsBox.AppendText(newCommentItem.User_name + "-------" + newCommentItem.Create_date.ToString() + "\r\n" + newCommentItem.Content.ToString() + "\r\n" + "\r\n"); } WriteCommentBox.Clear(); } else { MessageBox.Show("Please check your network"); } }
//private User user1; public Book_Interface(Book cbook, Form LastForm) { InitializeComponent(); lastWinform = LastForm; ContinueReadButton.Visible = false; currentBook = cbook; TotalChapNo = currentBook.Chapter_no; bookURL = string.Format(@"http://www.irran.top:8080/Yggdrasil/book/" + currentBook.Location + "/1.txt"); //Judge whether the network is available if (IsInternetAvailable()) { DatabaseUtility.checkFavorite(ref IsFavorite, Global.user, currentBook);//Check whether the book is user's favorite if (IsFavorite) { CollectButton.Text = "Remove from Collection"; } else { CollectButton.Text = "Add to My Collection"; } Image Cover = Image.FromStream(WebRequest.Create("http://www.irran.top:8080/Yggdrasil/book/" + currentBook.Location + "/cover.jpg").GetResponse().GetResponseStream()); pictureBox1.Image = Cover; BookNameLabel.Text = currentBook.Book_name; Summary.Text = currentBook.getInfo(); for (int i = 1; i <= currentBook.Chapter_no; i++) { ChapterBox.Items.Add(i); } DatabaseUtility.getComments(ref bookComments, currentBook); for (int j = 0; j < bookComments.Count; j++) { Comment newCommentItem = (Comment)bookComments[j]; CommentsBox.AppendText(newCommentItem.User_name + "-------" + newCommentItem.Create_date.ToString() + "\r\n" + newCommentItem.Content.ToString() + "\r\n" + "\r\n"); } } else { MessageBox.Show("Please check your network!"); } }