示例#1
0
文件: Server.cs 项目: Kant8/Railway
 public static void FillRoute(Route route)
 {
     var endTime = GetTimeTillStationOnRoute(route.Id, route.EndStationId);
     route.EndTime = endTime;
 }
示例#2
0
文件: MainForm.cs 项目: Kant8/Railway
        private void buttonAddRoute_Click(object sender, EventArgs e)
        {
            var startStation = comboBoxJunkStationsStart.SelectedItem as Station;
            var endStation = comboBoxJunkStationsEnd.SelectedItem as Station;
            var strTime = textBoxRouteDepartureTime.Text;
            var train = comboBoxRouteTrains.SelectedItem as Train;

            if (startStation == null || endStation == null || train == null) return;
            DateTime startTime;
            try
            {
                startTime = Server.CreateTrainTime(strTime);
            }
            catch
            {
                MessageBox.Show("Формат времени ЧЧ:ММ");
                return;
            }

            var route = new Route
            {
                StartStation = startStation,
                EndStation = endStation,
                StartTime = startTime,
                Train = train
            };
            Server.Context.Routes.Add(route);
            Server.Context.SaveChanges();
            Server.FillRoute(route);
            Server.Context.SaveChanges();
        }