private void FindButton_Click(object sender, RoutedEventArgs e) //Finds the competitor in the SkiRun class. { NameTextBox.Clear(); //Clears the name text box. AddressTextBox.Clear(); //Clears the address text box. ScoreTextBox.Clear(); //Clears the score text box. TagTextBox.Clear(); //Clears the tag text box. FindCompetitor(); //Calls the FindCompetitor method above. }
private void ClearData_Click(object sender, RoutedEventArgs e) { activeSkiRun.ClearCompData(); //Calls a method in the SkiRun class which empties the dictionary and the lists. IncomeTextBox.Clear(); //Clears the income textbox. TotalScoresTextBox.Clear(); //Clears the total scores text box. EntriesTextBox.Clear(); //Clears the ammount of entries the competiton had. TopThreeScoresTextBox.Clear(); //Clears the high scores text box so data doesn't overlap. AgeMinTextBox.Clear(); //Clears the minimum age textbox. AgeMaxTextBox.Clear(); //Clears the maximum age textbox. AgeAveTextBox.Clear(); //Clears the average age textbox. AgeModeTextBox.Clear(); //Clears the mode age textbox. activeSkiRun.CompetitorAges.Clear(); //Clears the ages list. CompetitorNumberTextBox.Text = "000000"; //Resets the competitor number text box. NumberTextBox.Clear(); //Clears the number text box. NameTextBox.Clear(); //Clears the name text box. AddressTextBox.Clear(); //Clears the address text box. DetailsTextBox.Clear(); //Clears the details text box. ScoreTextBox.Clear(); //Clears the scores text box. SearchTextBox.Clear(); //Clears the seach by name text box. TagTextBox.Clear(); //Clears the tag text box. SearchByName.Items.Clear(); //Clears the search by name combo box. }
private void FindCompetitor() //Set up to find the competitors by their number. { DetailsTextBox.Clear(); //Clears the details textbox. Competitor editSkier; //Makes aninstance of the Competitor class. if (SearchTextBox.Text.Trim() != "" && NumberTextBox.Text.Trim() != "") //You can only use on search method so if there is text in both it will be rejected. { MessageBox.Show("Please use only one search method!"); //The error message. } else if (SearchByName.Text.Trim() == "" && NumberTextBox.Text.Trim() == "") //If there is no text in either search methods then the search will fail. { editSkier = null; //There's no competitor. MessageBox.Show("There is no competitor with that number or name! Please try again."); //The error message. NameTextBox.Clear(); //Clears the name text box. AddressTextBox.Clear(); //Clears the address text box. ScoreTextBox.Clear(); //Clears the score text box. NumberTextBox.Clear(); //Clears number text box. TagTextBox.Clear(); //Clears the tag text box. } //***NOTE*** - This is a very inefficient way to seach. I have the same code twice for each search method because I didn't know how to differentiate between the two. else if (SearchByName.Text.Trim() != "") //If search by name has some text in it then it will make a competitor. { editSkier = SkiRun.FindSkierByName(SearchByName.Text.Trim()); //Calls the find competitor by name in the SkiRun class. try { NameTextBox.Text = editSkier.GetName().Trim(); //Sets the competitor name. AddressTextBox.Text = editSkier.GetAddress().Trim(); //Sets the competitor address. ScoreTextBox.Text = editSkier.GetScore().Trim(); //Sets the competitor score. if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null) //If there's no sponsor, no blood type and no next of kin then it must be an amateur. { DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100"; //Information show in details text box. TagTextBox.Text = "Amateur"; //Displays the tag in the tag text box. } else if (editSkier.GetSponsor() != null) //If the sponsor does no equal null then it must be a professional. { DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor(); //Information show in details text box. TagTextBox.Text = "Professional"; //Displays the tag in the tag text box. } else if (editSkier.GetBlood() != null) //If blood type does not equal null then is must be a celebrity. { DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box. TagTextBox.Text = "Celebrity"; //Displays the tag in the tag text box. } } catch { MessageBox.Show("Could not find competitor!"); //If the user types a name it cannot find then it will display this. } } else if (NumberTextBox.Text.Trim() != "") //If the number text box has something in it then it will use this method. { editSkier = SkiRun.FindSkier(NumberTextBox.Text.Trim()); //Calls the find competitor in the SkiRun class. try { NameTextBox.Text = editSkier.GetName(); //Sets the competitor name. AddressTextBox.Text = editSkier.GetAddress(); //Sets the competitor address. ScoreTextBox.Text = editSkier.GetScore(); //Sets the competitor score. if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null) //If there's no sponsor, no blood type and no next of kin then it must be an amateur. { DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100"; //Information show in details text box. TagTextBox.Text = "Amateur"; //Displays the tag in the tag text box. } else if (editSkier.GetSponsor() != null) //If the sponsor does no equal null then it must be a professional. { DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor(); //Information show in details text box. TagTextBox.Text = "Professional"; //Displays the tag in the tag text box. } else if (editSkier.GetBlood() != null) //If blood type does not equal null then is must be a celebrity. { DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box. TagTextBox.Text = "Celebrity"; //Displays the tag in the tag text box. } } catch { MessageBox.Show("Could not find competitor!"); //If the user types a name it cannot find then it will display this. } } //NumberTextBox.Clear(); //SearchByName.Items.Clear(); //SearchTextBox.Clear(); }