示例#1
0
        private void update_brn_Click(object sender, EventArgs e)
        {
            int index = books_lb.SelectedIndex;

            if (title_tb.Text != "" && author_tb.Text != "" && isbn_tb.Text != "" && url_tb.Text != "" && page_tb.Text != "" && year_tb.Text != "")
            {
                try
                {
                    int pg = Int32.Parse(page_tb.Text);
                    int yr = Int32.Parse(year_tb.Text);

                    bk[index]        = new BookDetails();
                    bk[index].Title  = title_tb.Text;
                    bk[index].Author = author_tb.Text;
                    bk[index].Isbn   = isbn_tb.Text;
                    bk[index].Url    = url_tb.Text;
                    bk[index].Page   = pg;
                    bk[index].Year   = yr;
                    bk[index].Pic    = picbox.ImageLocation;


                    books_lb.Items.Clear();
                    for (int i = 0; i < num; i++)
                    {
                        books_lb.Items.Add(bk[i].Title);
                    }

                    title_tb.Clear();
                    author_tb.Clear();
                    isbn_tb.Clear();
                    url_tb.Clear();
                    page_tb.Clear();
                    year_tb.Clear();
                    picbox.ImageLocation = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Exception");
                }
            }
            else
            {
                MessageBox.Show("Please Fill Out All fields which you want's to update:");
            }
        }
        private void add_btn_Click_1(object sender, EventArgs e)
        {
            if (title_tb.Text != "" && author_tb.Text != "" && isbn_tb.Text != "" && url_tb.Text != "" && page_tb.Text != "" && year_tb.Text != "")
            {
                int pg = Int32.Parse(page_tb.Text);
                int yr = Int32.Parse(year_tb.Text);

                bk[num]        = new BookDetails();
                bk[num].Title  = title_tb.Text;
                bk[num].Author = author_tb.Text;
                bk[num].Isbn   = isbn_tb.Text;
                bk[num].Url    = url_tb.Text;
                bk[num].Page   = pg;
                bk[num].Year   = yr;
                bk[num].Pic    = picbox.ImageLocation;

                books_lb.Items.Add(bk[num].Title);
                num++;
            }
            else
            {
                MessageBox.Show("Please Fill Out All fields");
            }
        }