Example #1
0
 public StationDetailsWindow(BO.Station station, IBL bl)
 {
     displayStat = station;
     this.bl     = bl;
     InitializeComponent();
     gridViewStat.DataContext = displayStat;
 }
        /// <summary>
        /// an event to show the details station window
        /// </summary>

        private void detailStation_Click(object sender, MouseButtonEventArgs e)
        {
            BO.Station     station       = bl.GetStationWithAdjacents((((FrameworkElement)e.OriginalSource).DataContext as BO.Station).Code);
            StationDetails detailStation = new StationDetails(station);

            detailStation.Show();
        }
        public StationViewInfo(BO.Station station)
        {
            InitializeComponent();
            try
            {
                if (station == null)
                {
                    return;
                }
                _currStation = myBL.GetStation(station.Code);
            }
            catch (BO.BadStationException ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            textBoxStationInfo.Text = _currStation.ToString();

            myLineList = new ObservableCollection <BO.Line>(_currStation.LinesPassBy);
            lvLinesPassBy.ItemsSource = myLineList;

            myAdjacentStationsList             = new ObservableCollection <BO.AdjacentStations>(_currStation.MyAdjacentStations);
            lvAdjacentStationsList.ItemsSource = myAdjacentStationsList;
        }
Example #4
0
 public UpdateStationWindow(BO.Station _updateStat, ObservableCollection <BO.Station> _stations, IBL _bl)
 {
     InitializeComponent();
     updateStat = _updateStat;
     stations   = _stations;
     bl         = _bl;
     gridViewStat.DataContext = updateStat;
 }
        private void pbUpdateStat_Click(object sender, RoutedEventArgs e)
        {
            BO.Station updateStation = new BO.Station();
            ((sender as Button).DataContext as BO.Station).CopyPropertiesTo(updateStation);
            UpdateStationWindow updateStationWindow = new UpdateStationWindow(updateStation, stations, bl);

            updateStationWindow.ShowDialog();
            updateStationWindow.Closed += UpdateLinesView;
        }
        /// <summary>
        /// an event to show the update station window
        /// </summary>

        private void update_Click(object sender, RoutedEventArgs e)
        {
            BO.Station       s          = ((Button)sender).DataContext as BO.Station;
            AddUpdateStation newStation = new AddUpdateStation(s.Code);

            if (newStation.ShowDialog() == true)//if the user fill all the ditals
            {
                bl.UpdateStation(newStation.MyStation);
                int i = listStations.IndexOf(s);
                listStations.Remove(s);
                listStations.Insert(i, newStation.MyStation);
            }
        }
Example #7
0
 private void btnAddStationExecution_Click(object sender, RoutedEventArgs e)
 {
     tbCode.BorderBrush         = tbName.BorderBrush =
         tbLatitude.BorderBrush = tbLongitude.BorderBrush = Brushes.Black;
     if (isEmptyBoxs())
     {
         return;
     }
     try
     {
         int code;
         if (!int.TryParse(tbCode.Text, out code) || code <= 0)
         {
             MessageBox.Show("Error: not valid station code", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         double lat, lon;
         if (!double.TryParse(tbLatitude.Text, out lat))
         {
             MessageBox.Show("Error: not valid latitude", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         if (!double.TryParse(tbLongitude.Text, out lon))
         {
             MessageBox.Show("Error: not valid longitude", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         var newStation = new BO.Station()
         {
             Code      = code,
             IsDeleted = false,
             Name      = tbName.Text,
             Latitude  = lat,
             Longitude = lon
         };
         myBL.AddStation(newStation);
         myStationList.Add(newStation);
     }
     catch (BO.BadStationException ex)
     {
         MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     gridAddNewStation.Visibility = Visibility.Hidden;
 }
Example #8
0
 private void pbUpdate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         bl.UpdateStation(updateStat); // will stop here if an exception is thrown
         BO.Station station = stations.FirstOrDefault(x => x.StationCode == updateStat.StationCode);
         updateStat.CopyPropertiesTo(station);
     }
     catch (ArgumentException)
     {
         MessageBox.Show("ERROR!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (InvalidOperationException ex)
     {
         MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     this.Close();
 }
 private void pbDeleteStat_Click(object sender, RoutedEventArgs e)
 {
     BO.Station delStation = (sender as Button).DataContext as BO.Station;
     if (MessageBox.Show("Are you sure?", "Consent", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         try
         {
             bl.DeleteStation(delStation);
         }
         catch (ArgumentException ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         // Stations View Update
         UpdateStationsView(sender, e);
         // update linesView
         UpdateLinesView(sender, e);
     }
 }
        // on double click on one line station in the list, show the station info
        private void lvLineStations_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var stationLine = lvLineStations.SelectedItem as BO.LineStation;

            if (stationLine == null)
            {
                return;
            }

            BO.Station station = new BO.Station();
            try
            {
                station = myBL.GetStation(stationLine.Station); // build the station
            }
            catch (BO.BadStationException ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            new StationViewInfo(station).Show();
        }
        /// <summary>
        /// show the station details onthe window
        /// </summary>

        public StationDetails(BO.Station station)
        {
            InitializeComponent();
            DataContext = station;
        }
 void refreshMe(int code)
 {
     _currStation            = myBL.GetStation(code);
     textBoxStationInfo.Text = _currStation.ToString();
 }