Example #1
0
        /// <summary>
        ///   loops through all the journeys to find the line matching
        ///     the out combo boxes.
        ///   if it finds a match, then it loops through all the journeys
        ///     to find the matching return journey (using the key field).
        ///   if there is no match make a note.
        /// </summary>
        private void SelectJourneyToEdit()
        {
            string keyIndex = string.Empty;
            bool   success  = false;

            for (int index = 0; index < journeyController.GetMileageDetailsLength(); ++index)
            {
                if (this.ValidRouteSelection(index))
                {
                    outIndex = index;
                    keyIndex = journeyController.GetMileageKey(index);
                    success  = true;
                    break;
                }
            }

            if (success)
            {
                for (int index = 0; index < journeyController.GetMileageDetailsLength(); ++index)
                {
                    if (string.Equals(keyIndex, journeyController.GetMileageKey(index)) &&
                        index != outIndex)
                    {
                        inIndex = index;
                        break;
                    }
                }

                this.newFromLocation   = journeyController.GetFromStation(outIndex);
                this.newToLocation     = journeyController.GetToStation(outIndex);
                this.newViaRoute       = journeyController.GetViaRoute(outIndex);
                this.newOutMiles       = journeyController.GetMiles(outIndex);
                this.newOutChains      = journeyController.GetChains(outIndex);
                this.newViaReturnRoute = journeyController.GetViaRoute(inIndex);
                this.newBackMiles      = journeyController.GetMiles(inIndex);
                this.newBackChains     = journeyController.GetChains(inIndex);

                this.EditMode = true;
                this.RaiseAddPropertyChangedEvents();
            }
        }