private void button3_Click(object sender, EventArgs e) { Comment cmt = new Comment { Content = textBox1.Text, Uid = Database.User.Uid }; cmtList.Add(cmt); cmt c = new cmt(); c.hienthi(cmt); flowLayoutPanel2.Controls.Add(c); textBox1.Text = ""; textBox1.ForeColor = System.Drawing.SystemColors.InfoText; currentBook.Comment = cmtList; Database.Edit(currentBook); }
private void LoadCurrentBookInfo() { labelName.Text = currentBook.Name; labelAuthor.Text = "bởi " + currentBook.Author; labelDesc.Text = currentBook.Description; foreach (var item in currentBook.Tags) { Label tag = new Label(); tag.Text = item; tag.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular); tag.AutoSize = true; flowLayoutPanel1.Controls.Add(tag); tag.Show(); } cmtList = currentBook.Comment; foreach (var item in currentBook.Comment) { cmt c = new cmt(); c.hienthi(item); flowLayoutPanel2.Controls.Add(c); } Picture pic = currentBook.GetPicture(); if (pic.GetImage() != null) { picture.Image = pic.GetImage(); } else { ; // TODO: use default picture } #region Action based on bookList. // Action is Remove if book is in booklist // Action is Add if book is not in booklist List <string> bookList = Database.User.BookListID; if (bookList.Contains(currentBook.Name)) { button1.Text = "Xóa"; onButton1Click = (obj, arg) => { Database.User.RemoveFromBookList(currentBook); button1_Click(currentBook, arg);; }; button1.Click += onButton1Click; button1.BackColor = Color.Crimson; } else { button1.Text = "Thêm"; onButton2Click = (obj, arg) => { Database.User.AddToBookList(currentBook); button1_Click(currentBook, arg); }; button1.Click += onButton2Click; button1.BackColor = Color.RoyalBlue; } #endregion #region Like / Dislike initial type if (Database.User.LikeListID.Contains(currentBook.Name)) { this.pictureBox2.Image = Properties.Resources.Like; } else { this.pictureBox2.Image = Properties.Resources.Like_disabled_; } if (Database.User.DislikeListID.Contains(currentBook.Name)) { this.pictureBox1.Image = Properties.Resources.Dislike; } else { this.pictureBox1.Image = Properties.Resources.Dislike_disabled_; } #endregion }