public void loadBook(Book book) { lbAuthor.Text = book.Author; Genre gen = BookManage.getGenreById(book.GenId); Categorie cat = BookManage.getCategorieById(gen.CatId); lbCatgroie.Text = cat.Title; lbGenre.Text = gen.Title; txtDesc.Text = book.Desc; lbIsbn.Text = book.Isbn; lbName.Text = book.Name; lbPrice.Text = book.Price.ToString(); lbPub.Text = BookManage.getPublisherById(book.PubId).Name; lbPubDate.Text = book.PubDate.ToString(); lbStatue.Text = book.Statue == 1 ? "否" : "是"; lbStock.Text = book.Stock.ToString(); string imgAddr = string.Format(baseAddr + "{0}/{1}.jpg", cat.Id, book.Isbn); try { FileStream fs = File.Open(imgAddr, FileMode.Open, FileAccess.Read); pbCover.Image = Image.FromStream(fs); fs.Close(); } catch { FileStream fs = File.Open(baseAddr + "nophoto.jpg", FileMode.Open, FileAccess.Read); pbCover.Image = Image.FromStream(fs); fs.Close(); } // = img; }
private void BtnDelet_Click(object sender, EventArgs e) { if (BookManage.deleteBook(book.Id) != 0) { MessageBox.Show("删除成功!"); File.Delete(string.Format(baseAddr + "{0}/{1}.jpg", BookManage.getGenreById(book.GenId).Id, book.Isbn)); book = BookManage.getFirstBook()[0]; loadBook(book); } else { MessageBox.Show("删除失败!"); } }
public void BookInfo() { this.lblISBN.Text = book.Isbn; this.lblName.Text = book.Name; this.lblAuthor.Text = book.Author; this.lblPrice.Text = book.Price.ToString(); card = cobCardId.SelectedItem as Card; this.lblDiscountedPirce.Text = book.Statue == 1 ? book.Price.ToString() : (book.Price * card.Discount).ToString(); this.lblPublisher.Text = BookManage.getPublisherById(book.PubId).Name; this.lblStock.Text = book.Stock.ToString(); //this.lblPubDate.Text = book.PubDate.ToString().Substring(0,8); string imgurl = string.Format(baseAddr + "{0}/{1}.jpg", BookManage.getGenreById(book.GenId).CatId, book.Isbn); this.pbCover.Image = Image.FromFile(imgurl); }
public void loadBook(Book book) { txtName.Text = book.Name; txtISBN.Text = book.Isbn; txtAuthor.Text = book.Author; nupPrice.Value = decimal.Parse(book.Price.ToString()); calPubDate.Value = book.PubDate; nupStock.Value = decimal.Parse(book.Stock.ToString()); cboRebate.Checked = book.Statue == 1 ? false : true; txtDesc.Text = book.Desc; cobPub.Items.Add(BookManage.getPublisherById(book.PubId)); cobPub.SelectedItem = cobPub.Items[0]; loadPubliser(); Genre gen = BookManage.getGenreById(book.GenId); Categorie cat = BookManage.getCategorieById(gen.CatId); imgAddr = string.Format(baseAddr + "{0}/{1}.jpg", cat.Id, book.Isbn); // pbCover.Image = Image.FromFile(imgAddr); try { FileStream fs = File.Open(imgAddr, FileMode.Open, FileAccess.Read); pbCover.Image = Image.FromStream(fs); fs.Close(); } catch { FileStream fs = File.Open(baseAddr + "nophoto.jpg", FileMode.Open, FileAccess.Read); pbCover.Image = Image.FromStream(fs); fs.Close(); } ofdChangeCover.FileName = imgAddr; cobCategories.Items.Add(cat); cobCategories.SelectedItem = cobCategories.Items[0]; loadCategories(); cobGenres.Items.Add(gen); cobGenres.SelectedItem = cobGenres.Items[0]; }