private void busStationListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     BO.BusStation busStation = (sender as ListView).SelectedItem as BO.BusStation;
     busLineListView.ItemsSource = bl.GetBusLineNumbers(busStation.Code).OrderBy(n => n);
     panelLines = new List <LineTiming>();
     lineTimingListView.ItemsSource = null;
     bl.SetStationPanel(busStation.Code, stationObserver);
 }
Пример #2
0
        public BO.BusStation BusStationDoBoAdapter(DO.BusStation stationDo)
        {
            BO.BusStation stationBo = new BO.BusStation();
            stationDo.CopyPropertiesTo(stationBo);
            List <int> test = (from line in dl.GetAllLineStationsBy(s => s.StationKey == stationBo.BusStationKey)
                               select line.LineId).ToList();

            stationBo.LinesThatPass = test;
            return(stationBo);
        }
 /// <summary>
 /// open the window of station info
 /// </summary>
 private void ShowStationsInfo()
 {
     BO.BusStation busStation = StationsDataGrid.SelectedItem as BO.BusStation;
     if (busStation != null)//prevent delete+double click
     {
         StationInfo win = new StationInfo(busStation);
         win.ShowDialog();
         ShowStations();
     }
 }
Пример #4
0
 public void UpdateBusStation(BO.BusStation station)
 {
     try
     {
         dl.UpdateStation(BusStationBoDoAdapter(station));
     }
     catch (DO.InexistantStationException ex)
     {
         throw new BO.InexistantStationException("This Bus Station not exist", ex);
     }
 }
Пример #5
0
 public void AddStation(BO.BusStation newStation)
 {
     DO.BusStation stationToAdd = BusStationBoDoAdapter(newStation);
     try
     {
         dl.AddStation(stationToAdd);
     }
     catch (DO.DuplicateStationException ex)
     {
         throw new BO.DuplicateStationException("You can't add this station because it already exists", ex);
     }
 }
Пример #6
0
 DO.BusStation BusStationBoDoAdapter(BO.BusStation stationBo)
 {
     DO.BusStation stationDo = new DO.BusStation();
     stationBo.CopyPropertiesTo(stationDo);
     if (stationDo.Latitude == 0)
     {
         stationDo.Latitude = rndLat.NextDouble() + 31;
     }
     if (stationDo.Longitude == 0)
     {
         stationDo.Longitude = rndLong.NextDouble() + 34;
     }
     return(stationDo);
 }
        /// <summary>
        ///  delete station from the data
        /// </summary>
        /// <param name="sender">sender of the event</param>
        /// <param name="e">e of the argument</param>
        private void DeleteStation(object sender, RoutedEventArgs e)
        {
            try
            {
                Button        bt      = sender as Button;
                BO.BusStation station = bt.DataContext as BO.BusStation;

                bool   check = true;
                string lines = "";
                foreach (var line in station.LinesInstation)
                {
                    if (bl.IsTwoStationsInLine(line.DOLineId))
                    {
                        check  = false;
                        lines += line.LineNumber.ToString() + ' ';
                    }
                }
                if (!check) // warning the user from delete station the cause to delete line
                {
                    var answer = MessageBox.Show(string.Format("Are you sure you want to delete? line/s {0} will be deleted", lines), "Attention!", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (answer == MessageBoxResult.Yes)
                    {
                        check = true;
                    }
                }
                if (check)
                {
                    bl.DeleteBusStation(station);
                    ShowStations();
                }
            }
            catch (BO.BusLineNotFound ex)
            {
                MessageBox.Show(ex.Message + string.Format(" wrong Line {0}.", ex.LineNumber), "Object not found", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (BO.StationNotFound ex)
            {
                MessageBox.Show(ex.Message + string.Format(" wrong station{0}", ex.Code), "Object not found", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #8
0
        public IEnumerable <IGrouping <TimeSpan, LineTiming> > StationTiming(BO.BusStation station, TimeSpan hour)
        {
            //if (station.LinesThatPass == null)
            //    throw new BO.InexistantLineTripException("לא נמצעו נסיעות בשעות אלו עבור הקו המבוקש");
            try
            {
                List <LineTiming> timing = new List <LineTiming>();
                foreach (int lineId in station.LinesThatPass)
                {
                    foreach (var item in ListArrivalOfLine(lineId, hour, station.BusStationKey))
                    {
                        timing.Add(item);
                    }
                }

                return(from item in timing
                       group item by item.ExpectedTimeTillArrive);
            }
            catch (DO.InexistantLineTripException ex)
            {
                throw new BO.InexistantLineTripException("לא נמצעו נסיעות בשעות אלו עבור הקו המבוקש", ex);
            }
        }