Exemple #1
0
        public TrackForm(FlightTrackRecord selectedItem) : this()
        {
            _flightTrack = selectedItem.FlightTrack;
            UpdateInformation();

            _animatedThreadWorker.DoWork             += AnimatedThreadWorkerDoLoad;
            _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted;
        }
Exemple #2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string message;

            if (!ValidateData(out message))
            {
                message += "\nAbort operation";
                MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (GetChangeStatus())
                {
                    ApplyChanges();
                    GlobalObjects.CasEnvironment.Keeper.SaveAll(_flightTrack);
                }

                //Сделанно специально при открытии с FlightScreen(сохраняем записи) в остальных случаях код не валиден
                if (_saveRecords)
                {
                    foreach (var item in _selectedItems.Where(i => i is FlightNumberPeriod))
                    {
                        var p = item as FlightNumberPeriod;

                        var flightTripRecord = new FlightTrackRecord
                        {
                            FlightNumberPeriod = p,
                            FlightTrack        = _flightTrack,
                            FlightPeriodId     = p.ItemId,
                            FlightTripId       = _flightTrack.ItemId
                        };
                        GlobalObjects.NewKeeper.Save(flightTripRecord);
                        _flightTrack.FlightTripRecord.Add(flightTripRecord);
                    }
                }
                _saveRecords = false;

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while save FlightTrip", ex);
            }
        }
Exemple #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (flightNumberListViewAll.SelectedItems.Count == 0)
            {
                return;
            }

            if (!flightNumberListViewAll.SelectedItems.All(p => p is FlightNumberPeriod))
            {
                MessageBox.Show("Please select only perods!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                return;
            }

            string message;

            if (!ValidateData(out message))
            {
                message += "\nAbort operation";
                MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (_flightTrack.ItemId <= 0 || GetChangeStatus())
                {
                    ApplyChanges();
                    GlobalObjects.NewKeeper.Save(_flightTrack);
                }

                foreach (var item in flightNumberListViewAll.SelectedItems.Cast <FlightNumberPeriod>().GroupBy(g => g.FlightNum))
                {
                    foreach (var period in item)
                    {
                        if (_addedItems.Contains(period))
                        {
                            MessageBox.Show($"Item {period} alredy added!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                            return;
                        }

                        if (_addedItems.Where(i => i is FlightNumberPeriod).Cast <FlightNumberPeriod>().Any(i => i.Schedule != period.Schedule))
                        {
                            MessageBox.Show($"You can not add {period.Schedule} schedule! Please select another period with difference schedule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                            return;
                        }

                        string flType = "";
                        if (_addedItems.Count > 0)
                        {
                            if (_addedItems.Where(i => i is FlightNumberPeriod).Cast <FlightNumberPeriod>().All(i => i.FlightType == FlightType.Schedule))
                            {
                                flType = "Shedule";
                            }
                            else if (_addedItems.Where(i => i is FlightNumberPeriod).Cast <FlightNumberPeriod>().All(i => i.FlightType != FlightType.Schedule))
                            {
                                flType = "UnShedule";
                            }

                            if (period.FlightType.RecoredType != flType)
                            {
                                MessageBox.Show($"You can not add period with Fl.Type : {period.FlightType}! Please select another period with difference Fl.Type!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                                return;
                            }
                        }



                        var flightTripRecord = new FlightTrackRecord
                        {
                            FlightNumberPeriod = period,
                            FlightTrack        = _flightTrack,
                            FlightPeriodId     = period.ItemId,
                            FlightTripId       = _flightTrack.ItemId
                        };
                        GlobalObjects.NewKeeper.Save(flightTripRecord);
                        _flightTrack.FlightTripRecord.Add(flightTripRecord);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while save FlightTrip", ex);
            }

            _animatedThreadWorker.RunWorkerAsync();
        }