/// <summary>
        /// an event to remove the current line window
        /// </summary>

        private void removeOneLine_Click(object sender, RoutedEventArgs e)
        {
            BO.Line line = ((Button)sender).DataContext as BO.Line;
            bl.DeleteLine(line.ID);
            lineList.Remove(line);
            MessageBox.Show("The bus line: " + line.LineCode + " deleted succsesfully!", "Done succusesfully", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public LineViewInfo(BO.Line line)
        {
            InitializeComponent();
            try
            {
                if (line == null)
                {
                    Close();
                }
                line = myBL.GetLine(line.Id); // Get the line updated from database
            }
            catch (BO.BadLineException ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
            }

            textBlockLineInfo.Text = $"Line number: {line.Code}";
            textBlockArea.Text     = $"Area: {line.Area.ToString().ToLower()}";

            myLineStationsList         = new ObservableCollection <BO.LineStation>(line.LineStations);
            lvLineStations.ItemsSource = myLineStationsList;

            newLineStation = new BO.LineStation() // Set with defult values
            {
                LineId           = line.Id,       // Set the line station with the id of the line shown
                LineStationIndex = -1,
                IsDeleted        = false,
                NextStation      = -1,
                PrevStation      = -1,
                Station          = -1
            };
        }
 private void pbUpButton_Click(object sender, RoutedEventArgs e)
 {
     BO.LineStation lineStation = ((sender as Button).DataContext as BO.LineStation);
     BO.Line        line        = cbLineNum.SelectedItem as BO.Line;
     bl.MoveStationUpInLine(line.ID, lineStation.StationCode);
     UpdateLinesView(sender, e);
 }
 /// <summary>
 /// Initializes the current window in all existing objects
 /// </summary>
 public StartTravelLine(BO.Line mLine)
 {
     InitializeComponent();
     bl       = BLApi.Factory.GetBL("1");
     tempLine = mLine;
     busListBox.ItemsSource    = bl.GetAllBussesReadyForDrive().ToList();
     DriverListBox.ItemsSource = bl.GetAllUsers(user => user.Permission == BO.authority.Driver).ToList();
 }
 /// <summary>
 /// Defines actions to be performed when the user enters input
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Line_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     managingLine = (BO.Line)lines.SelectedItem;
     for (int i = 1; i <= managingLine.Stops.Count(); i++)
     {
         number_in_lines.Items.Add(i);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Initializes the current window in all existing objects
 /// </summary>
 public SequentialStopPresention(BO.Line mLine)
 {
     InitializeComponent();
     bl       = BLApi.Factory.GetBL("1");
     tempLine = mLine;
     stopListBoxA.DataContext = tempLine.Stops;
     stopListBoxB.ItemsSource = tempLine.Stops;
     ProgressBar();
 }
 private void cbLineNum_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     BO.Line line = (sender as ComboBox).SelectedItem as BO.Line;
     if (line != null)
     {
         lineStationsListView.DataContext = bl.GetLine(line.ID).Stations;
         lineTripsListView.DataContext    = bl.GetLineSchedule(line);
     }
 }
Beispiel #8
0
 public AddStationToLineWindow(IBL _bl, List <BO.Station> _stations, BO.Line _line)
 {
     InitializeComponent();
     bl       = _bl;
     stations = _stations;
     line     = _line;
     stations.RemoveAll(x => line.Stations.Exists(y => y.StationCode == x.StationCode)); // only stations not already in the line
     stationListView.DataContext = stations;
 }
Beispiel #9
0
        /// <summary>
        /// Defines actions to be performed when a  button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void information_Click(object sender, RoutedEventArgs e)
        {
            BLApi.IBL bl;
            bl = BLApi.Factory.GetBL("1");
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            new LineInfo(tempLine).Show();
        }
        /// <summary>
        /// This function is responsible for the series of actions that will be performed when this button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartTravel_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            var ab = new StartTravelLine(tempLine);

            ab.Height = 300;
            ab.Width  = 600;
            ab.Show();
        }
Beispiel #11
0
        /// <summary>
        /// Defines actions to be performed when a  button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void information_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            var ab = new LineInfo(tempLine);

            ab.Height = 350;
            ab.Width  = 250;
            ab.Show();
        }
        /// <summary>
        /// This function is responsible for the series of actions that will be performed when this button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SeqStopInfo_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            var ab = new SequentialStopPresention(tempLine);

            ab.Height = 300;
            ab.Width  = 600;
            ab.Show();
        }
        /// <summary>
        /// This function is responsible for the series of actions that will be performed when this button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lineLocation_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            var ab = new map2(tempLine.Number);

            ab.Height = 300;
            ab.Width  = 600;
            ab.Show();
        }
        /// <summary>
        /// Initializes the current window in all existing objects
        /// </summary>
        public LineManager(BO.Line line)
        {
            InitializeComponent();
            managingLine = new BO.Line();
            managingLine = line;
            bl           = BLApi.Factory.GetBL("1");
            var managingStops = bl.GetAllStops();

            allStopsList.ItemsSource = managingStops;
            stopsList.ItemsSource    = managingLine.Stops;
        }
        /// <summary>
        /// This function is responsible for the series of actions that will be performed when this button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            var ab = new LineManager(tempLine);

            ab.Height = 300;
            ab.Width  = 600;
            ab.Show();
        }
        /// <summary>
        /// an event to get the bus on a trip
        /// </summary>

        public void GoToTrip(BO.BusOnTrip b, BO.Line l)
        {
            PO.CurrentStation current = new PO.CurrentStation {
                TripStartTime = b.ActualTakeOff, EndStationName = l.StationsRoute.ToList().Last().Station.Address, UplineStations = l.StationsRoute, LineID = l.ID, LineNum = l.LineCode
            };
            PO.CurrentStation.LineTimings.Add(current);
            if (current.simulation == null)
            {
                current.simulation = new SimulationOfTrip(current);
            }
            current.simulation.Starting();
        }
 public LineScheduleWindow(IBL bl, BO.Line _line)
 {
     InitializeComponent();
     this.bl        = bl;
     line           = _line;
     newTrip.LineID = line.ID;
     if (line.Trip != null)
     {
         line.Trip.CopyPropertiesTo(newTrip);
     }
     TopLabel.Content         = $"Add trip for line {line.LineNum}";
     gridViewTrip.DataContext = newTrip;
 }
        /// <summary>
        /// an event to show the update line window
        /// </summary>

        private void updateBusLine_Click(object sender, RoutedEventArgs e)
        {
            BO.Line      l            = ((Button)sender).DataContext as BO.Line;
            LinesDetails linesDetails = new LinesDetails(l, false, true);

            if (linesDetails.ShowDialog() == true)//if the user fill all the ditals
            {
                bl.UpdateLine(l);
                int i = lineList.IndexOf(l);
                lineList.Remove(l);
                lineList.Insert(i, l);
            }
        }
