예제 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Book book = new Book();

            book.Isbn   = txtISBN.Text;
            book.Name   = txtName.Text;
            book.Author = txtAuthor.Text;
            book.Desc   = txtDesc.Text;
            book.Price  = float.Parse(nupPrice.Value.ToString());
            Publisher pub = cobPub.SelectedItem as Publisher;

            book.PubId = pub.Id;
            Genre gen = cobGenres.SelectedItem as Genre;

            book.GenId   = gen.Id;
            book.Statue  = cboRebate.Checked ? 1 : 0;
            book.Stock   = (int)nupStock.Value;
            book.PubDate = calPubDate.Value;
            int re = BookManage.addBook(book);

            if (re == 1)
            {
                imgAddr = baseAddr + gen.CatId + "/" + book.Isbn + ".jpg";

                //FileStream f = File.Create(imgAddr);
                Image.FromFile(ofdCover.FileName).Save(imgAddr);
                MessageBox.Show(string.Format("图片:{0}保存成功", book.Name));
            }
            else
            {
                MessageBox.Show(string.Format("图片:{0}保存失败", book.Name));
            }
        }