public StationStartAndStopInfo()
 {
     InitializeComponent();
     var c = Content;
     TrainStationModel model = DataContext as TrainStationModel;
     //tb_over_station.Text = model.over_station.name;
     //tb_start_station.Text = model.start_station.name;
 }
Example #2
0
        /// <summary>
        /// This method is used to create the station information
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="toArrival">To arrival</param>
        /// <param name="toDistance">To distance</param>
        /// <returns>Date time</returns>
        public TrainStationModel CreateStationInfo(string name, string toArrival, double toDistance)
        {
            DateTime dateTimeArr;

            DateTime toStartTime;

            if (DateTime.TryParse("7:00:00 AM", out toStartTime))
            {
                // Do Nothing
            }

            DateTime toEndTime;

            if (DateTime.TryParse("7:00:00 PM", out toEndTime))
            {
                // Do Nothing
            }

            StepStatus currentStatus = StepStatus.NotStarted;

            if (DateTime.TryParse(toArrival, out dateTimeArr))
            {
                // Do Nothing
            }

            dateTimeArr = this.SetTrainTiming(dateTimeArr);

            if (this.lastStationStatus == StepStatus.Completed)
            {
                currentStatus = StepStatus.InProgress;
            }

            if (dateTimeArr <= DateTime.Now)
            {
                currentStatus = StepStatus.Completed;
            }

            this.lastStationStatus = currentStatus;

            var station = new TrainStationModel()
            {
                Name              = name,
                Arrival           = dateTimeArr.TimeOfDay.ToString().Remove(5),
                Departure         = dateTimeArr.AddMinutes(2).TimeOfDay.ToString().Remove(5),
                ArrivalDateTime   = dateTimeArr,
                DepartureDateTime = dateTimeArr.AddMinutes(2),
                Distance          = "Station at " + toDistance.ToString(CultureInfo.CurrentCulture) + " km",
                Status            = currentStatus,
            };

            if (station.Status == StepStatus.Completed)
            {
                station.ProgressedDistance = 100;
            }

            return(station);
        }
Example #3
0
 private void SetNorthComboBox()
 {
     using (TrainStationModel tsm = new TrainStationModel())
     {
         var list  = tsm.TrainStationTable.ToList();
         var start = list.Distinct(new TicketStartEquityComparer()).ToList();
         var end   = list.Distinct(new TicketEndEquityComparer()).ToList();
         comboBox1.DataSource    = end;
         comboBox2.DataSource    = start;
         comboBox1.DisplayMember = "EndStation";
         comboBox2.DisplayMember = "StartStation";
     }
 }
Example #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var tsm = new TrainStationModel())
     {
         var list = tsm.TrainStationTable.ToList();
         if (radioButton1.Checked == true)//south
         {
             var southprice = list.Where((x) => x.StartStation.ToString() == ((TrainStationTable)(comboBox1.SelectedItem)).StartStation.ToString() && x.EndStation.ToString() == ((TrainStationTable)(comboBox2.SelectedItem)).EndStation.ToString());
             if (checkBox1.Checked == true && checkBox2.Checked == true)
             {
                 label3.Text = (Math.Ceiling(southprice.First().Fare * 0.81 * 2)).ToString();
             }
             else if (checkBox2.Checked == true)
             {
                 label3.Text = (Math.Ceiling(southprice.First().Fare * 0.9)).ToString();
             }
             else if (checkBox1.Checked == true)
             {
                 label3.Text = (Math.Ceiling(southprice.First().Fare * 2 * 0.9)).ToString();
             }
             else
             {
                 label3.Text = southprice.First().Fare.ToString();
             }
         }
         else         //north
         {
             var northprice = list.Where((x) => x.EndStation.ToString() == ((TrainStationTable)(comboBox1.SelectedItem)).EndStation.ToString() && x.StartStation.ToString() == ((TrainStationTable)(comboBox2.SelectedItem)).StartStation.ToString());
             if (checkBox1.Checked == true && checkBox2.Checked == true)
             {
                 label3.Text = (Math.Ceiling(northprice.First().Fare * 0.81 * 2)).ToString();
             }
             else if (checkBox2.Checked == true)
             {
                 label3.Text = (Math.Ceiling(northprice.First().Fare * 0.9)).ToString();
             }
             else if (checkBox1.Checked == true)
             {
                 label3.Text = (Math.Ceiling(northprice.First().Fare * 2 * 0.9)).ToString();
             }
             else
             {
                 label3.Text = northprice.First().Fare.ToString();
             }
         }
     }
 }
Example #5
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     using (TrainStationModel tsm = new TrainStationModel())
     {
         var list = tsm.TrainStationTable.ToList();
         if (radioButton1.Checked == true)
         {
             var end = from o in list
                       where o.StartStation.ToString() == ((TrainStationTable)(comboBox1.SelectedItem)).StartStation.ToString()
                       select o;
             comboBox2.DataSource    = end.ToList();
             comboBox2.DisplayMember = "EndStation";
         }
         else
         {
             var end = list.Where((x) => x.EndStation.ToString() == ((TrainStationTable)(comboBox1.SelectedItem)).EndStation.ToString());
             comboBox2.DataSource    = end.ToList();
             comboBox2.DisplayMember = "StartStation";
         }
     }
 }
 public TrainDetailInfoViewModel(TrainDetailInfoModel model)
 {
     _model   = model;
     _station = new TrainStationModel(_model.train_start_station, _model.train_end_station);
 }