Beispiel #19
0
        /// <summary>
        /// constractor of the window
        /// </summary>
        public LineInfo(BO.Line infoLine)
        {
            InitializeComponent();

            BLApi.IBL bl;
            bl = BLApi.Factory.GetBL("1");
            try
            {
                lineInfo.DataContext = infoLine;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            StopList.ItemsSource  = infoLine.Stops;
            BusesList.ItemsSource = infoLine.Buses;
        }
        /// <summary>
        /// This function is responsible for the series of actions that will be performed when this button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            Button a = (Button)sender;

            tempLine = (BO.Line)a.DataContext;
            try
            {
                bl.DeleteLine(tempLine.Id);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Information);
            }



            var aa = bl.GetAllLines().ToList();


            if (au == "PASSENGER")
            {
                foreach (BO.Line line in aa)
                {
                    line.Show = BO.status.REFULING;
                }
            }
            else
            {
                foreach (BO.Line line in aa)
                {
                    line.Show = BO.status.READY_FOR_DRIVE;
                }
            }



            lineList.ItemsSource = aa;
            lineList.Items.Refresh();
        }
        private void UpdateLinesView(object sender, EventArgs e)
        {
            int selectedLineId = (cbLineNum.SelectedItem as BO.Line).ID;

            // update linesView
            lines.Clear();
            foreach (var line in bl.GetAllLines())
            {
                lines.Add(line);
            }
            BO.Line lineToDisplay = lines.FirstOrDefault(x => x.ID == selectedLineId);
            if (lineToDisplay != null)
            {
                cbLineNum.SelectedItem           = lines.FirstOrDefault(x => x.ID == selectedLineId);
                lineStationsListView.DataContext = lineToDisplay.Stations;
                lineTripsListView.DataContext    = bl.GetLineSchedule(lineToDisplay);
            }
            else
            {
                lineStationsListView.DataContext = null;
                lineTripsListView.DataContext    = null;
            }
        }
