private void DeleteBook_Load(object sender, EventArgs e) { foreach (var item in Book_Center.GetBooks()) { cmbook.Items.Add(item.BookName); } }
private void btnCreateBook_Click(object sender, EventArgs e) { string Bookname = textBox2.Text.Trim(); int isbn = Convert.ToInt32(textBox3.Text); textBox3.Text = isbn.ToString(); int price = Convert.ToInt32(textBox4.Text); textBox4.Text = price.ToString(); string author = textBox5.Text.Trim(); //Bookname validation if (Bookname == string.Empty) { MessageBox.Show("Bookname is empty", "Eror!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Add Book Book book = new Book(); book.BookName = Bookname; book.Author = author; book.ISBN = isbn; book.Price = price; Book_Center.AddBook(book); ClearAddBookList(); //Update dataGridView to show new Book dgv.DataSource = null; dgv.DataSource = Book_Center.GetBooks(); }
private void UpdateBookDropdown() { cmbook.Items.Clear(); foreach (var item in Book_Center.GetBooks()) { cmbook.Items.Add(item.BookName); } }
private void btnCreateBook_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure to delete student?", "Confirmation!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { string selectBookName = cmbook.Text; if (Book_Center.DeleteByBookName(selectBookName)) { cmbook.Items.Clear(); foreach (var item in Book_Center.GetBooks()) { cmbook.Items.Add(item.BookName); } } else { MessageBox.Show("Not Found"); } } }
private void UpdateDataGridWhenFormClosed(object sender, EventArgs e) { dgv.DataSource = null; dgv.DataSource = Book_Center.GetBooks(); }