/// <summary>
 /// Сохранаяет данные заданного агрегата
 /// </summary>
 /// <param name="detail">Агрегат</param>
 public bool SaveData(AbstractDetail detail)
 {
     for (int i = 0; i < existPrformances.Count; i++)
     {
         if (!existPrformances[i].SaveData())
         {
             return(false);
         }
     }
     for (int i = 0; i < addedPerformances.Count; i++)
     {
         if (addedPerformances[i].Interval != Lifelength.NullLifelength)
         {
             DetailDirective detailDirective = addedPerformances[i].GetDetailDirective();
             detail.AddDetailDirective(detailDirective);
             if (addedPerformances[i].AddActualStateRecordToDetail)
             {
                 ActualStateRecord record = new ActualStateRecord(addedPerformances[i].ComponentLastPerformance);
                 record.RecordDate = addedPerformances[i].RecordDate;
                 detail.AddRecord(record);
             }
             if (addedPerformances[i].AddActualStateRecordToAircraft)
             {
                 ActualStateRecord record = new ActualStateRecord(addedPerformances[i].AircraftLastPerformance);
                 record.RecordDate = addedPerformances[i].RecordDate;
                 if (detail is BaseDetail)
                 {
                     ((BaseDetail)detail).ParentAircraft.AddRecord(record);
                 }
                 else
                 {
                     ((Aircraft)detail.Parent.Parent).AddRecord(record);
                 }
             }
         }
     }
     if (currentDetail != null)
     {
         UpdateInformation();
     }
     return(true);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Данные работы обновляются по введенным значениям
        /// </summary>
        private bool SaveData()
        {
            TimeSpan hours;
            int      cycles;

            if (!UsefulMethods.ParseTime(textBoxFlightHours.Text, out hours))
            {
                SimpleBalloon.Show(textBoxFlightHours, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH:MM");
                return(false);
            }
            if (!int.TryParse(textBoxFlightCycles.Text, out cycles))
            {
                SimpleBalloon.Show(textBoxFlightCycles, ToolTipIcon.Warning, "Incorrect value", "Please enter integer value");
                return(false);
            }
            if (currentRecord.RecordDate != dateTimePickerDate.Value)
            {
                currentRecord.RecordDate = dateTimePickerDate.Value;
            }
            if (currentRecord.Lifelength.Hours.ToString() != textBoxFlightHours.Text ||
                currentRecord.Lifelength.Cycles.ToString() != textBoxFlightCycles.Text)
            {
                currentRecord.Lifelength = new Lifelength(new TimeSpan(0), cycles, hours);
            }
            if (currentRecord.Description != textBoxRemarks.Text)
            {
                currentRecord.Description = textBoxRemarks.Text;
            }
            try
            {
                if (mode == ScreenMode.Add)
                {
                    if (parentDetail != null)
                    {
                        parentDetail.AddRecord(currentRecord);
                    }
                    else
                    {
                        for (int i = 0; i < parentDetails.Count; i++)
                        {
                            parentDetails[i].AddRecord(new ActualStateRecord(currentRecord));
                        }
                    }
                    mode = ScreenMode.Edit;
                }
                else
                {
                    currentRecord.Save(true);
                }
                if (RecordChanged != null)
                {
                    RecordChanged(this, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while saving data", ex);
                return(false);
            }
            return(true);
        }