Ejemplo n.º 1
0
 public SearchResult(itemList inputResults, string terms)
 {
     InitializeComponent();
     //pass in search results to local variable
     searchResults = inputResults;
     //loads the form boxes with information provided
     LoadBoxes(terms);
 }
Ejemplo n.º 2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     int flag = 0;
     itemList temp = new itemList();
     string[] searcharray = this.txtSearch.Text.ToUpper().Split(null);
     //looping through every item in the list
     foreach (Item i in shopOrder.getItemList)
     {
         flag = 0;
         //splitting the name into an array based on the whitespace
         //EG: "Apple Juice" becomes "APPLE", "JUICE" for testing
         string itemname = i.getName.ToUpper();
         string[] testarray = itemname.Split(null);
         //testing each term in the item name
         foreach (string testname in testarray)
         {
             //testing each term in search query
             foreach (string search in searcharray)
             {
                 if (testname == search)
                 {
                     //when a match is found, add the current item to the temporary list for search output
                     temp.addItem(i);
                     //flag is used to break out of the matching loop so that we move to the next item once a match has been found
                     flag = 1;
                     break;
                 }
             }
             //flag is used to move onto the next item in the list
             if (flag == 1)
             {
                 break;
             }
         }
     }
     resultPage = new SearchResult(temp, this.txtSearch.Text);
     resultPage.Show();
 }