/// <summary>
        /// Updates the field town category for stations from file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public static void updateStationDetailsFromFile(String fileName)
        {
            List <StationDetail> stationDetails = IOUtil.readTrainStationFromFile(fileName);

            foreach (StationDetail stationDetail in stationDetails)
            {
                // if station exits in train station cache
                if (TrainStationCache.getInstance().doesStationExist(stationDetail.StationName))
                {
                    // find station in cache
                    TrainStation s = TrainStationCache.getInstance()
                                     .getCacheContentOnName(stationDetail.StationName);
                    // copy inhabitation
                    s.Inhabitation = stationDetail.Inhabitation;
                    // update town category according inhabitation
                    s.updateTownCategory();

                    if (stationDetail.MinimalTransferTime != Time.EmptyValue)
                    {
                        s.MinimalTransferTime = stationDetail.MinimalTransferTime;
                    }

                    if (stationDetail.Town != "")
                    {
                        s.Town = stationDetail.Town;
                    }
                }
            }
        }
Exemple #2
0
        private void saveDetailsOfStation()
        {
            // if the value of inhabitation was changed
            if (inhabitationValueChanged())
            {
                // set up the new value of inhabitation
                trainStation.Inhabitation = Convert.ToInt32(textBoxInhabitation.Text);
                // and according that update townCategory
                trainStation.updateTownCategory();
            }
            // otherwise if category was changed
            else if (townCategoryValueChanged())
            {
                // set up the new value of townCategory
                trainStation.TownCategory = (TownCategory)comboBoxCategory.SelectedValue;
                // and according that update value of inhabitation
                trainStation.updateInhabitation();
            }

            // save information about the town
            trainStation.Town = textBoxTown.Text;
            trainStation.MinimalTransferTime = Time.ToTime(textBoxMinimalTransferTime.Text);
        }