private void btnSearch_Click(object sender, RoutedEventArgs e) //event that happens when button is clicked
        {
            string  station    = cmbxStationStrChooser.Text;           //gets input from user
            string  result     = string.Empty;                         //empty string
            Station resultStat = new Station();                        //creates new Station Object

            if (radStatName.IsChecked == true)                         //if StationName checkbox is checked
            {
                resultStat = Guide.SearchByStationName(station);       //search for the input station code based on inputted station name
            }
            else //else if StationCode checkbox is checked
            {
                resultStat = Guide.SearchByStationCd(station); //search by station code based on user input
            }

            foreach (string StationCodeStr in resultStat.StationCode) //foreach loop
            {
                result += Guide.DisplayRoute(StationCodeStr);         //output string
                result += "\r\n";
            }

            DisplayResults LineResult = new DisplayResults();                                                                           //create new instance of DisplayResults object

            LineResult.Show();                                                                                                          //show DisplayResults window
            LineResult.txtBoxDisplay.Text     = "Displaying Line : \r\n" + "# - Represents the station that you selected\r\n" + result; //display output in textbox in DisplayResults window
            LineResult.tripDetails.Visibility = Visibility.Collapsed;
            this.Hide();                                                                                                                //hides current windoxw
        }
Example #2
0
        private void btnSearch_Click(object sender, RoutedEventArgs e) //event that happens when button is clicked
        {
            string bStatCode;
            string aStatCode;

            if (radBStatName.IsChecked == true)                                                    //if Station Name radiobutton is checked
            {
                bStatCode = Guide.SearchByStationName(cmbxBStationStrChooser.Text).StationCode[0]; //Search for the input Station Code based on user input
            }
            else //else if Station Code radiobutton is checked
            {
                bStatCode = cmbxBStationStrChooser.Text;
            }

            if (radAStatName.IsChecked == true)                                                    //if Station Name radiobutton is checked
            {
                aStatCode = Guide.SearchByStationName(cmbxAStationStrChooser.Text).StationCode[0]; //search for the input Station Code based on user input
            }
            else //else if Station Code radiobutton is checked
            {
                aStatCode = cmbxAStationStrChooser.Text;
            }

            string cardFare        = "Stored Value Card Fare -- " + "$" + DBGuide.QueryFareFromDatabase(bStatCode, aStatCode)[0]; //assign value of card fare
            string ticketFare      = "Adult Standard Ticket -- " + "$" + DBGuide.QueryFareFromDatabase(bStatCode, aStatCode)[1];  //assign value of ticket fare
            string timeTaken       = "Time Taken -- " + DBGuide.QueryFareFromDatabase(bStatCode, aStatCode)[2] + " minutes";      //assign value of time taken
            bool   cardFareValue   = radCardFare.IsChecked.Value;                                                                 //check if radiobutton is checked
            bool   ticketFareValue = radTicketFare.IsChecked.Value;                                                               //check if radiobutton is checked
            bool   time            = radTime.IsChecked.Value;                                                                     //check if radiobutton is checked
            bool   fare            = radFare.IsChecked.Value;                                                                     //check if radiobutton is checked
            string output          = string.Empty;                                                                                //empty string

            if (chkAdvFeature.IsChecked.Value)                                                                                    //if checkbox for advanced feature is checked
            {
                if (time)                                                                                                         //if time is true
                {
                    output = Guide.FindPathV2(bStatCode, aStatCode, chkAdvFeature.IsChecked.Value);                               //output
                }
                else if (fare)                                                                                                    //if fare is true
                {
                    output = Guide.FindPathV2(bStatCode, aStatCode, chkAdvFeature.IsChecked.Value);                               //output
                }
                else
                {
                    output = "Error";
                }
            }
            else //else
            {
                output = Guide.FindPathV2(bStatCode, aStatCode, chkAdvFeature.IsChecked.Value); //output
            }


            DisplayResults Results = new DisplayResults();                                                     //create new instance of Results form

            if (cardFareValue)                                                                                 //if true
            {
                Results.Show();                                                                                //show Results form
                Results.txtBoxDisplay.Text = "Displaying Route : " + "\n" + output;                            //calls Guide.FindPathV2 and Displays Output in textbox in DirectionsResults window
                Results.tripDetails.Text   = "-- Fare Details and Time -- \n" + cardFare + "\n" + timeTaken;   //Fare Details and Time
                this.Hide();                                                                                   //hides current window
                DBGuide.InsertFareDataIntoHistory(bStatCode, aStatCode, 'C');                                  //Insert Query into database
            }
            else if (ticketFareValue)                                                                          //else if ticketfarevalue is true
            {
                Results.Show();                                                                                //show Results form
                Results.txtBoxDisplay.Text = "Displaying Route : " + "\n" + output;                            //calls Guide.FindPathV2 and Displays Output in textbox in DirectionsResults window
                Results.tripDetails.Text   = "-- Fare Details and Time -- \n" + ticketFare + "\n" + timeTaken; //fare details and time
                this.Hide();                                                                                   //hides current window
                DBGuide.InsertFareDataIntoHistory(bStatCode, aStatCode, 'T');                                  //Insert Query into database
            }
            else
            {
                Results.Show();                                                                                                                                                                                                   //show Results form
                Results.txtBoxDisplay.Text = "Displaying Route : " + "\n" + output;                                                                                                                                               //calls Guide.FindPathV2 and Displays Output in textbox in DirectionsResults window
                Results.tripDetails.Text   = "-- Fare Details and Time -- \n" + cardFare + "\n" + ticketFare + "\n" + timeTaken + "\nThis fare record will not be inserted into the database as Fare Type has not been selected"; //fare details and time
                this.Hide();                                                                                                                                                                                                      //hides current window
            }
        }