示例#1
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
            }
        }
示例#2
0
 public Directions()
 {
     InitializeComponent();
     Guide.initLineArray(); //Invokes Guide.initLineArray() Method
 }