コード例 #1
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            if (ofdChangeCover.FileName != imgAddr)
            {
                this.pbCover.Image = null;
                File.Delete(imgAddr);
                Image.FromFile(ofdChangeCover.FileName).Save(imgAddr);
                //img.Save(imgAddr);
                //this.parent.getPbCover().Image = null;

                //
                // pbCover.Image.Save(imgAddr);
            }   //这里就已经保存了图片
            Book b = new Book();

            b.Name = txtName.Text;
            b.Isbn = txtISBN.Text;
            Publisher pub = cobPub.SelectedItem as Publisher;

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

            b.GenId   = gen.Id;
            b.Author  = txtAuthor.Text;
            b.Price   = float.Parse(nupPrice.Value.ToString());
            b.PubDate = calPubDate.Value;
            b.Stock   = (int)nupStock.Value;
            ;
            b.Desc   = txtDesc.Text;
            b.Statue = cboRebate.Checked ? 0:1;
            b.Id     = book.Id;

            if (BookManage.updateBook(b) != 0)
            {
                MessageBox.Show("修改成功!");
            }
            else
            {
                MessageBox.Show("修改失败!");
            }
            BtnReset_Click(sender, e);
            this.parent.loadBook(this.book);
        }