/// <summary> /// Отображение рейса текущего поезда для дальнейшего редактирования /// </summary> /// <param name="window"></param> private void EditVoyage(TrainInfoWindow window) { if (_trainToEdit == null || String.IsNullOrEmpty(TrainNum)) return; var voyage = VoyageBuilder.GetVoyageOfTrain(_trainToEdit.Id); if (voyage == null) { var newVoyage = new Voyage(); newVoyage.DepartureDateTime = DateTime.Now; newVoyage.TrainId = _trainToEdit.Id; ContextKeeper.Voyages.Add(newVoyage); } var voyageEditWin = new VoyageEditWindow(); voyageEditWin.Show(); Messenger.Default.Send(new TrainOfVoyageMessage(_trainToEdit.Id)); window.Close(); }
/// <summary> /// Открытие окна с данными конкретного поезда для их редактирования /// </summary> private void EditTrain() { if (TrainSelectedIndex >= 0) { var selectedTrainId = TrainList[TrainSelectedIndex].Id; var trainInfoWin = new TrainInfoWindow(); trainInfoWin.Show(); trainInfoWin.Closing += new System.ComponentModel.CancelEventHandler((a, b) => RefreshTrainList()); Messenger.Default.Send(new TrainInfoMessage(selectedTrainId)); } }
/// <summary> /// Сохранение изменений информации о поезде /// </summary> /// <param name="window"></param> private void SaveTrainInfo(TrainInfoWindow window) { if (String.IsNullOrEmpty(TrainNum)) return; if (_trainToEdit == null) { _trainToEdit = new Train(); _trainToEdit.TrainNum = TrainNum; ContextKeeper.Trains.Add(_trainToEdit); } _trainToEdit.TrainNum = TrainNum; ContextKeeper.Trains.Update(_trainToEdit); window.Close(); }
/// <summary> /// Добавление поезда /// </summary> private void AddTrain() { var trainInfoWin = new TrainInfoWindow(); trainInfoWin.Show(); trainInfoWin.Closing += new System.ComponentModel.CancelEventHandler((a,b) => RefreshTrainList()); }