private void ClearTextBoxes() { TextBoxGameName.Clear(); TextBoxRating.Clear(); TextBoxPrice.Clear(); TextBoxGenre.Clear(); TextBoxConsole.Clear(); }
private void SearchInventoryBtn_Click(object sender, EventArgs e) { string searchId = textBoxSearch.Text.Trim(); Book book = dbEntities.Books.Find(searchId); if (book != null) { comboBoxISBN.Text = book.ISBN; textBoxTitle.Text = book.Title; TextBoxPrice.Text = book.Price.ToString(); textBoxQOH.Text = book.QoH.ToString(); textBoxYear.Text = book.Year.ToString(); comboBoxPublisher.Text = book.PId.ToString(); comboBoxSupplier.Text = book.SId.ToString(); comboBoxAuthorID.Text = book.AuthorId.ToString(); } else { var listBook = dbEntities.Books.Where(tl => tl.Title == textBoxSearch.Text).ToList <Book>(); // if (listEmp != null) :Problem if (listBook.Count != 0) { foreach (var bk in listBook) { //MessageBox.Show( bk.ISBN.ToString()+ ", " + bk.Title.ToString() // + ", " + bk.Price.ToString()); ListViewProduct.Items.Clear(); comboBoxISBN.ResetText(); textBoxTitle.Clear(); TextBoxPrice.Clear(); textBoxQOH.Clear(); textBoxYear.Clear(); comboBoxPublisher.ResetText(); comboBoxSupplier.ResetText(); comboBoxAuthorID.ResetText(); ListViewItem item = new ListViewItem(bk.ISBN); item.SubItems.Add(bk.Title); item.SubItems.Add(bk.Price.ToString()); item.SubItems.Add(bk.QoH.ToString()); item.SubItems.Add(bk.Year.ToString()); item.SubItems.Add(bk.PId.ToString()); item.SubItems.Add(bk.SId.ToString()); item.SubItems.Add(bk.AuthorId.ToString()); ListViewProduct.Items.Add(item); } } else { MessageBox.Show("ISBN or Title not exist in the DB", "Warning"); } } }