Example #1
0
 /// <summary>
 /// Creates a new search
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void newSearchButton_Click(object sender, EventArgs e)
 {
     // New
     SearchField.Text     = "";
     SearchButton.Enabled = true;
     newSearch            = new SearchClass();
     clearGrid(searchGrid);
 }
Example #2
0
        /// <summary>
        ///  Calls the search for the current search parameters
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SearchButton_Click(object sender, EventArgs e)
        {
            // New
            newSearch = new SearchClass();

            nextButton.Enabled     = false;
            previousButton.Enabled = false;

            //getting string from search box
            String searchItem = SearchField.Text;

            //if nothing has been entered into the search box, show message
            if (searchItem == "")
            {
                SearchButton.Enabled = true;
                MessageBox.Show("Please select a search item and enter select the appropriate search criteria.");
                return;
            }

            //NEW Cancellation Exception
            try
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    await newSearch.searchHelper(searchItem, cancelToken.Token);

                    // NEW: Deactivate the search button after the search is run
                    SearchButton.Enabled = false;

                    nextButton.Enabled     = true;
                    previousButton.Enabled = false;
                    try
                    {
                        // updating the grid based on the new indecies
                        await updateDataGrid(searchGrid, startIndex, endIndex, cancelToken.Token);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Search returned 0 results.");
                    }
                    return;
                }

                else if (comboBox1.SelectedIndex == 1)
                {
                    await newSearch.searchHelperLanguage(searchItem, cancelToken.Token);

                    // NEW: Deactivate the search button after the search is run
                    SearchButton.Enabled = false;

                    nextButton.Enabled     = true;
                    previousButton.Enabled = false;
                    try
                    {
                        // updating the grid based on the new indecies
                        await updateDataGrid(searchGrid, startIndex, endIndex, cancelToken.Token);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Search returned 0 results.");
                    }
                    return;
                }

                else if (comboBox1.SelectedIndex == 2)
                {
                    int starRating = 0;
                    //checking that searchItem is an int
                    if (int.TryParse(searchItem, out starRating))
                    {
                        searchItem = "" + starRating;
                        await newSearch.searchHelperStars(searchItem, cancelToken.Token);

                        // NEW: Deactivate the search button after the search is run
                        SearchButton.Enabled = false;

                        nextButton.Enabled     = true;
                        previousButton.Enabled = false;
                        try
                        {
                            // updating the grid based on the new indecies
                            await updateDataGrid(searchGrid, startIndex, endIndex, cancelToken.Token);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Search returned 0 results.");
                        }
                        return;
                    }
                }
            }
            catch (OperationCanceledException)
            {
                MessageBox.Show("Search has been Cancelled.");
            }
        }