Beispiel #22
0
        public LinesDetails(BO.Line line, bool isAdd, bool up = false)
        {
            InitializeComponent();
            MyLine       = line;
            Add          = isAdd;
            Update       = up;
            CanModified  = Update || Add;
            RestStations = new ObservableCollection <Stat>(from item in bl.GetAllStations() select new Stat(item.Code, item.Name));
            if (!Add)
            {
                lcode.IsEnabled = false;
                if (MyLine.StationsRoute != null)
                {
                    foreach (var item in MyLine.StationsRoute)
                    {
                        RestStations.Remove(RestStations.First(it => it.Code == item.Station.Code));
                    }
                }
                if (MyLine.StationsRoute != null)
                {
                    stationInLine = new ObservableCollection <BO.LineStation>(MyLine.StationsRoute);
                }
                else
                {
                    stationInLine = new ObservableCollection <BO.LineStation>();
                }
            }
            cmbxStation.SelectedItem = RestStations[0];
            DataContext = this;
            if (Add && line == null)
            {
                MyLine = new BO.Line()
                {
                    ID = bl.GetLineId()
                };
                bl.UpdateLineId();
                stationInLine         = new ObservableCollection <BO.LineStation>();
                cmbxStation.IsEnabled = false;
                txbDist.IsEnabled     = false;
                txbTime.IsEnabled     = false;
            }
            else if (!Add && !up)
            {
                larea.SelectedValue = new AREA {
                    Line_Area = MyLine.Area
                };
                larea.IsEnabled = false;
                lcode.IsEnabled = false;
            }
            if (Add)
            {
                adding.IsEnabled = false;
            }
            Station.ItemsSource = stationInLine;
            List <AREA> line_Areas = new List <AREA> {
                new AREA {
                    Line_Area = BO.Line_Area.Eilat
                }, new AREA {
                    Line_Area = BO.Line_Area.Haifa
                }, new AREA {
                    Line_Area = BO.Line_Area.Herzelia
                }, new AREA {
                    Line_Area = BO.Line_Area.Jerusalem
                }, new AREA {
                    Line_Area = BO.Line_Area.Netanya
                }, new AREA {
                    Line_Area = BO.Line_Area.Ramat_Gan
                }, new AREA {
                    Line_Area = BO.Line_Area.Tel_Aviv
                }
            };

            larea.ItemsSource = line_Areas;
        }
Beispiel #23
0
        private void addLine()
        {
            int code;

            if (!int.TryParse(tbLineNumber.Text, out code))
            {
                MessageBox.Show("Error: not a valid code line", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var firstStation = cbFirstStation.SelectedItem as BO.Station;

            if (firstStation == null)
            {
                MessageBox.Show("Please select first station", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var lastStation = cbLastStation.SelectedItem as BO.Station;

            if (lastStation == null)
            {
                MessageBox.Show("Please select last station", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (firstStation.Code == lastStation.Code)
            {
                MessageBox.Show("Error: select diffrent stations\n to the first and the last", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            int id;
            var newLine = new BO.Line()
            {
                Code         = code,
                FirstStation = firstStation.Code,
                LastStation  = lastStation.Code,
                IsDeleted    = false,
            };

            id = myBL.AddLine(newLine);
            myBL.AddLineStation(new BO.LineStation()
            {
                IsDeleted        = false,
                LineId           = id,
                LineStationIndex = 0,
                Station          = newLine.FirstStation,
                NextStation      = newLine.LastStation,
                PrevStation      = 0
            });
            myBL.AddLineStation(new BO.LineStation()
            {
                IsDeleted        = false,
                LineId           = id,
                LineStationIndex = 1,
                Station          = newLine.LastStation,
                NextStation      = -1,
                PrevStation      = newLine.FirstStation
            });
            newLine = myBL.GetLine(id);
            myLineList.Add(newLine);
            lvLineList.Items.Refresh();
        }
Beispiel #24
0
 /// <summary>
 /// Defines actions to be performed when a  button is pressed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lineListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     tempLine = (BO.Line)lineListBox.SelectedItem;
     lineLabel.DataContext = tempLine;
 }