private void Find_Click(object sender, RoutedEventArgs e) { var find = new Find(); find.ShowDialog(); // get data var resultBook = booksUtil.FindBookBy(GetStringValue); if (resultBook != null) { txtBookName.Text = resultBook.BookName; txtAuthor.Text = resultBook.Author; lstListCategory.Text = resultBook.Category; } var resultAuthor = booksUtil.FindBookByBookAuthor(GetStringValue); if (resultAuthor != null) { txtBookName.Text = resultAuthor.BookName; txtAuthor.Text = resultAuthor.Author; lstListCategory.Text = resultAuthor.Category; } }
private void btnFind_Click(object sender, RoutedEventArgs e) { if (txtFind.Text != "") { var selectItem = comboboxNameAuthor.SelectedValue as string; if (selectItem == TypeBooksConstant.BookName) { var result = booksUtil.FindBookBy(txtFind.Text); if (result != null) { lblFindResult.Foreground = Brushes.Green; lblFindResult.Content = $"Found '{txtFind.Text}'"; // Send value to Books foreach (Window item in Application.Current.Windows) { if (item is Books) { ((Books)item).GetName(txtFind.Text); } } if (cbxAutoClose.IsChecked.Value) // if true { Close(); } } else { lblFindResult.Foreground = Brushes.Red; lblFindResult.Content = "Nothing found"; } } else if (selectItem == TypeBooksConstant.Author) { var result = booksUtil.FindBookByBookAuthor(txtFind.Text); if (result != null) { lblFindResult.Foreground = Brushes.Green; lblFindResult.Content = $"Found '{txtFind.Text}'"; // Send value to Books foreach (Window item in Application.Current.Windows) { if (item is Books) { ((Books)item).GetName(txtFind.Text); } } if (cbxAutoClose.IsChecked.Value) // if true { Close(); } } else { lblFindResult.Foreground = Brushes.Red; lblFindResult.Content = "Nothing found"; } } else { lblFindResult.Foreground = Brushes.Red; lblFindResult.Content = "Nothing found"; } } else { lblFindResult.Foreground = Brushes.Red; lblFindResult.Content = "You must type a book name"; } }