/// <summary>
        /// Заполняет поля для редактирования агрегата
        /// </summary>
        private void UpdateInformation()
        {
            if (_currentComponent == null)
            {
                throw new ArgumentNullException("_current" + "Detail", "must be not null");
            }

            lifelengthViewerWarranty.Lifelength       = _currentComponent.Warranty;
            lifelengthViewerWarrantyNotify.Lifelength = _currentComponent.WarrantyNotify;
            var d = _currentComponent;
            var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(_currentComponent.ParentAircraftId);    //TODO:(Evgenii Babak) надо пересмотреть тюк из aiercraft тут исползуется только Model

            if (d.LLPMark && d.LLPCategories && parentAircraft != null)
            {
                lifelengthTCSNOnInstall.Visible = false;

                //деталь является вращающимся элементом двигателя
                //поиск номера модели самолета в строке название модели самолета
                var pattern = @"(?<=\-\s*)\d+";
                //читается так:
                // ?<= -то, что должео идти перед искомой подстрокой
                // \- - тире
                // \s - пустое место(пробел); * -0 или более раз
                // \d - десятичная цифра; + -1 или более раз
                // из строки Boeing 737-300d - должно извлечь - 300
                var m = Regex.Match(parentAircraft.Model.ToString(), pattern);
                //TODO:Разобраться почему именно юольше 30
                //if (m.Success && int.Parse(m.Value) >= 30)
                //            {
                //модель самолета выше модели 737-300
                var list = GlobalObjects.CasEnvironment.GetDictionary <LLPLifeLimitCategory>()
                           .OfType <LLPLifeLimitCategory>()
                           .Where(llp => llp.AircraftModel.ItemId == parentAircraft.Model.ItemId)
                           .ToList();
                if (list.Count == 0)
                {
                    //если список категорий ресурса вращающихся деталей на данном самолете пуст
                    //добавление ресурса по умолчанию
                    var newControl = new ComponentLifeLimitControlItem(d);
                    _lifeLimitItems.Add(newControl);
                    flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                    flowLayoutPanelLifeLimit.Controls.Add(newControl);
                    flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
                }
                else
                {
                    //LINQ запрос для сортировки записей по дате;
                    var sortrecords = (from record in list
                                       orderby record.GetChar() ascending
                                       select record).ToList();

                    //if (d.ChangeLLPCategoryRecords.Count == 0)
                    //{
                    // if (d.ParentBaseComponent != null)
                    // {
                    //  var lastBaseComponentLL = d.ParentBaseComponent.ChangeLLPCategoryRecords.GetLast();
                    //  if (lastBaseComponentLL != null)
                    //  {
                    //   d.ChangeLLPCategoryRecords.Add(new ComponentLLPCategoryChangeRecord
                    //   {
                    //    ParentId = d.ItemId,
                    //    ToCategory = lastBaseComponentLL.ToCategory ?? LLPLifeLimitCategory.Unknown,
                    //    RecordDate = lastBaseComponentLL.RecordDate,
                    //    OnLifelength = Lifelength.Zero
                    //   });
                    //   GlobalObjects.CasEnvironment.Keeper.Save(d.ChangeLLPCategoryRecords[0]);
                    //  }
                    // }
                    //}

                    if (d.ChangeLLPCategoryRecords.Count != 0)
                    {
                        flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                        //TODO:Вынести расчет LLp в Calculator (1785 строка)
                        foreach (var t in sortrecords)
                        {
                            var llpData = d.LLPData.GetItemByCatagory(t);
                            if (llpData == null)
                            {
                                llpData = new ComponentLLPCategoryData
                                {
                                    LLPLifeLimit   = d.LifeLimit,
                                    ParentCategory = t,
                                    ComponentId    = d.ItemId
                                };
                                d.LLPData.Add(llpData);
                                GlobalObjects.NewKeeper.Save(llpData);
                            }

                            var lastRecord       = d.ChangeLLPCategoryRecords.GetLast();
                            var selectedCategory = lastRecord?.ToCategory;

                            if (selectedCategory != null)
                            {
                                if (selectedCategory.ItemId == t.ItemId)
                                {
                                    if (llpData.LLPCurrent != null)
                                    {
                                        if (!llpData.LLPCurrent.IsEqual(llpData.LLPTemp))
                                        {
                                            llpData.LLPTemp = new Lifelength(llpData.LLPCurrent);
                                            GlobalObjects.NewKeeper.Save(llpData);
                                        }
                                    }
                                }
                            }
                        }

                        //TODO: такой же цикл сверху, сделано для того что бы сначала расчитать LLPCurrent а тут уже посчитать Remain вынести все расчеты в Calculator!
                        foreach (var category in sortrecords)
                        {
                            var llpData = d.LLPData.GetItemByCatagory(category);
                            GlobalObjects.CasEnvironment.Calculator.CalculateLifeLimit(llpData, sortrecords, d.LLPData);
                            var newControl = new ComponentLifeLimitControlItem(llpData,
                                                                               llpData.ParentCategory == d.ChangeLLPCategoryRecords.GetLast().ToCategory);
                            _lifeLimitItems.Add(newControl);
                            flowLayoutPanelLifeLimit.Controls.Add(newControl);
                        }

                        flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
                    }
                }
            }
            else
            {
                //деталь не является вращающеися деталью двигателя,
                //или не установлена на самолет
                ComponentLifeLimitControlItem newControl = new ComponentLifeLimitControlItem(d);
                _lifeLimitItems.Add(newControl);
                flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                flowLayoutPanelLifeLimit.Controls.Add(newControl);
                flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);

                lifelengthTCSNOnInstall.Lifelength = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseEntityObject)_currentComponent);
            }

            fileControl.UpdateInfo(_currentComponent.FaaFormFile,
                                   "Adobe PDF Files|*.pdf",
                                   "This record does not contain a file proving the origin of the detail. Enclose PDF file to prove the origin.",
                                   "Attached file proves the origin of the detail.");
            if (Math.Abs(_currentComponent.CostNew) > 0.000001)
            {
                Cost = _currentComponent.CostNew;
            }
            if (Math.Abs(_currentComponent.CostOverhaul) > 0.000001)
            {
                CostOverhaul = _currentComponent.CostOverhaul;
            }
            if (Math.Abs(_currentComponent.CostServiceable) > 0.000001)
            {
                CostServiceable = _currentComponent.CostServiceable;
            }
            if (Math.Abs(_currentComponent.ManHours) > 0.000001)
            {
                ManHours = _currentComponent.ManHours;
            }
            KitRequered   = _currentComponent.KitRequired;
            Remarks       = _currentComponent.Remarks;
            HiddenRemarks = _currentComponent.HiddenRemarks;

            documentControl1.CurrentDocument = _currentComponent.DocumentCRS;
            documentControl1.Added          += DocumentControl1_Added;
        }
        ///<summary>
        ///</summary>
        ///<param name="llpMark"></param>
        ///<param name="parent"></param>
        public void InitLifeLimit(bool llpMark, Aircraft parent)
        {
            foreach (ComponentLifeLimitControlItem item in _lifeLimitItems)
            {
                flowLayoutPanelLifeLimit.Controls.Remove(item);
            }
            _lifeLimitItems.Clear();

            if (llpMark && parent != null)
            {
                //деталь является вращающимся элементом двигателя
                //поиск номера модели самолета в строке название модели самолета
                if (int.Parse(parent.Model.Series) >= 300)
                {
                    //модель самолета выше модели 737-300
                    List <LLPLifeLimitCategory> list =
                        GlobalObjects.CasEnvironment.GetDictionary <LLPLifeLimitCategory>()
                        .OfType <LLPLifeLimitCategory>()
                        .Where(llp => llp.AircraftModel == parent.Model)
                        .ToList();

                    if (list.Count == 0)
                    {
                        //если список категорий ресурса вращающихся деталей на данном самолете пуст
                        //добавление ресурса по умолчанию
                        ComponentLifeLimitControlItem newControl = new ComponentLifeLimitControlItem();
                        _lifeLimitItems.Add(newControl);
                        flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                        flowLayoutPanelLifeLimit.Controls.Add(newControl);
                        flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
                    }
                    else
                    {
                        //LINQ запрос для сортировки записей по дате;
                        List <LLPLifeLimitCategory> sortrecords = (from record in list
                                                                   orderby record.GetChar() ascending
                                                                   select record).ToList();

                        flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                        for (int i = 0; i < sortrecords.Count; i++)
                        {
                            ComponentLifeLimitControlItem newControl;
                            if (i != 0)
                            {
                                newControl             = new ComponentLifeLimitControlItem();
                                newControl.IsMainLimit = true;
                            }
                            else
                            {
                                newControl = new ComponentLifeLimitControlItem();
                            }


                            _lifeLimitItems.Add(newControl);
                            flowLayoutPanelLifeLimit.Controls.Add(newControl);
                        }
                        flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
                    }
                }
                else
                {
                    //модель самолета ниже 737-300
                    ComponentLifeLimitControlItem newControl = new ComponentLifeLimitControlItem();
                    _lifeLimitItems.Add(newControl);
                    flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                    flowLayoutPanelLifeLimit.Controls.Add(newControl);
                    flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
                }
            }
            else
            {
                //деталь не является вращающеися деталью двигателя,
                //или не установлена на самолет
                ComponentLifeLimitControlItem newControl = new ComponentLifeLimitControlItem();
                _lifeLimitItems.Add(newControl);
                flowLayoutPanelLifeLimit.Controls.Remove(panelWarranty);
                flowLayoutPanelLifeLimit.Controls.Add(newControl);
                flowLayoutPanelLifeLimit.Controls.Add(panelWarranty);
            }
        }