Exemplo n.º 1
0
 /// <summary>
 /// Заполняется DataSet
 /// </summary>
 /// <param name="dataSet"></param>
 public void FillDataSet(DiscrepanciesDataSet dataSet)
 {
     dataSet.Clear();
     dataSet.AdditionalDataTable.AddAdditionalDataTableRow(1, dateAsOf.ToString("MMM dd yyyy"), reportTitle,
                                                           thresholdLifelength.ToString());
     FillDetailDiscrepancies(dataSet);
     FillDirectiveDiscrepancies(dataSet);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        public void UpdateInformation()
        {
            if ((_currentDefferedItem == null) || _currentDefferedItem.ParentBaseComponent == null)
            {
                return;
            }

            var aircraft = GlobalObjects.AircraftsCore.GetParentAircraft(_currentDefferedItem);
            //GlobalObjects.PerformanceCalculator.GetNextPerformance(_currentDefferedItem);
            var ata = _currentDefferedItem.ATAChapter;

            labelDirectiveValue.Text     = _currentDefferedItem.Title + " for";
            labelDescriptionValue.Text   = _currentDefferedItem.Description;
            labelEffectiveDateValue.Text = Convert.GetDateFormat(_currentDefferedItem.Threshold.EffectiveDate);
            labelSBValue.Text            = _currentDefferedItem.ServiceBulletinNo;
            labelEOValue.Text            = _currentDefferedItem.EngineeringOrders;
            labelATAChapterValue.Text    = ata != null?ata.ToString() : "";

            labelApplicabilityValue.Text = _currentDefferedItem.Applicability;

            linkDetailInfoFirst.Text = aircraft.RegistrationNumber;
            labelRemarksLast.Text    = "";
            if (CurrentAircraft != null)
            {
                linkDirectiveStatus.Text = BackLinkText;
            }

            if (_currentDefferedItem.Remains != null && _currentDefferedItem.Condition != ConditionState.NotEstimated)
            {
                if (_currentDefferedItem.Remains.IsOverdue() && _currentDefferedItem.Condition == ConditionState.Overdue)
                {
                    labelRemains.Text           = "Overdue:";
                    imageLinkLabelStatus.Status = Statuses.NotSatisfactory;
                }
                else if (_currentDefferedItem.Condition == ConditionState.Notify)
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.Notify;
                }
                else if (_currentDefferedItem.Condition == ConditionState.Satisfactory)
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.Satisfactory;
                }
                else
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.NotActive;
                }
            }
            imageLinkLabelStatus.Text = _currentDefferedItem.WorkType.ToString();

            labelRemainsValue.Text = "";

            if (_currentDefferedItem.Remains != null)
            {
                labelRemainsValue.Text = _currentDefferedItem.Remains.ToString();
            }


            labelCostValue.Text     = _currentDefferedItem.Cost.ToString();
            labelManHoursValue.Text = _currentDefferedItem.ManHours.ToString();
            labelKitValue.Text      = _currentDefferedItem.KitRequired == "" ? "N" : _currentDefferedItem.KitRequired;
            labelNDTvalue.Text      = _currentDefferedItem.NDTType.ShortName;
            labelRemarksValue.Text  = _currentDefferedItem.Remarks;

            labelHiddenRemarksValue.Text = "";
            if (labelHiddenRemarksValue.Text == "")
            {
                labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false;
            }
            labelDateLast.Text            = "";
            labelAircraftTsnCsnLast.Text  = "";
            labelDateNext.Text            = "n/a";
            labelAircraftTsnCsnNext.Text  = "n/a";
            labelComponentTsnCsnNext.Text = "n/a";
            labelRemarksValue.Text        = "";


            BaseComponent parentBaseComponent = _currentDefferedItem.ParentBaseComponent;

            if (_currentDefferedItem.LastPerformance != null)
            {
                labelDateLast.Text = Convert.GetDateFormat(_currentDefferedItem.LastPerformance.RecordDate);

                if (!_currentDefferedItem.LastPerformance.OnLifelength.IsNullOrZero())
                {
                    labelComponentTsnCsnLast.Text = _currentDefferedItem.LastPerformance.OnLifelength.ToString();

                    labelAircraftTsnCsnLast.Text =
                        GlobalObjects.CasEnvironment.Calculator.
                        GetFlightLifelengthOnEndOfDay(parentBaseComponent, _currentDefferedItem.LastPerformance.RecordDate).ToString();
                }
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////
            labelFirstPerformanceValue.Text = "n/a";
            labelRptIntervalValue.Text      = "n/a";

            if (_currentDefferedItem.Threshold.FirstPerformanceSinceNew != null &&
                !_currentDefferedItem.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
            {
                labelFirstPerformanceValue.Text = "s/n: " + _currentDefferedItem.Threshold.FirstPerformanceSinceNew;
            }

            if (_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                !_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
            {
                if (labelFirstPerformanceValue.Text != "n/a")
                {
                    labelFirstPerformanceValue.Text += " or ";
                }
                else
                {
                    labelFirstPerformanceValue.Text = "";
                }
                labelFirstPerformanceValue.Text += "s/e.d: " + _currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate;
            }

            if (_currentDefferedItem.Threshold.RepeatInterval != null)
            {
                labelRptIntervalValue.Text = _currentDefferedItem.Threshold.RepeatInterval.IsNullOrZero()
                                                 ? "n/a"
                                                 : _currentDefferedItem.Threshold.RepeatInterval.ToString();
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////
            labelRemarksValue.Text = _currentDefferedItem.Remarks;


            if (_currentDefferedItem.IsClosed)
            {
                return;                               //если директива принудительно закрыта пользователем
            }
            //то вычисление следующего выполнения не нужно


            labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a";
            if (_currentDefferedItem.LastPerformance == null)
            {
                if (_currentDefferedItem.Threshold.PerformSinceNew &&
                    _currentDefferedItem.Threshold.FirstPerformanceSinceNew != null &&
                    !_currentDefferedItem.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    //если наработка исчисляется с момента выпуска
                    if (_currentDefferedItem.Threshold.FirstPerformanceSinceNew.Days != null)
                    {
                        //если в первом выполнении заданы дни
                        //то выводится точная дата следующего выполнения
                        labelDateNext.Text =
                            Convert.GetDateFormat(
                                parentBaseComponent.ManufactureDate.AddDays(
                                    (double)_currentDefferedItem.Threshold.FirstPerformanceSinceNew.Days)) +
                            " s/n";
                    }
                    else
                    {
                        //иначе, если (дополнительно) дата не определена
                        labelDateNext.Text = "n/a";
                    }
                    labelComponentTsnCsnNext.Text = "s/n: " + _currentDefferedItem.Threshold.FirstPerformanceSinceNew;
                    //labelAircraftTsnCsnNext.Text = "s/n: " + currentDirective.Threshold.SinceNew.ToString();
                }


                if (_currentDefferedItem.Threshold.PerformSinceEffectiveDate &&
                    _currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    //если наработка исчисляется с эффективной даты

                    //Определение даты исполнения
                    if (_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.Days != null)
                    {
                        //если в первом выполнении заданы дни
                        //то выводится точная дата следующего выполнения
                        if (labelDateNext.Text != "n/a")
                        {
                            labelDateNext.Text += " or ";
                        }
                        else
                        {
                            labelDateNext.Text = "";
                        }


                        labelDateNext.Text +=
                            Convert.GetDateFormat(
                                _currentDefferedItem.Threshold.EffectiveDate.AddDays
                                    ((double)_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.Days)) + " s/e.d.";
                    }
                    else
                    {
                        //иначе, дату определить нельзя
                        if (labelDateNext.Text == "")
                        {
                            labelDateNext.Text = "n/a";
                        }
                    }


                    //Определение наработки
                    if (_currentDefferedItem.Threshold.EffectiveDate < DateTime.Today)
                    {
                        Lifelength sinceEffDate =
                            GlobalObjects.CasEnvironment.Calculator.
                            GetFlightLifelengthOnEndOfDay(parentBaseComponent, _currentDefferedItem.Threshold.EffectiveDate);
                        sinceEffDate.Add(_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate);
                        sinceEffDate.Resemble(_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate);

                        if (labelComponentTsnCsnNext.Text != "n/a")
                        {
                            labelComponentTsnCsnNext.Text += " or ";
                        }
                        else
                        {
                            labelComponentTsnCsnNext.Text = "";
                        }
                        labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate;
                    }
                }
            }
            else
            {
                if (_currentDefferedItem.Threshold.PerformRepeatedly &&
                    _currentDefferedItem.Threshold.RepeatInterval != null)
                {
                    //повторяющаяся директива
                    //если есть последнне выполнение, то следующая дата расчитывается
                    //по повторяющемуся интервалу
                    if (_currentDefferedItem.Threshold.RepeatInterval.Days != null)
                    {
                        //если в первом выполнении заданы дни
                        //то выводится точная дата следующего выполнения
                        labelDateNext.Text =
                            Convert.GetDateFormat(
                                _currentDefferedItem.LastPerformance.RecordDate.AddDays(
                                    (double)_currentDefferedItem.Threshold.RepeatInterval.Days));
                    }
                    else
                    {
                        //иначе, точную дату выполнения расчитать нельзя
                        labelDateNext.Text            = "n/a";
                        labelComponentTsnCsnNext.Text = "n/a";
                    }

                    //Определение наработки
                    if (!_currentDefferedItem.Threshold.RepeatInterval.IsNullOrZero())
                    {
                        Lifelength nextTsnCsn;
                        if (!_currentDefferedItem.LastPerformance.OnLifelength.IsNullOrZero())
                        {
                            nextTsnCsn = new Lifelength(_currentDefferedItem.LastPerformance.OnLifelength);
                        }
                        else
                        {
                            nextTsnCsn = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(parentBaseComponent,
                                                                                                               _currentDefferedItem.
                                                                                                               LastPerformance.
                                                                                                               RecordDate);
                        }
                        Lifelength nextAircraftTsnCsn = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(
                            parentBaseComponent,
                            _currentDefferedItem.
                            LastPerformance.
                            RecordDate);

                        nextTsnCsn.Add(_currentDefferedItem.Threshold.RepeatInterval);
                        nextTsnCsn.Resemble(_currentDefferedItem.Threshold.RepeatInterval);
                        labelComponentTsnCsnNext.Text = nextTsnCsn.ToString();

                        nextAircraftTsnCsn.Add(_currentDefferedItem.Threshold.RepeatInterval);
                        nextAircraftTsnCsn.Resemble(_currentDefferedItem.Threshold.RepeatInterval);
                        labelAircraftTsnCsnNext.Text = nextAircraftTsnCsn.ToString();

                        if (labelComponentTsnCsnNext.Text == "")
                        {
                            labelComponentTsnCsnNext.Text = "n/a";
                        }
                        if (labelAircraftTsnCsnNext.Text == "")
                        {
                            labelAircraftTsnCsnNext.Text = "n/a";
                        }
                    }
                    else
                    {
                        labelComponentTsnCsnNext.Text = "n/a";
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item)
        {
            var subItems = new List <CustomCell>();
            var author   = GlobalObjects.CasEnvironment.GetCorrector(item);

            DateTime?  approx;
            Lifelength remains = Lifelength.Null, next;
            AtaChapter ata;
            MaintenanceControlProcess maintenanceType;
            DateTime   transferDate;
            Lifelength firstPerformance = Lifelength.Null,
                       lastPerformance = Lifelength.Null,
                       warranty, repeatInterval = Lifelength.Null;
            string partNumber,
                   description,
                   serialNumber,
                   position,
                   mpdString             = "",
                   mpdNumString          = "",
                   lastPerformanceString = "",
                   type        = getGroupName(item),
                   classString = "",
                   kitRequieredString,
                   remarks,
                   hiddenRemarks,
                   workType    = "",
                   zone        = "",
                   destination = "",
                   access      = "",
                   ndtString   = "";
            double manHours,
                   cost,
                   costServiceable = 0,
                   costOverhaul    = 0;

            if (item is Component)
            {
                Component componentItem = (Component)item;
                approx = componentItem.NextPerformanceDate;
                next   = componentItem.NextPerformanceSource;

                destination = GlobalObjects.AircraftsCore.GetAircraftById(componentItem.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString();

                var selectedCategory = componentItem.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                if (selectedCategory != null)
                {
                    var llp = componentItem.LLPData.GetItemByCatagory(selectedCategory);
                    remains = llp?.Remain;
                }



                ata              = componentItem.Model != null ? componentItem.Model.ATAChapter : componentItem.ATAChapter;
                partNumber       = componentItem.PartNumber;
                description      = componentItem.Model != null ? componentItem.Model.Description : componentItem.Description;
                serialNumber     = componentItem.SerialNumber;
                position         = componentItem.TransferRecords.GetLast().Position.ToUpper();
                maintenanceType  = componentItem.MaintenanceControlProcess;
                transferDate     = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance = componentItem.LifeLimit;
                warranty         = componentItem.Warranty;
                classString      = componentItem.GoodsClass != null?componentItem.GoodsClass.ToString() : "";

                kitRequieredString = componentItem.Kits.Count + " kits";
                manHours           = componentItem.ManHours;
                cost            = componentItem.Cost;
                costOverhaul    = componentItem.CostOverhaul;
                costServiceable = componentItem.CostServiceable;
                remarks         = componentItem.Remarks;
                hiddenRemarks   = componentItem.HiddenRemarks;
            }
            else
            {
                ComponentDirective dd = (ComponentDirective)item;


                destination = GlobalObjects.AircraftsCore.GetAircraftById(dd.ParentComponent.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString();

                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }
                if (dd.LastPerformance != null)
                {
                    lastPerformanceString =
                        SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " +
                        dd.LastPerformance.OnLifelength;
                    lastPerformance = dd.LastPerformance.OnLifelength;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd, out next, out remains, out approx, out cond);
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd);
                approx     = dd.NextPerformanceDate;
                next       = dd.NextPerformanceSource;
                remains    = dd.Remains;
                ata        = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.ATAChapter : dd.ParentComponent.ATAChapter;
                partNumber = "    " + dd.PartNumber;
                var desc = dd.ParentComponent.Model != null
                                        ? dd.ParentComponent.Model.Description
                                        : dd.ParentComponent.Description;

                description     = "    " + desc;
                serialNumber    = "    " + dd.SerialNumber;
                position        = "    " + dd.ParentComponent.TransferRecords.GetLast().Position.ToUpper();
                transferDate    = dd.ParentComponent.TransferRecords.GetLast().TransferDate;
                maintenanceType = dd.ParentComponent.MaintenanceControlProcess;
                warranty        = dd.Threshold.Warranty;
                classString     = dd.ParentComponent.GoodsClass != null?dd.ParentComponent.GoodsClass.ToString() : "";

                kitRequieredString = dd.Kits.Count + " kits";
                manHours           = dd.ManHours;
                cost          = dd.Cost;
                zone          = dd.ZoneArea;
                access        = dd.AccessDirective;
                remarks       = dd.Remarks;
                hiddenRemarks = dd.HiddenRemarks;
                workType      = dd.DirectiveType.ToString();
                ndtString     = dd.NDTType.ShortName;
                if (dd.MaintenanceDirective != null)
                {
                    mpdString    = dd.MaintenanceDirective.TaskNumberCheck;
                    mpdNumString = dd.MaintenanceDirective.TaskCardNumber;
                }
            }

            subItems.Add(CreateRow(destination, destination));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(mpdString, mpdString));
            subItems.Add(CreateRow(mpdNumString, mpdNumString));
            subItems.Add(CreateRow(position, position));
            subItems.Add(CreateRow(maintenanceType.ShortName, maintenanceType));
            subItems.Add(CreateRow(zone, zone));
            subItems.Add(CreateRow(access, access));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(firstPerformance?.ToString(), firstPerformance));
            subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval));
            subItems.Add(CreateRow(approx == null ? "" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next,
                                   approx == null ? DateTimeExtend.GetCASMinDateTime() : (DateTime)approx));
            subItems.Add(CreateRow(remains != null && !remains.IsNullOrZero() ? remains.ToString() : "",
                                   remains ?? Lifelength.Null));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformance));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(cost.ToString(), cost));
            subItems.Add(CreateRow(costOverhaul.ToString(), costOverhaul));
            subItems.Add(CreateRow(costServiceable.ToString(), costServiceable));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Exemplo n.º 4
0
        protected override void SetRowCellsValues(DataGridViewRow row, BaseEntityObject item)
        {
            AtaChapter ataChapter  = null;
            string     title       = "";
            string     description = "";
            string     zone        = "";
            string     access      = "";
            string     taskType    = "";
            MaintenanceDirectiveProgramType program = MaintenanceDirectiveProgramType.Unknown;
            StaticDictionary workType  = null;
            string           phase     = "";
            double           manHours  = 0;
            int        mans            = 0;
            string     categories      = "";
            double     cost            = 0;
            string     kits            = "";
            Lifelength performance     = Lifelength.Null;
            Lifelength repeat          = Lifelength.Null;
            Lifelength remain          = Lifelength.Null;
            DateTime?  performanceDate = null;

            if (item is NextPerformance)
            {
                NextPerformance       np = (NextPerformance)item;
                IEngineeringDirective engineeringDirective = np.Parent as IEngineeringDirective;
                if (engineeringDirective != null)
                {
                    ataChapter = engineeringDirective.ATAChapter;
                    zone       = engineeringDirective.Zone;
                    access     = engineeringDirective.Access;
                    program    = engineeringDirective.Program;
                    workType   = engineeringDirective.WorkType;
                    phase      = engineeringDirective.Phase;
                    manHours   = engineeringDirective.ManHours;
                    mans       = engineeringDirective.Mans;
                    categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; "));
                    cost       = engineeringDirective.Cost;
                }
                title           = np.Title;
                description     = np.Description;
                taskType        = np.Parent.SmartCoreObjectType.ToString();
                kits            = np.KitsToString;
                performance     = np.PerformanceSource;
                repeat          = np.Parent.Threshold != null ? np.Parent.Threshold.RepeatInterval : Lifelength.Null;
                remain          = np.Remains;
                performanceDate = np.PerformanceDate;
            }
            else if (item is AbstractPerformanceRecord)
            {
                //DirectiveRecord directiveRecord = (DirectiveRecord)item;
                AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item;

                IEngineeringDirective engineeringDirective = apr.Parent as IEngineeringDirective;
                if (engineeringDirective != null)
                {
                    ataChapter = engineeringDirective.ATAChapter;
                    zone       = engineeringDirective.Zone;
                    access     = engineeringDirective.Access;
                    program    = engineeringDirective.Program;
                    workType   = engineeringDirective.WorkType;
                    phase      = engineeringDirective.Phase;
                    manHours   = engineeringDirective.ManHours;
                    mans       = engineeringDirective.Mans;
                    categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; "));
                    cost       = engineeringDirective.Cost;
                }
                title           = apr.Title;
                description     = apr.Description;
                taskType        = apr.Parent.SmartCoreObjectType.ToString();
                kits            = apr.KitsToString;
                performance     = apr.OnLifelength;
                repeat          = apr.Parent.Threshold != null ? apr.Parent.Threshold.RepeatInterval : Lifelength.Null;
                performanceDate = apr.RecordDate;
            }
            else if (item is IEngineeringDirective)
            {
                IEngineeringDirective engineeringDirective = item as IEngineeringDirective;
                ataChapter      = engineeringDirective.ATAChapter;
                zone            = engineeringDirective.Zone;
                access          = engineeringDirective.Access;
                program         = engineeringDirective.Program;
                workType        = engineeringDirective.WorkType;
                phase           = engineeringDirective.Phase;
                manHours        = engineeringDirective.ManHours;
                mans            = engineeringDirective.Mans;
                categories      = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; "));
                cost            = engineeringDirective.Cost;
                title           = engineeringDirective.Title;
                description     = engineeringDirective.Description;
                taskType        = engineeringDirective.SmartCoreObjectType.ToString();
                kits            = engineeringDirective is IKitRequired ? ((IKitRequired)engineeringDirective).KitParentString : "";
                performance     = engineeringDirective.NextPerformanceSource;
                repeat          = engineeringDirective.Threshold != null ? engineeringDirective.Threshold.RepeatInterval : Lifelength.Null;
                performanceDate = engineeringDirective.NextPerformanceDate;
            }

            if (performance == null)
            {
                performance = Lifelength.Null;
            }
            if (repeat == null)
            {
                repeat = Lifelength.Null;
            }
            if (remain == null)
            {
                remain = Lifelength.Null;
            }

            row.Cells[0].Value = ataChapter != null?ataChapter.ToString() : "";

            row.Cells[0].Tag   = ataChapter;
            row.Cells[1].Value = title;
            row.Cells[1].Tag   = title;
            row.Cells[2].Value = description;
            row.Cells[2].Tag   = description;
            row.Cells[3].Value = zone;
            row.Cells[3].Tag   = zone;
            row.Cells[4].Value = access;
            row.Cells[4].Tag   = access;
            row.Cells[5].Value = taskType;
            row.Cells[5].Tag   = taskType;
            row.Cells[6].Value = program.ToString();
            row.Cells[6].Tag   = program;
            row.Cells[7].Value = workType != null?workType.ToString() : DirectiveType.Unknown.ToString();

            row.Cells[7].Tag = workType != null?workType.ToString() : DirectiveType.Unknown.ToString();

            row.Cells[8].Value  = phase;
            row.Cells[8].Tag    = phase;
            row.Cells[9].Value  = manHours.ToString();
            row.Cells[9].Tag    = manHours;
            row.Cells[10].Value = mans.ToString();
            row.Cells[10].Tag   = mans;
            row.Cells[11].Value = categories;
            row.Cells[11].Tag   = categories;
            row.Cells[12].Value = cost.ToString();
            row.Cells[12].Tag   = cost;
            row.Cells[13].Value = kits;
            row.Cells[13].Tag   = kits;
            row.Cells[14].Value = performance.ToString();
            row.Cells[14].Tag   = performance;
            row.Cells[15].Value = repeat.ToString();
            row.Cells[15].Tag   = repeat;
            row.Cells[16].Value = remain.ToString();
            row.Cells[16].Tag   = remain.ToString();
            row.Cells[17].Value = performanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)performanceDate);
            row.Cells[17].Tag   = performanceDate;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        public void UpdateInformation()
        {
            if (_currentComponent == null)
            {
                return;
            }
            if (_detailDirectivesPerformances == null)
            {
                _detailDirectivesPerformances = new List <ComponentSummaryCompliancePerformanceControl>();
            }
            else
            {
                _detailDirectivesPerformances.Clear();
            }
            //очищение плавающей панели и списка контролов отображения директив деталей
            flowLayoutPanel_Compliance.Controls.Clear();

            if (_currentComponent is BaseComponent)
            {
                BaseComponent inspectedBaseComponent = (BaseComponent)_currentComponent;

                var    lastTransferRecord   = inspectedBaseComponent.TransferRecords.GetLast();
                string baseDetailTypeString = inspectedBaseComponent.BaseComponentType.ToString();
                labelCompntTCSN.Text             = baseDetailTypeString + " Total:";
                labelCompntInstallDate.Text      = baseDetailTypeString + " install date:";
                labelCompntTCSNonInstall.Text    = baseDetailTypeString + " on Install:";
                labelCompntTCSNsinceInstall.Text = baseDetailTypeString + " since Install:";


                labelMPDItemValue.Text         = inspectedBaseComponent.MPDItem;
                labelDescriptionValue.Text     = inspectedBaseComponent.Model != null ? inspectedBaseComponent.Model.Description : inspectedBaseComponent.Description;
                labelRemarksValue.Text         = inspectedBaseComponent.Remarks;
                labelHiddenRemarksValue.Text   = inspectedBaseComponent.HiddenRemarks;
                labelPartNumberValue.Text      = inspectedBaseComponent.PartNumber;
                labelSerialNumberValue.Text    = inspectedBaseComponent.SerialNumber;
                labelPositionValue.Text        = lastTransferRecord.Position;          //позиция задается только для базовых деталей
                labelManufacturerValue.Text    = inspectedBaseComponent.Manufacturer;
                labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate);
                labelDeliveryDateValue.Text    = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.DeliveryDate);
                labelModelValue.Text           = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.ToString() : "";

                labelSupplierValue.Text        = inspectedBaseComponent.Suppliers.ToString();
                labelMaintFreqValue.Text       = inspectedBaseComponent.MaintenanceControlProcess.ToString();
                labelCostNewValue.Text         = inspectedBaseComponent.Cost.ToString();
                labelCostServiceableValue.Text = inspectedBaseComponent.CostServiceable.ToString();
                labelCostOverhaulValue.Text    = inspectedBaseComponent.CostOverhaul.ToString();
                labelWarrantyValue.Text        = inspectedBaseComponent.Warranty.ToString();
                labelClassValue.Text           = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.GoodsClass.ToString() :
                                                     inspectedBaseComponent.GoodsClass != null?inspectedBaseComponent.GoodsClass.ToString() : "";

                labelATAChapterValue.Text = inspectedBaseComponent.ATAChapter.ToString();

                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.None)
                {
                    labelAvionicsInventoryValue.Text = "None";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Optional)
                {
                    labelAvionicsInventoryValue.Text = "Optional";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Required)
                {
                    labelAvionicsInventoryValue.Text = "Required";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Unknown)
                {
                    labelAvionicsInventoryValue.Text = "Unknown";
                }

                labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate);
                Lifelength temp, temp2;
                //Наработка компонента на сегодня
                temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent);
                labelCompntTCSNValue.Text = temp.ToString();

                //Остаток жизненного времени на сегодня
                temp2 = new Lifelength(inspectedBaseComponent.LifeLimit);
                temp2.Substract(temp);
                temp2.Resemble(inspectedBaseComponent.LifeLimit);


                if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine)
                {
                    Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0
                                                                                           ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null)
                                              .OrderBy(d => d.NextPerformanceDate)
                                              .FirstOrDefault()
                                                                                           : null;

                    labelCompntLifeLimit.Text = baseDetailTypeString + " Life Limit / First Limit";

                    labelCompntLifeLimitValue.Text =
                        ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) +
                         " / " +
                         (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString()));

                    labelCompntLifeLimitRemains.Text = baseDetailTypeString + " Life Limit Remain / First Remains";

                    labelCompntLifeLimitRemainsValue.Text =
                        ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) +
                         " / " +
                         (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString()));
                }
                else
                {
                    labelCompntLifeLimit.Text             = baseDetailTypeString + " Life Limit";
                    labelCompntLifeLimitValue.Text        = inspectedBaseComponent.LifeLimit.ToString();
                    labelCompntLifeLimitRemains.Text      = baseDetailTypeString + " Life Limit Remain";
                    labelCompntLifeLimitRemainsValue.Text = temp2.ToString();
                }


                //Наработка компонента на момент установки
                temp2 = inspectedBaseComponent.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate)?.OnLifelength ?? Lifelength.Null;
                labelCompntTCSNonInstallValue.Text = temp2.ToString();

                //Наработка компонента с момента установки и по сей день
                temp.Substract(temp2);
                labelCompntTCSNsinceInstallValue.Text = temp.ToString();


                var tcsnLifeLenght           = Lifelength.Zero;
                var tcsnNonInstallLifeLenght = Lifelength.Zero;

                var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId);                //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь

                if (parentAircraft != null)
                {
                    tcsnLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft);

                    var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId);
                    //Наработка самолета на момент установки детали
                    if (aircraftFrame != null)
                    {
                        tcsnNonInstallLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, lastTransferRecord.TransferDate);
                    }
                }

                labelAircraftTCSNValue.Text          = tcsnLifeLenght.ToString();
                labelAircraftTCSNonInstallValue.Text = tcsnNonInstallLifeLenght.ToString();
            }
            else
            {
                var inspectedDetail = _currentComponent;

                var lastTransferRecord = inspectedDetail.TransferRecords.GetLast();
                labelMPDItemValue.Text         = inspectedDetail.MPDItem;
                labelDescriptionValue.Text     = inspectedDetail.Model != null ? inspectedDetail.Model.Description : inspectedDetail.Description;
                labelRemarksValue.Text         = inspectedDetail.Remarks;
                labelHiddenRemarksValue.Text   = inspectedDetail.HiddenRemarks;
                labelPartNumberValue.Text      = inspectedDetail.PartNumber;
                labelSerialNumberValue.Text    = inspectedDetail.SerialNumber;
                labelPositionValue.Text        = lastTransferRecord.Position;
                labelManufacturerValue.Text    = inspectedDetail.Manufacturer;
                labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.ManufactureDate);
                labelDeliveryDateValue.Text    = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.DeliveryDate);
                labelModelValue.Text           = inspectedDetail.Model != null?inspectedDetail.Model.ToString() : "";

                labelSupplierValue.Text        = inspectedDetail.Suppliers.ToString();
                labelMaintFreqValue.Text       = inspectedDetail.MaintenanceControlProcess.ToString();
                labelCostNewValue.Text         = inspectedDetail.Cost.ToString();
                labelCostServiceableValue.Text = inspectedDetail.CostServiceable.ToString();
                labelCostOverhaulValue.Text    = inspectedDetail.CostOverhaul.ToString();
                labelWarrantyValue.Text        = inspectedDetail.Warranty.ToString();
                labelClassValue.Text           = inspectedDetail.Model != null?inspectedDetail.Model.GoodsClass.ToString() :
                                                     inspectedDetail.GoodsClass != null?inspectedDetail.GoodsClass.ToString() : "";

                labelATAChapterValue.Text = inspectedDetail.ATAChapter.ToString();

                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.None)
                {
                    labelAvionicsInventoryValue.Text = "None";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Optional)
                {
                    labelAvionicsInventoryValue.Text = "Optional";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Required)
                {
                    labelAvionicsInventoryValue.Text = "Required";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Unknown)
                {
                    labelAvionicsInventoryValue.Text = "Unknown";
                }

                labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate);
                labelCompntLifeLimitValue.Text   = inspectedDetail?.LifeLimit?.ToString();

                var temp  = Lifelength.Null;
                var temp2 = Lifelength.Null;
                //Наработка компонента на сегодня
                if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories)
                {
                    var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                    if (selectedCategory != null)
                    {
                        var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory == selectedCategory);
                        temp = new Lifelength(data?.LLPCurrent);
                        if (data?.Remain != null)
                        {
                            temp2 = data.Remain;
                        }
                    }
                }
                else
                {
                    temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedDetail);
                }

                labelCompntTCSNValue.Text = temp.ToString();

                //Остаток жизненного времени на сегодня
                //temp2 = new Lifelength(inspectedDetail.LifeLimit);
                //temp2.Substract(temp);
                //temp2.Resemble(inspectedDetail.LifeLimit);
                labelCompntLifeLimitRemainsValue.Text = temp2.ToString();


                //Наработка компонента на момент установки
                var actualState = inspectedDetail.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate);
                if (actualState != null)
                {
                    temp2 = actualState.OnLifelength;
                }
                else
                {
                    temp2 = Lifelength.Null;
                }

                labelCompntTCSNonInstallValue.Text = temp2.ToString();

                //Наработка компонента с момента установки и по сей день
                if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories)
                {
                    var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                    if (selectedCategory != null)
                    {
                        var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory.ItemId == selectedCategory.ItemId);
                        temp.Substract(data?.LLPLifelengthCurrent);

                        labelCompntTCSNsinceInstallValue.Text = temp.ToString();
                    }
                }
                else
                {
                    temp.Substract(temp2);
                    labelCompntTCSNsinceInstallValue.Text = temp.ToString();
                }


                //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь
                var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedDetail.ParentAircraftId);

                //Наработка самолета на сегодня
                temp = parentAircraft != null
                                        ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft)
                                        : Lifelength.Zero;

                labelAircraftTCSNValue.Text = temp.ToString();

                //Наработка самолета на момент установки детали
                temp = parentAircraft != null
                                                   ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId), lastTransferRecord.TransferDate)
                                                   : Lifelength.Zero;

                labelAircraftTCSNonInstallValue.Text = temp.ToString();
            }

            //Обновление таблиц выполнения директив
            //На каждую из директив детали создается отдельная таблица выполнения
            //После каждая таблица помещается в плавающую панель для отображения

            List <ComponentDirective> detailDirectives = new List <ComponentDirective>(((Component)_currentComponent).ComponentDirectives.ToArray());

            for (int i = 0; i < detailDirectives.Count; i++)
            {
                ComponentSummaryCompliancePerformanceControl summaryCompliancePerformanceControl = new ComponentSummaryCompliancePerformanceControl(detailDirectives[i]);

                summaryCompliancePerformanceControl.UpdateInformation();

                _detailDirectivesPerformances.Add(summaryCompliancePerformanceControl);
                flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        private void UpdateInformation()
        {
            if (_currentComponent == null)
            {
                return;
            }
            if (_componentDirectivesPerformances == null)
            {
                _componentDirectivesPerformances = new List <BaseComponentDirectiveSummaryControl>();
            }
            else
            {
                _componentDirectivesPerformances.Clear();
            }
            //очищение плавающей панели и списка контролов отображения директив деталей
            flowLayoutPanel_Compliance.Controls.Clear();

            referenceLinkLabelLLPStatus.Visible = _currentComponent.BaseComponentType == BaseComponentType.Engine;

            var inspectedBaseComponent = _currentComponent;

            var baseComponentTypeString  = inspectedBaseComponent.BaseComponentType.ToString();
            var baseComponentModelString = inspectedBaseComponent.Model != null
                                                                                           ? " " + inspectedBaseComponent.Model
                                                                                           : "";
            var engineThrustString =
                inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine &&
                !string.IsNullOrEmpty(inspectedBaseComponent.Thrust)
                                                                                        ? "/" + inspectedBaseComponent.Thrust
                                                                                        : "";

            extendableRichContainer.Caption = baseComponentTypeString + baseComponentModelString + engineThrustString
                                              //+ " P/N:" + _currentComponent.PartNumber
                                              + " S/N:" + _currentComponent.SerialNumber
                                              + " M/P:" + _currentComponent.MaintenanceControlProcess.ShortName
                                              + " Pos:" + _currentComponent.TransferRecords.GetLast().Position;

            referenceLinkLabelBaseDetail.Text = baseComponentTypeString;


            labelCompntTCSN.Text             = baseComponentTypeString + " Total:";
            labelCompntInstallDate.Text      = baseComponentTypeString + " install date:";
            labelCompntTCSNonInstall.Text    = baseComponentTypeString + " on Install:";
            labelCompntTCSNsinceInstall.Text = baseComponentTypeString + " since Install:";


            labelRemarksValue.Text         = inspectedBaseComponent.Remarks;
            labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate);
            labelWarrantyValue.Text        = inspectedBaseComponent.Warranty.ToString();

            labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.TransferRecords.GetLast().TransferDate);
            Lifelength temp, temp2;

            //Наработка компонента на сегодня
            temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent);
            labelCompntTCSNValue.Text = temp.ToString();

            //Остаток жизненного времени на сегодня
            temp2 = new Lifelength(inspectedBaseComponent.LifeLimit);
            temp2.Substract(temp);
            temp2.Resemble(inspectedBaseComponent.LifeLimit);


            if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine)
            {
                Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0
                                                                                   ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null)
                                          .OrderBy(d => d.NextPerformanceDate)
                                          .FirstOrDefault()
                                                                                   : null;

                labelCompntLifeLimit.Text = baseComponentTypeString + " Life Limit / First Limit";

                labelCompntLifeLimitValue.Text =
                    ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) +
                     " / " +
                     (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString()));

                labelCompntLifeLimitRemains.Text = baseComponentTypeString + " Life Limit Remain / First Remains";

                labelCompntLifeLimitRemainsValue.Text =
                    ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) +
                     " / " +
                     (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString()));
            }
            else
            {
                labelCompntLifeLimit.Text             = baseComponentTypeString + " Life Limit";
                labelCompntLifeLimitValue.Text        = inspectedBaseComponent.LifeLimit.ToString();
                labelCompntLifeLimitRemains.Text      = baseComponentTypeString + " Life Limit Remain";
                labelCompntLifeLimitRemainsValue.Text = temp2.ToString();
            }

            var lastTransferRecord = inspectedBaseComponent.TransferRecords.GetLast();

            //Наработка компонента на момент установки
            temp2 = lastTransferRecord.OnLifelength;
            labelCompntTCSNonInstallValue.Text = temp2.ToString();

            //Наработка компонента с момента установки и по сей день
            temp.Substract(temp2);
            labelCompntTCSNsinceInstallValue.Text = temp.ToString();

            var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId);

            //Наработка самолета на сегодня
            temp = parentAircraft != null
                                           ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft)
                                           : Lifelength.Zero;

            labelAircraftTCSNValue.Text = temp.ToString();

            //Наработка самолета на момент установки детали
            temp = parentAircraft != null
                                           ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId),
                                                                                                                   lastTransferRecord.TransferDate)
                                           : Lifelength.Zero;

            labelAircraftTCSNonInstallValue.Text = temp.ToString();

            //Обновление таблиц выполнения директив
            //На каждую из директив детали создается отдельная таблица выполнения
            //После каждая таблица помещается в плавающую панель для отображения

            var componentDirectives = new List <ComponentDirective>(_currentComponent.ComponentDirectives.ToArray());

            for (int i = 0; i < componentDirectives.Count; i++)
            {
                var summaryCompliancePerformanceControl = new BaseComponentDirectiveSummaryControl(componentDirectives[i]);

                summaryCompliancePerformanceControl.UpdateInformation();

                _componentDirectivesPerformances.Add(summaryCompliancePerformanceControl);
                flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        /// <param name="bindedItems"></param>
        private void UpdateInformation(IList <IDirective> bindedItems)
        {
            if ((_currentDirective == null) || _currentDirective.ParentBaseComponent == null)
            {
                return;
            }

            var inspectedComponent = _currentDirective.ParentBaseComponent;

            labelDirectiveValue.Text    = _currentDirective.TaskNumberCheck;
            labelDescriptionValue.Text  = _currentDirective.Description;
            labelRevisionDateValue.Text = _currentDirective.MpdRevisionNum + " " + Convert.GetDateFormat(_currentDirective.MpdRevisionDate);
            labelAMP.Text             = _currentDirective.ScheduleItem;
            labelAMPRevison.Text      = _currentDirective.ScheduleRevisionNum + " " + (_currentDirective.ScheduleRevisionDate > DateTimeExtend.GetCASMinDateTime() ? Convert.GetDateFormat(_currentDirective.ScheduleRevisionDate) : "");
            labelSBValue.Text         = _currentDirective.ServiceBulletinNo;
            labelATAChapterValue.Text = _currentDirective.ATAChapter != null
                ? _currentDirective.ATAChapter.ToString()
                : "";

            labelRemarksLast.Text         = "";
            labelApplicabilityValue.Text  = _currentDirective.Applicability;
            labelRemarksValue.Text        = _currentDirective.Remarks;
            labelHiddenRemarksValue.Text  = _currentDirective.HiddenRemarks;
            labelMRBValue.Text            = _currentDirective.MRB;
            labelMaintManualValue.Text    = _currentDirective.MaintenanceManual;
            labelTaskCardNumberValue.Text = _currentDirective.TaskCardNumber;
            labelMPDNumberValue.Text      = _currentDirective.MPDTaskNumber;
            labelWorkArea.Text            = _currentDirective.Workarea;
            labelSkill.Text               = _currentDirective.Skill.ToString();
            labelCategory.Text            = _currentDirective.Category.ToString();
            labelProgramValue.Text        = _currentDirective.Program.ToString();
            labelCriticalSystemValue.Text = _currentDirective.CriticalSystem.ToString();


            if (_currentDirective.Zone.Length > 10)
            {
                labelZoneValue.Text = _currentDirective.Zone.Replace(Environment.NewLine, " ").Substring(0, 10) + "....";
            }
            else
            {
                labelZoneValue.Text = _currentDirective.Zone.Replace(Environment.NewLine, " ");
            };

            if (_currentDirective.Access.Length > 10)
            {
                labelAccessValue.Text = _currentDirective.Access.Replace(Environment.NewLine, " ").Substring(0, 10) + "....";
            }
            else
            {
                labelAccessValue.Text = _currentDirective.Access.Replace(Environment.NewLine, " ");
            }

            labelCheckValue.Text = _currentDirective.MaintenanceCheck != null
                    ? _currentDirective.MaintenanceCheck.Name
                    : "N/A";
            SetTextBoxComponentsString(bindedItems);
            if (CurrentBaseComponent != null)
            {
                linkDirectiveStatus.Text = BackLinkText;
            }

            ///////////////////////////////////////////////////////////////////////
            // Расчетные данные
            //////////////////////////////////////////////////////////////////////

            if (_currentDirective.ItemRelations.Count == 0)
            {
                #region  асчет при отсутствии привязанных задач

                if (_currentDirective.Remains != null && _currentDirective.Condition != ConditionState.NotEstimated)
                {
                    if (_currentDirective.Remains.IsOverdue() && _currentDirective.Condition == ConditionState.Overdue)
                    {
                        labelRemains.Text           = "Overdue:";
                        imageLinkLabelStatus.Status = Statuses.NotSatisfactory;
                    }
                    else if (_currentDirective.Condition == ConditionState.Notify)
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.Notify;
                    }
                    else if (_currentDirective.Condition == ConditionState.Satisfactory)
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.Satisfactory;
                    }
                    else
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.NotActive;
                    }
                }
                imageLinkLabelStatus.Text = _currentDirective.WorkType.ToString();

                labelRemainsValue.Text = "";

                if (_currentDirective.Remains != null)
                {
                    labelRemainsValue.Text = _currentDirective.Remains.ToString();
                }

                labelCostValue.Text     = _currentDirective.Cost.ToString();
                labelManHoursValue.Text = _currentDirective.ManHours.ToString();
                labelKitValue.Text      = _currentDirective.Kits.Count == 0 ? "N" : _currentDirective.Kits.Count + "Kits";
                labelNDTvalue.Text      = _currentDirective.NDTType.ShortName;
                //labelRemarksValue.Text = _currentDirective.Remarks;

                //labelHiddenRemarksValue.Text = "";
                //if (labelHiddenRemarksValue.Text == "")
                //    labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false;

                labelDateLast.Text            = "";
                labelAircraftTsnCsnLast.Text  = "";
                labelNextCompliance.Text      = "Next Compliance";
                labelDateNext.Text            = "n/a";
                labelAircraftTsnCsnNext.Text  = "n/a";
                labelComponentTsnCsnNext.Text = "n/a";
                //labelRemarksValue.Text = "";

                if (_currentDirective.LastPerformance != null)
                {
                    labelDateLast.Text = Convert.GetDateFormat(_currentDirective.LastPerformance.RecordDate);
                    //labelRemarksLast.Text = currentDirective.LastPerformance.Description;

                    if (!_currentDirective.LastPerformance.OnLifelength.IsNullOrZero())
                    {
                        labelComponentTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString();
                    }
                    else
                    {
                        labelComponentTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString();
                    }

                    //TODO:(Evgenii Babak)Если тип inspectedDetail будет Frame, то при перерасчете будет проверен тип базового агрегата и если он равен Frame,
                    //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС

                    //labelAircraftTsnCsnLast.Text =
                    //                   GlobalObjects.CasEnvironment.Calculator.
                    //                    GetFlightLifelengthOnStartOfDay(inspectedComponent, _currentDirective.LastPerformance.RecordDate).ToString();
                    labelAircraftTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString();
                }

                ///////////////////////////////////////////////////////////////////////////////////////////////
                labelFirstPerformanceValue.Text = "n/a";
                labelRptIntervalValue.Text      = "n/a";

                if (_currentDirective.Threshold.FirstPerformanceSinceNew != null &&
                    !_currentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    labelFirstPerformanceValue.Text = "s/n: " + _currentDirective.Threshold.FirstPerformanceSinceNew;
                }

                if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (labelFirstPerformanceValue.Text != "n/a")
                    {
                        labelFirstPerformanceValue.Text += " or ";
                    }
                    else
                    {
                        labelFirstPerformanceValue.Text = "";
                    }
                    labelFirstPerformanceValue.Text += "s/e.d: " + _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                if (_currentDirective.Threshold.RepeatInterval != null)
                {
                    labelRptIntervalValue.Text = _currentDirective.Threshold.RepeatInterval.IsNullOrZero()
                                                     ? "n/a"
                                                     : _currentDirective.Threshold.RepeatInterval.ToString();
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////
                //labelRemarksValue.Text = _currentDirective.Remarks;


                if (_currentDirective.IsClosed)
                {
                    return;                            //если директива принудительно закрыта пользователем
                }
                //то вычисление следующего выполнения не нужно


                labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a";
                if (_currentDirective.LastPerformance == null)
                {
                    if (_currentDirective.Threshold.FirstPerformanceSinceNew != null &&
                        !_currentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                    {
                        //если наработка исчисляется с момента выпуска
                        if (_currentDirective.Threshold.FirstPerformanceSinceNew.CalendarValue != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            labelDateNext.Text =
                                Convert.GetDateFormat(inspectedComponent.ManufactureDate.
                                                      AddCalendarSpan(_currentDirective.Threshold.FirstPerformanceSinceNew.CalendarSpan)) +
                                " s/n";
                        }
                        else
                        {
                            //иначе, если (дополнительно) дата не определена
                            labelDateNext.Text = "n/a";
                        }
                        labelComponentTsnCsnNext.Text = "s/n: " + _currentDirective.Threshold.FirstPerformanceSinceNew;
                        //labelAircraftTsnCsnNext.Text = "s/n: " + currentDirective.Threshold.SinceNew.ToString();
                    }


                    if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                        !_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                    {
                        //если наработка исчисляется с эффективной даты

                        //Определение даты исполнения
                        if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.Days != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            if (labelDateNext.Text != "n/a")
                            {
                                labelDateNext.Text += " or ";
                            }
                            else
                            {
                                labelDateNext.Text = "";
                            }


                            labelDateNext.Text +=
                                Convert.GetDateFormat(
                                    _currentDirective.Threshold.EffectiveDate.AddCalendarSpan(
                                        _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.CalendarSpan)) + " s/e.d.";
                        }
                        else
                        {
                            //иначе, дату определить нельзя
                            if (labelDateNext.Text == "")
                            {
                                labelDateNext.Text = "n/a";
                            }
                        }


                        //Определение наработки
                        if (_currentDirective.Threshold.EffectiveDate < DateTime.Today)
                        {
                            Lifelength sinceEffDate =
                                GlobalObjects.CasEnvironment.Calculator.
                                GetFlightLifelengthOnEndOfDay(inspectedComponent, _currentDirective.Threshold.EffectiveDate);
                            sinceEffDate.Add(_currentDirective.Threshold.EffectiveDate, _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate);
                            sinceEffDate.Resemble(_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate);

                            if (labelComponentTsnCsnNext.Text != "n/a")
                            {
                                labelComponentTsnCsnNext.Text += " or ";
                            }
                            else
                            {
                                labelComponentTsnCsnNext.Text = "";
                            }
                            labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate;
                        }
                    }
                }
                else
                {
                    if (_currentDirective.Threshold.PerformRepeatedly &&
                        _currentDirective.Threshold.RepeatInterval != null)
                    {
                        //повторяющаяся директива
                        //если есть последнне выполнение, то следующая дата расчитывается
                        //по повторяющемуся интервалу
                        if (_currentDirective.Threshold.RepeatInterval.CalendarValue != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            labelDateNext.Text =
                                Convert.GetDateFormat(
                                    _currentDirective.LastPerformance.RecordDate.AddCalendarSpan(
                                        _currentDirective.Threshold.RepeatInterval.CalendarSpan));
                            labelDateNext.Text =
                                Convert.GetDateFormat(_currentDirective.NextPerformance.PerformanceDate.Value);
                        }
                        else
                        {
                            //иначе, точную дату выполнения расчитать нельзя
                            labelDateNext.Text            = "n/a";
                            labelComponentTsnCsnNext.Text = "n/a";
                        }

                        //Определение наработки
                        if (!_currentDirective.Threshold.RepeatInterval.IsNullOrZero())
                        {
                            Lifelength nextTsnCsn;
                            if (!_currentDirective.LastPerformance.OnLifelength.IsNullOrZero())
                            {
                                nextTsnCsn = new Lifelength(_currentDirective.LastPerformance.OnLifelength);
                            }
                            else
                            {
                                nextTsnCsn = _currentDirective.LastPerformance.OnLifelength;
                            }

                            Lifelength nextAircraftTsnCsn =
                                GlobalObjects.CasEnvironment.Calculator.
                                GetFlightLifelengthOnStartOfDay(inspectedComponent, _currentDirective.LastPerformance.RecordDate);

                            nextTsnCsn.Add(_currentDirective.LastPerformance.RecordDate, _currentDirective.Threshold.RepeatInterval);
                            nextTsnCsn.Resemble(_currentDirective.Threshold.RepeatInterval);
                            //labelComponentTsnCsnNext.Text = nextTsnCsn.ToString();
                            labelComponentTsnCsnNext.Text = _currentDirective.NextPerformance.PerformanceSource.ToString();

                            nextAircraftTsnCsn.Add(_currentDirective.LastPerformance.RecordDate, _currentDirective.Threshold.RepeatInterval);
                            nextAircraftTsnCsn.Resemble(_currentDirective.Threshold.RepeatInterval);
                            //labelAircraftTsnCsnNext.Text = nextAircraftTsnCsn.ToString();
                            labelAircraftTsnCsnNext.Text = _currentDirective.NextPerformance.PerformanceSource.ToString();

                            if (labelComponentTsnCsnNext.Text == "")
                            {
                                labelComponentTsnCsnNext.Text = "n/a";
                            }
                            if (labelAircraftTsnCsnNext.Text == "")
                            {
                                labelAircraftTsnCsnNext.Text = "n/a";
                            }
                        }
                        else
                        {
                            labelComponentTsnCsnNext.Text = "n/a";
                        }
                    }
                }
                #endregion
            }
            else
            {
                #region  асчет при наличии привязанных задач

                labelDateLast.Text            = "";
                labelAircraftTsnCsnLast.Text  = "";
                labelNextCompliance.Text      = "First Limitter";
                labelDateNext.Text            = "n/a";
                labelAircraftTsnCsnNext.Text  = "n/a";
                labelComponentTsnCsnNext.Text = "n/a";
                labelRemainsValue.Text        = "";
                //labelRemarksValue.Text = "";

                var firstLimitters   = new List <NextPerformance>();
                var lastPerformances = new List <DirectiveRecord>();

                foreach (var bdd in bindedItems)
                {
                    if (bdd is ComponentDirective)
                    {
                        var componentDirective = (ComponentDirective)bdd;
                        GlobalObjects.PerformanceCalculator.GetNextPerformance(componentDirective);

                        if (componentDirective.NextPerformances.Count > 0)
                        {
                            firstLimitters.Add(componentDirective.NextPerformances[0]);
                        }
                        if (componentDirective.LastPerformance != null)
                        {
                            lastPerformances.Add(componentDirective.LastPerformance);
                        }
                    }
                }

                var firstLimitter   = firstLimitters.OrderBy(np => np.PerformanceDate).FirstOrDefault();
                var lastPerformance = lastPerformances.OrderByDescending(p => p.RecordDate).FirstOrDefault() ??
                                      _currentDirective.LastPerformance;
                IDirective parentOfFirstLimitter = firstLimitter != null
                    ? firstLimitter.Parent
                    : lastPerformance != null ? lastPerformance.Parent : _currentDirective;

                if (firstLimitter != null && firstLimitter.Remains != null && firstLimitter.Condition != ConditionState.NotEstimated)
                {
                    if (firstLimitter.Remains.IsOverdue() && firstLimitter.Condition == ConditionState.Overdue)
                    {
                        labelRemains.Text           = "Overdue:";
                        imageLinkLabelStatus.Status = Statuses.NotSatisfactory;
                    }
                    else if (firstLimitter.Condition == ConditionState.Notify)
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.Notify;
                    }
                    else if (firstLimitter.Condition == ConditionState.Satisfactory)
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.Satisfactory;
                    }
                    else
                    {
                        labelRemains.Text           = "Remains:";
                        imageLinkLabelStatus.Status = Statuses.NotActive;
                    }
                    ComponentDirective componentDirective = (ComponentDirective)firstLimitter.Parent;
                    labelRemainsValue.Text    = firstLimitter.Remains.ToString();
                    imageLinkLabelStatus.Text = componentDirective.DirectiveType.ToString();
                    labelCostValue.Text       = componentDirective.Cost.ToString();
                    labelManHoursValue.Text   = componentDirective.ManHours.ToString();
                    labelKitValue.Text        = componentDirective.Kits.Count == 0 ? "N" : componentDirective.Kits.Count + "Kits";
                    labelNDTvalue.Text        = _currentDirective.NDTType.ShortName;
                    //labelRemarksValue.Text = componentDirective.Remarks;
                }
                else
                {
                    imageLinkLabelStatus.Text = _currentDirective.WorkType.ToString();
                    labelCostValue.Text       = _currentDirective.Cost.ToString();
                    labelManHoursValue.Text   = _currentDirective.ManHours.ToString();
                    labelKitValue.Text        = _currentDirective.Kits.Count == 0 ? "N" : _currentDirective.Kits.Count + "Kits";
                    labelNDTvalue.Text        = _currentDirective.NDTType.ShortName;
                    // labelRemarksValue.Text = _currentDirective.Remarks;
                }

                //labelHiddenRemarksValue.Text = "";
                //if (labelHiddenRemarksValue.Text == "")
                //    labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false;

                if (lastPerformance != null)
                {
                    labelDateLast.Text = Convert.GetDateFormat(lastPerformance.RecordDate);

                    if (!lastPerformance.OnLifelength.IsNullOrZero())
                    {
                        labelComponentTsnCsnLast.Text = lastPerformance.OnLifelength.ToString();
                    }
                    else
                    {
                        labelComponentTsnCsnLast.Text = lastPerformance.OnLifelength.ToString();
                    }
                    //TODO:(Evgenii Babak)Тип inspectedDetail всегда будет Frame. При перерасчете будет проверен тип базового агрегата и если он равен Frame,
                    //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС
                    labelAircraftTsnCsnLast.Text =
                        GlobalObjects.CasEnvironment.Calculator.
                        GetFlightLifelengthOnStartOfDay(inspectedComponent, lastPerformance.RecordDate).ToString();
                }

                ///////////////////////////////////////////////////////////////////////////////////////////////
                labelFirstPerformanceValue.Text = "n/a";
                labelRptIntervalValue.Text      = "n/a";

                if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew != null &&
                    !parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    labelFirstPerformanceValue.Text = "s/n: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew;
                }

                if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (labelFirstPerformanceValue.Text != "n/a")
                    {
                        labelFirstPerformanceValue.Text += " or ";
                    }
                    else
                    {
                        labelFirstPerformanceValue.Text = "";
                    }
                    labelFirstPerformanceValue.Text += "s/e.d: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                if (parentOfFirstLimitter.Threshold.RepeatInterval != null)
                {
                    labelRptIntervalValue.Text = parentOfFirstLimitter.Threshold.RepeatInterval.IsNullOrZero()
                                                     ? "n/a"
                                                     : parentOfFirstLimitter.Threshold.RepeatInterval.ToString();
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////
                if (parentOfFirstLimitter.IsClosed)
                {
                    return;                                //если директива принудительно закрыта пользователем
                }
                //то вычисление следующего выполнения не нужно


                labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a";
                if (parentOfFirstLimitter.LastPerformance == null)
                {
                    if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew != null &&
                        !parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                    {
                        //если наработка исчисляется с момента выпуска
                        if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.CalendarValue != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            labelDateNext.Text =
                                Convert.GetDateFormat(inspectedComponent.ManufactureDate.
                                                      AddCalendarSpan(parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.CalendarSpan)) +
                                " s/n";
                        }
                        else
                        {
                            //иначе, если (дополнительно) дата не определена
                            labelDateNext.Text = "n/a";
                        }
                        labelComponentTsnCsnNext.Text = "s/n: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew;
                    }

                    if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                        !parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                    {
                        //если наработка исчисляется с эффективной даты

                        //Определение даты исполнения
                        if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.Days != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            if (labelDateNext.Text != "n/a")
                            {
                                labelDateNext.Text += " or ";
                            }
                            else
                            {
                                labelDateNext.Text = "";
                            }


                            labelDateNext.Text +=
                                Convert.GetDateFormat(parentOfFirstLimitter.Threshold.EffectiveDate.AddCalendarSpan(
                                                          parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.CalendarSpan)) + " s/e.d.";
                        }
                        else
                        {
                            //иначе, дату определить нельзя
                            if (labelDateNext.Text == "")
                            {
                                labelDateNext.Text = "n/a";
                            }
                        }
                        //Определение наработки
                        if (parentOfFirstLimitter.Threshold.EffectiveDate < DateTime.Today)
                        {
                            Lifelength sinceEffDate =
                                GlobalObjects.CasEnvironment.Calculator.
                                GetFlightLifelengthOnEndOfDay(inspectedComponent, parentOfFirstLimitter.Threshold.EffectiveDate);
                            sinceEffDate.Add(parentOfFirstLimitter.Threshold.EffectiveDate, parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate);
                            sinceEffDate.Resemble(parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate);

                            if (labelComponentTsnCsnNext.Text != "n/a")
                            {
                                labelComponentTsnCsnNext.Text += " or ";
                            }
                            else
                            {
                                labelComponentTsnCsnNext.Text = "";
                            }
                            labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate;
                        }
                    }
                }
                else
                {
                    if (firstLimitter != null)
                    {
                        //повторяющаяся директива
                        //если есть последнне выполнение, то следующая дата расчитывается
                        //по повторяющемуся интервалу
                        if (parentOfFirstLimitter.Threshold.RepeatInterval.CalendarValue != null &&
                            firstLimitter.PerformanceDate != null)
                        {
                            //если в первом выполнении заданы дни
                            //то выводится точная дата следующего выполнения
                            labelDateNext.Text = Convert.GetDateFormat(firstLimitter.PerformanceDate.Value);
                        }
                        else
                        {
                            //иначе, точную дату выполнения расчитать нельзя
                            labelDateNext.Text            = "n/a";
                            labelComponentTsnCsnNext.Text = "n/a";
                        }

                        //Определение наработки
                        if (!parentOfFirstLimitter.Threshold.RepeatInterval.IsNullOrZero() &&
                            !firstLimitter.PerformanceSource.IsNullOrZero())
                        {
                            labelComponentTsnCsnNext.Text = firstLimitter.PerformanceSource.ToString();

                            //TODO:(Evgenii Babak)Тип inspectedDetail всегда будет Frame. При перерасчете будет проверен тип базового агрегата и если он равен Frame,
                            //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС
                            Lifelength nextAircraftTsnCsn =
                                GlobalObjects.CasEnvironment.Calculator.
                                GetFlightLifelengthOnStartOfDay(inspectedComponent, lastPerformance.RecordDate);

                            nextAircraftTsnCsn.Add(lastPerformance.RecordDate, parentOfFirstLimitter.Threshold.RepeatInterval);
                            nextAircraftTsnCsn.Resemble(parentOfFirstLimitter.Threshold.RepeatInterval);
                            labelAircraftTsnCsnNext.Text = nextAircraftTsnCsn.ToString();

                            if (labelComponentTsnCsnNext.Text == "")
                            {
                                labelComponentTsnCsnNext.Text = "n/a";
                            }
                            if (labelAircraftTsnCsnNext.Text == "")
                            {
                                labelAircraftTsnCsnNext.Text = "n/a";
                            }
                        }
                        else
                        {
                            labelComponentTsnCsnNext.Text = "n/a";
                        }
                    }
                }
                #endregion
            }
        }
Exemplo n.º 8
0
        protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item)
        {
            var subItems = new List <CustomCell>();
            var author   = GlobalObjects.CasEnvironment.GetCorrector(item);

            AtaChapter ata;
            MaintenanceControlProcess maintenanceType;
            DateTime   transferDate;
            DateTime?  lastPerformanceDate = null;
            DateTime?  nextEstimated       = null;
            DateTime?  nextLimit           = null;
            Lifelength firstPerformance    = Lifelength.Null,
                       lastPerformance     = Lifelength.Null,
                       lastPerformanceC    = Lifelength.Null,
                       expiryRemain        = Lifelength.Null,
                       nextEstimatedData   = Lifelength.Null,
                       nextEstimatedDataC  = Lifelength.Null,
                       remainEstimated     = Lifelength.Null,
                       nextLimitData       = Lifelength.Null,
                       nextLimitDataC      = Lifelength.Null,
                       remainLimit         = Lifelength.Null,
                       remainLimitC        = Lifelength.Null,
                       IDD = Lifelength.Null,
                       IDDC = Lifelength.Null,
                       warranty, repeatInterval = Lifelength.Null;
            string partNumber,
                   description,
                   serialNumber,
                   position,
                   mpdString             = "",
                   mpdNumString          = "",
                   lastPerformanceString = "",
                   type        = getGroupName(item),
                   classString = "",
                   kitRequieredString,
                   remarks,
                   hiddenRemarks,
                   workType        = "",
                   zone            = "",
                   ad              = "",
                   access          = "",
                   expiryDate      = "",
                   condition       = "",
                   conditionRepeat = "",
                   ndtString       = "";
            double manHours,
                   cost,
                   costServiceable = 0,
                   costOverhaul    = 0;
            bool isRVSM            = false,
                 isETOPS           = false;

            if (item is Component)
            {
                Component componentItem = (Component)item;

                if (componentItem.LLPCategories)
                {
                    nextEstimated      = componentItem.NextPerformance?.PerformanceDate;
                    nextEstimatedData  = componentItem.NextPerformance?.PerformanceSource;
                    nextEstimatedDataC = componentItem.NextPerformance?.PerformanceSourceC;
                    remainEstimated    = componentItem.NextPerformance?.Remains;

                    nextLimit      = componentItem.NextPerformance?.NextPerformanceDateNew;
                    nextLimitData  = componentItem.NextPerformance?.NextLimit;
                    nextLimitDataC = componentItem.NextPerformance?.NextLimitC;
                    remainLimit    = componentItem.NextPerformance?.RemainLimit;
                    remainLimitC   = componentItem.NextPerformance?.RemainLimitC;

                    IDD  = componentItem.NextPerformance?.IDD;
                    IDDC = componentItem.NextPerformance?.IDDC;
                }


                ata              = componentItem.Model != null ? componentItem.Model.ATAChapter : componentItem.ATAChapter;
                partNumber       = componentItem.PartNumber;
                description      = componentItem.Model != null ? componentItem.Model.Description : componentItem.Description;
                serialNumber     = componentItem.SerialNumber;
                position         = componentItem.TransferRecords.GetLast().Position.ToUpper();
                maintenanceType  = componentItem.MaintenanceControlProcess;
                transferDate     = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance = componentItem.LifeLimit;
                warranty         = componentItem.Warranty;
                classString      = componentItem.GoodsClass != null?componentItem.GoodsClass.ToString() : "";

                kitRequieredString = componentItem.Kits.Count + " kits";
                manHours           = componentItem.ManHours;
                cost            = componentItem.Cost;
                costOverhaul    = componentItem.CostOverhaul;
                costServiceable = componentItem.CostServiceable;
                remarks         = componentItem.Remarks;
                hiddenRemarks   = componentItem.HiddenRemarks;
                isRVSM          = componentItem.IsRVSM;
                isETOPS         = componentItem.IsETOPS;
                expiryDate      = " ";
                expiryRemain    = Lifelength.Null;
                condition       = !firstPerformance.IsNullOrZero() ? (componentItem.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
                conditionRepeat = !componentItem.Threshold.RepeatInterval.IsNullOrZero() ? (componentItem.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
            }
            else
            {
                ComponentDirective dd = (ComponentDirective)item;
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }

                if (dd.LastPerformance != null)
                {
                    lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate);
                    lastPerformance       = dd.LastPerformance?.OnLifelength;
                    lastPerformanceC      = dd.NextPerformance?.LastDataC;
                    lastPerformanceDate   = dd.LastPerformance?.RecordDate;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                nextEstimated      = dd.NextPerformance?.PerformanceDate;
                nextEstimatedData  = dd.NextPerformance?.PerformanceSource;
                nextEstimatedDataC = dd.NextPerformance?.PerformanceSourceC;
                remainEstimated    = dd.NextPerformance?.Remains;

                nextLimit      = dd.NextPerformance?.NextPerformanceDateNew;
                nextLimitData  = dd.NextPerformance?.NextLimit;
                nextLimitDataC = dd.NextPerformance?.NextLimitC;
                remainLimit    = dd.NextPerformance?.RemainLimit;
                remainLimitC   = dd.NextPerformance?.RemainLimitC;


                IDD  = dd.NextPerformance?.IDD;
                IDDC = dd.NextPerformance?.IDDC;

                ata        = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.ATAChapter : dd.ParentComponent.ATAChapter;
                partNumber = "    " + dd.PartNumber;
                var desc = dd.ParentComponent.Model != null
                                        ? dd.ParentComponent.Model.Description
                                        : dd.ParentComponent.Description;

                description     = "    " + desc;
                serialNumber    = "    " + dd.SerialNumber;
                position        = "    " + dd.ParentComponent.TransferRecords.GetLast().Position.ToUpper();
                transferDate    = dd.ParentComponent.TransferRecords.GetLast().TransferDate;
                maintenanceType = dd.ParentComponent.MaintenanceControlProcess;
                warranty        = dd.Threshold.Warranty;
                classString     = dd.ParentComponent.GoodsClass != null?dd.ParentComponent.GoodsClass.ToString() : "";

                kitRequieredString = dd.Kits.Count + " kits";
                manHours           = dd.ManHours;
                cost          = dd.Cost;
                zone          = dd.ZoneArea;
                access        = dd.AccessDirective;
                remarks       = dd.Remarks;
                hiddenRemarks = dd.HiddenRemarks;
                workType      = dd.DirectiveType.ToString();
                ndtString     = dd.NDTType.ShortName;
                isRVSM        = dd.ParentComponent.IsRVSM;
                isETOPS       = dd.ParentComponent.IsETOPS;
                condition     = !firstPerformance.IsNullOrZero() ? (dd.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
                conditionRepeat = !dd.Threshold.RepeatInterval.IsNullOrZero() ? (dd.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";

                ad = dd.LinkAd;

                if (dd.IsExpiry)
                {
                    expiryDate   = dd.IsExpiry ? (dd.ExpiryDate.HasValue ? SmartCore.Auxiliary.Convert.GetDateFormat(dd.ExpiryDate.Value) : "") : "";
                    expiryRemain = dd.IsExpiry ? new Lifelength((int)(dd.ExpiryDate.Value - DateTime.Today).TotalDays, 0, 0) : Lifelength.Null;
                }

                if (dd.MaintenanceDirective != null)
                {
                    mpdString    = dd.MaintenanceDirective.TaskNumberCheck;
                    mpdNumString = dd.MaintenanceDirective.TaskCardNumber;
                }
            }
            if (ShowGroup)
            {
                subItems.Add(CreateRow(type, type));
            }
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(mpdString, mpdString));
            subItems.Add(CreateRow(mpdNumString, mpdNumString));
            subItems.Add(CreateRow(position, position));
            subItems.Add(CreateRow(maintenanceType.ShortName, maintenanceType));
            subItems.Add(CreateRow(zone, zone));
            subItems.Add(CreateRow(access, access));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(IDD?.ToString(), IDD));
            subItems.Add(CreateRow(IDDC?.ToString(), IDDC));
            subItems.Add(CreateRow($"{firstPerformance} {condition}", firstPerformance));
            subItems.Add(CreateRow($"{repeatInterval} {conditionRepeat}", repeatInterval));


            subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(nextEstimated), nextEstimated));
            subItems.Add(CreateRow(nextEstimatedData?.ToString(), nextEstimatedData));
            subItems.Add(CreateRow(nextEstimatedDataC?.ToString(), nextEstimatedDataC));
            subItems.Add(CreateRow(remainEstimated?.ToString(), remainEstimated));
            subItems.Add(CreateRow(nextLimitData?.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(nextLimit) : "", nextLimit));
            subItems.Add(CreateRow(nextLimitData?.ToString(), nextLimitData));
            subItems.Add(CreateRow(nextLimitDataC?.ToString(), nextLimitDataC));
            subItems.Add(CreateRow(remainLimit?.ToString(), remainLimit));
            subItems.Add(CreateRow(remainLimitC?.ToString(), remainLimitC));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformanceDate));
            subItems.Add(CreateRow(lastPerformanceC?.ToString(), lastPerformanceC));
            subItems.Add(CreateRow(lastPerformance?.ToString(), lastPerformance));


            subItems.Add(CreateRow(expiryDate, expiryDate));
            subItems.Add(CreateRow(!expiryRemain.IsNullOrZero() ? $"{expiryRemain?.Days}d" : "", expiryRemain));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(isRVSM ? "Yes" : "No", isRVSM));
            subItems.Add(CreateRow(isETOPS ? "Yes" : "No", isETOPS));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(cost.ToString(), cost));
            subItems.Add(CreateRow(costOverhaul.ToString(), costOverhaul));
            subItems.Add(CreateRow(costServiceable.ToString(), costServiceable));
            subItems.Add(CreateRow(ad, ad));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Добавляет элементы в ListView
        /// </summary>
        /// <param name="itemsArray"></param>
        //protected override void AddItems(IBaseCoreObject[] itemsArray)
        //{
        //    ColumnHeader ch = ColumnHeaderList.FirstOrDefault(h => h.Text == "Performances");
        //    if (ch == null)
        //    {
        //        base.AddItems(itemsArray);
        //        return;
        //    }

        //    if(itemsArray == null || itemsArray.Length == 0)
        //    {
        //        ch.Width = 0;
        //        base.AddItems(itemsArray);
        //        return;
        //    }
        //    ch.Width = itemsArray.OfType<IDirective>()
        //                         .Count(d => d.NextPerformances != null && d.NextPerformances.Count > 1) > 0 ? 100 : 0;

        //    base.AddItems(itemsArray);
        //}

        #endregion

        #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(IBaseCoreObject item)

        protected override List <CustomCell> GetListViewSubItems(IBaseEntityObject item)
        {
            var subItems = new List <CustomCell>();

            DateTime?  approx = null;
            AtaChapter ata;
            string     maintenanceTypeString = "";
            DateTime   transferDate = DateTimeExtend.GetCASMinDateTime();
            bool       isPool = false, IsDangerous = false;
            Lifelength firstPerformance = Lifelength.Null,
                       lastPerformance  = Lifelength.Null,
                       remains = null,
                       next = null,
                       warranty = Lifelength.Null, warrantyRemain = Lifelength.Null, repeatInterval = Lifelength.Null;
            string partNumber            = "",
                   description           = "",
                   altPartNumber         = "",
                   standart              = "",
                   name                  = "",
                   refference            = "",
                   effectivity           = "",
                   serialNumber          = "",
                   code                  = "",
                   classString           = "",
                   batchNumber           = "",
                   idNumber              = "",
                   supplier              = "";
            string status                = "",
                   location              = "",
                   facility              = "",
                   lastPerformanceString = "",
                   kitRequieredString    = "",
                   remarks               = "",
                   hiddenRemarks         = "",
                   workType              = "",
                   timesString,
                   quantityString        = "",
                   currentString         = "",
                   shouldBeOnStockString = "",
                   from = "",
                   id = "",
                   quantityInString = "",
                   author = "",
                   currency = "";
            double manHours = 0,
                   unitPrice = 0,
                   totalPrice = 0,
                   shipPrice = 0,
                   subTotal = 0,
                   tax1 = 0,
                   tax2 = 0,
                   tax3 = 0,
                   total = 0,
                   quantity = 0,
                   current = 0,
                   quantityIn = 0,
                   shouldBeOnStock = 0, needWpQuantity = 0, reserve = 0;
            int times,

                kitCount        = 0;
            string     position = ComponentStorePosition.UNK.ToString();
            IDirective parent;

            if (item is NextPerformance)
            {
                NextPerformance np = (NextPerformance)item;
                parent = np.Parent;

                int index = np.Parent.NextPerformances.IndexOf(np);
                timesString = index == 0 ? np.Parent.TimesToString : "#" + (index + 1);
                times       = index == 0 ? np.Parent.Times : index + 1;
            }
            else
            {
                parent = item as IDirective;
                if (parent == null)
                {
                    return(subItems);
                }
                timesString = parent.TimesToString;
                times       = parent.Times;
            }

            if (parent is Component)
            {
                Component componentItem = (Component)parent;
                id                    = componentItem.ItemId.ToString();
                author                = GlobalObjects.CasEnvironment.GetCorrector(componentItem);
                approx                = componentItem.NextPerformanceDate;
                next                  = componentItem.NextPerformanceSource;
                remains               = componentItem.Remains;
                ata                   = componentItem.Product?.ATAChapter ?? componentItem.ATAChapter;
                partNumber            = componentItem.Product?.PartNumber ?? componentItem.PartNumber;
                altPartNumber         = componentItem.Product?.AltPartNumber ?? componentItem.ALTPartNumber;
                standart              = componentItem.Product?.Standart?.ToString() ?? componentItem.Standart?.ToString();
                refference            = componentItem.Product?.Reference;
                effectivity           = componentItem.Product?.IsEffectivity;
                name                  = componentItem.Product?.Name;
                description           = componentItem.Description;
                serialNumber          = componentItem.SerialNumber;
                code                  = componentItem.Product != null ? componentItem.Product.Code :componentItem.Code;
                classString           = componentItem.GoodsClass.ToString();
                batchNumber           = componentItem.BatchNumber;
                idNumber              = componentItem.IdNumber;
                position              = componentItem.TransferRecords.GetLast()?.State?.ToString();
                status                = componentItem.ComponentStatus.ToString();
                location              = componentItem.Location.ToString();
                facility              = componentItem.Location.LocationsType?.ToString() ?? LocationsType.Unknown.ToString();
                maintenanceTypeString =
                    componentItem.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts)
                                                ? componentItem.MaintenanceControlProcess.ShortName
                                                : componentItem.LifeLimit.IsNullOrZero()
                                                        ? ""
                                                        : MaintenanceControlProcess.HT.ShortName;
                transferDate       = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance   = componentItem.LifeLimit;
                warranty           = componentItem.Warranty;
                warrantyRemain     = componentItem.NextPerformance?.WarrantlyRemains ?? Lifelength.Null;
                kitRequieredString = componentItem.Kits.Count > 0 ? componentItem.Kits.Count + " kits" : "";
                kitCount           = componentItem.Kits.Count;
                bool isComponent =
                    componentItem.GoodsClass.IsNodeOrSubNodeOf(new IDictionaryTreeItem[]
                {
                    GoodsClass.ComponentsAndParts,
                    GoodsClass.ProductionAuxiliaryEquipment,
                });

                quantity              = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.Quantity;
                quantityString        = quantity.ToString();
                quantityIn            = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.QuantityIn;
                quantityInString      = $"{quantityIn:0.##}" + (componentItem.Measure != null ? " " + componentItem.Measure + "(s)" : "") + componentItem.Packing;
                needWpQuantity        = Math.Round(componentItem.NeedWpQuantity, 2);
                reserve               = quantity - needWpQuantity;
                shouldBeOnStock       = componentItem.ShouldBeOnStock;
                shouldBeOnStockString = componentItem.ShouldBeOnStock > 0 ? "Yes" : "No";
                manHours              = componentItem.ManHours;
                remarks               = componentItem.Remarks;
                hiddenRemarks         = componentItem.HiddenRemarks;
                isPool      = componentItem.IsPOOL;
                IsDangerous = componentItem.IsDangerous;
                supplier    = componentItem.FromSupplier.ToString();

                if (componentItem.ProductCosts.Count > 0)
                {
                    var productost = componentItem.ProductCosts.FirstOrDefault();
                    unitPrice  = productost.UnitPrice;
                    totalPrice = productost.TotalPrice;
                    shipPrice  = productost.ShipPrice;
                    subTotal   = productost.SubTotal;
                    tax1       = productost.Tax;
                    tax2       = productost.Tax1;
                    tax3       = productost.Tax2;
                    total      = productost.Total;
                    currency   = productost.Currency.ToString();
                }


                TransferRecord tr = componentItem.TransferRecords.GetLast();
                if (tr.FromAircraftId == 0 &&
                    tr.FromBaseComponentId == 0 &&
                    tr.FromStoreId == 0 &&
                    tr.FromSupplierId == 0 &&
                    tr.FromSpecialistId == 0)
                {
                    from = componentItem.Suppliers.ToString();
                }
                else
                {
                    from = DestinationHelper.FromObjectString(tr);
                }
            }
            else if (parent is ComponentDirective)
            {
                ComponentDirective dd = (ComponentDirective)parent;
                author = GlobalObjects.CasEnvironment.GetCorrector(dd);
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }
                if (dd.LastPerformance != null)
                {
                    lastPerformanceString =
                        SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " +
                        dd.LastPerformance.OnLifelength;
                    lastPerformance = dd.LastPerformance.OnLifelength;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                approx  = dd.NextPerformanceDate;
                next    = dd.NextPerformanceSource;
                remains = dd.Remains;
                ata     = dd.ParentComponent.Product?.ATAChapter ?? dd.ParentComponent.ATAChapter;
                maintenanceTypeString = dd.ParentComponent.MaintenanceControlProcess.ShortName;
                warranty           = dd.Threshold.Warranty;
                kitRequieredString = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "";
                kitCount           = dd.Kits.Count;
                manHours           = dd.ManHours;
                remarks            = dd.Remarks;
                hiddenRemarks      = dd.HiddenRemarks;
                workType           = dd.DirectiveType.ToString();
                position           = "    " + dd.ParentComponent.TransferRecords.GetLast()?.State?.ToString();
                isPool             = dd.IsPOOL;
                IsDangerous        = dd.IsDangerous;
                partNumber         = "    " + (dd.ParentComponent.Product?.PartNumber ?? dd.ParentComponent.PartNumber);
                altPartNumber      = "    " + (dd.ParentComponent.Product?.AltPartNumber ?? dd.ParentComponent.ALTPartNumber);
                standart           = dd.ParentComponent.Product?.Standart?.ToString() ?? dd.ParentComponent.Standart?.ToString();
                name           = "    " + dd.ParentComponent.Product?.Name;
                description    = "    " + dd.ParentComponent.Description;
                serialNumber   = "    " + dd.ParentComponent.SerialNumber;
                classString    = dd.ParentComponent.GoodsClass.ToString();
                warrantyRemain = dd.NextPerformance?.WarrantlyRemains ?? Lifelength.Null;
            }
            else
            {
                ata = (AtaChapter)GlobalObjects.CasEnvironment.GetDictionary <AtaChapter>().GetItemById(21);
            }

            subItems.Add(CreateRow(id, id));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(refference, refference));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(altPartNumber, altPartNumber));
            subItems.Add(CreateRow(standart, standart));
            subItems.Add(CreateRow(name, name));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(batchNumber, batchNumber));
            subItems.Add(CreateRow(idNumber, idNumber));
            subItems.Add(CreateRow(position.ToUpper(), position));
            subItems.Add(CreateRow(status, status));
            subItems.Add(CreateRow(location, location));
            subItems.Add(CreateRow(facility, facility));
            subItems.Add(CreateRow(from, from));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(needWpQuantity.ToString(), needWpQuantity));
            subItems.Add(CreateRow(reserve.ToString(), reserve));
            subItems.Add(CreateRow(quantityString, quantity));
            subItems.Add(CreateRow(shouldBeOnStockString, shouldBeOnStock));
            subItems.Add(CreateRow(quantityInString, quantityIn));
            subItems.Add(CreateRow(unitPrice.ToString(), unitPrice));
            subItems.Add(CreateRow(totalPrice.ToString(), totalPrice));
            subItems.Add(CreateRow(shipPrice.ToString(), shipPrice));
            subItems.Add(CreateRow(subTotal.ToString(), subTotal));
            subItems.Add(CreateRow(tax1.ToString(), tax1));
            subItems.Add(CreateRow(tax2.ToString(), tax2));
            subItems.Add(CreateRow(tax3.ToString(), tax3));
            subItems.Add(CreateRow(total.ToString(), total));
            subItems.Add(CreateRow(currency, currency));
            subItems.Add(CreateRow(supplier, supplier));
            subItems.Add(CreateRow(code, code));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(effectivity, effectivity));
            subItems.Add(CreateRow(isPool ? "Yes" : "No", isPool));
            subItems.Add(CreateRow(IsDangerous ? "Yes" : "No", IsDangerous));
            subItems.Add(CreateRow(maintenanceTypeString, maintenanceTypeString));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(firstPerformance.ToString(), firstPerformance));
            subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval));
            subItems.Add(CreateRow(timesString, times));
            subItems.Add(CreateRow(approx != null
                                ? SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next
                                : next != null && !next.IsNullOrZero()
                                        ? next.ToString()
                                        : "", approx == null ? DateTimeExtend.GetCASMinDateTime() : (DateTime)approx));
            subItems.Add(CreateRow(remains != null && !remains.IsNullOrZero()
                                ? remains.ToString()
                                : "", remains ?? Lifelength.Null));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformance));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(warrantyRemain.ToString(), warrantyRemain));
            subItems.Add(CreateRow(kitRequieredString, kitCount));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Exemplo n.º 10
0
        private void FindNextCheck()
        {
            //вычисление самого последнего выполненного чека, вне зависимости от типа
            //последний выполненый чек по типу может нессответствовать текущему типу программы
            //в случае переключения
            MaintenanceCheck lastComplianceCheck = CheckItems.Where(c => c.LastPerformance != null).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault();

            if (lastComplianceCheck != null && lastComplianceCheck.Schedule != Schedule && Schedule)
            {
                //тип программмы Maintenance был переключен, переключение с Unschedule на Schedule
                //вычисление самого последнего выполненного чека, заданного типа
                MaintenanceCheck lastComplianceScheduleTypeCheck =
                    CheckItems.Where(c => c.LastPerformance != null && c.Schedule == Schedule).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault();

                MaintenanceCheckGroupByType group = new List <MaintenanceCheck>(CheckItems).GetNextCheckBySourceDifference(lastComplianceScheduleTypeCheck, TsnCsn.Days);
                //название чеков
                MaintenanceCheck maxIntervalCheckInGroup = group.GetMaxIntervalCheck();
                string           tNext = maxIntervalCheckInGroup.Name + " (";
                tNext += group.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " "));
                tNext += ") ";
                string tNextDate = UsefulMethods.NormalizeDate(group.GroupComplianceDate);

                group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null;
                string tNextLl = group.GroupComplianceLifelength.ToRepeatIntervalsFormat();

                group.GroupComplianceLifelength.Substract(TsnCsn);
                group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null;
                string tRemainLl = Convert.ToInt32(group.GroupComplianceLifelength.Days).ToString();

                Action <string, string, string, string> addLast = AddNextCheckItem;
                if (InvokeRequired)
                {
                    Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                }
                else
                {
                    addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                }
            }
            else
            {
                if (_complianceGroupCollection == null)
                {
                    _complianceGroupCollection = CheckItems.GetNextComplianceCheckGroups(Schedule).OrderBy(GetNextComplianceDate);
                }

                foreach (MaintenanceCheckComplianceGroup complianceGroup in _complianceGroupCollection)
                {
                    string           tNext, tNextDate, tNextLl, tRemainLl;
                    MaintenanceCheck maxIntervalCheckInGroup;
                    if ((maxIntervalCheckInGroup = complianceGroup.GetMaxIntervalCheck()) == null)
                    {
                        continue;
                    }
                    complianceGroup.Sort();

                    string prefix = complianceGroup.GetGroupName();

                    if (complianceGroup.Grouping)
                    {
                        MaintenanceCheck lastOrMinCheck =
                            complianceGroup.GetLastComplianceChecks().FirstOrDefault() != null
                                ? complianceGroup.GetLastComplianceChecks().First()
                                : complianceGroup.GetMinIntervalCheck();


                        //дата следующего выполнения группы чеков
                        if (lastOrMinCheck.Interval.Days != null && lastOrMinCheck.Interval.Days > 0)
                        {
                            DateTime nextDate = lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].PerformanceDate != null
                                                    ? lastOrMinCheck.NextPerformances[0].PerformanceDate.Value
                                                    : lastOrMinCheck.LastPerformance != null
                                                          ? lastOrMinCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days))
                                                          : lastOrMinCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days));

                            tNextDate = UsefulMethods.NormalizeDate(nextDate);

                            if (lastOrMinCheck.NextPerformances.Count != 0 &&
                                lastOrMinCheck.NextPerformances[0].Remains != null)
                            {
                                //Остаток до выполнения
                                Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains;
                                tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString();
                            }
                            else
                            {
                                tRemainLl = " N/A ";
                            }
                        }
                        else
                        {
                            tNextDate = lastOrMinCheck.NextPerformances.Count != 0 &&
                                        lastOrMinCheck.NextPerformances[0].PerformanceDate != null
                                ? " approx. " + UsefulMethods.NormalizeDate(lastOrMinCheck.NextPerformances[0].PerformanceDate.Value)
                                : " N/A ";

                            if (lastOrMinCheck.NextPerformances.Count != 0 &&
                                lastOrMinCheck.NextPerformances[0].Remains != null)
                            {
                                //Остаток до выполнения
                                Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains;
                                tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString();
                            }
                            else
                            {
                                tRemainLl = " N/A ";
                            }
                        }
                        //ресурс, на котором надо поризвести выполнение
                        //след выполнение
                        Lifelength next =
                            lastOrMinCheck.NextPerformances.Count != 0
                                ? lastOrMinCheck.NextPerformances[0].PerformanceSource
                                : Lifelength.Null;
                        next.Resemble(maxIntervalCheckInGroup.Interval);
                        tNextLl = next.IsNullOrZero() ? "N/A" : next.ToString();
                        //название чеков
                        tNext = prefix;
                        if (lastOrMinCheck.ParentAircraft != null &&
                            lastOrMinCheck.ParentAircraft.MSG < MSG.MSG3)
                        {
                            tNext += " (";
                            tNext  = complianceGroup.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " "));
                            tNext += ") ";
                        }

                        Action <string, string, string, string> addLast = AddNextCheckItem;
                        if (InvokeRequired)
                        {
                            Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                        }
                        else
                        {
                            addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                        }
                    }
                    else
                    {
                        foreach (MaintenanceCheck maintenanceCheck in complianceGroup.Checks)
                        {
                            DateTime nextDate;
                            if (maintenanceCheck.Interval.Days != null && maintenanceCheck.Interval.Days > 0)
                            {
                                nextDate =
                                    maintenanceCheck.NextPerformances.Count != 0 && maintenanceCheck.NextPerformances[0].PerformanceDate != null
                                                    ? maintenanceCheck.NextPerformances[0].PerformanceDate.Value
                                                    : maintenanceCheck.LastPerformance != null
                                                          ? maintenanceCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days))
                                                          : maintenanceCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days));

                                tNextDate = "\n" + UsefulMethods.NormalizeDate(nextDate);

                                if (maintenanceCheck.NextPerformances.Count != 0 &&
                                    maintenanceCheck.NextPerformances[0].Remains != null)
                                {
                                    //Остаток до выполнения
                                    Lifelength remains = maintenanceCheck.NextPerformances[0].Remains;
                                    tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString());
                                }
                                else
                                {
                                    tRemainLl = "\n N/A ";
                                }
                            }
                            else
                            {
                                if (maintenanceCheck.NextPerformanceDate != null)
                                {
                                    nextDate  = maintenanceCheck.NextPerformanceDate.Value;
                                    tNextDate = "\n approx. " + UsefulMethods.NormalizeDate(nextDate);
                                }
                                else
                                {
                                    tNextDate = "\n (N/A) ";
                                }

                                if (maintenanceCheck.NextPerformances.Count != 0 &&
                                    maintenanceCheck.NextPerformances[0].Remains != null)
                                {
                                    //Остаток до выполнения
                                    Lifelength remains = maintenanceCheck.NextPerformances[0].Remains;
                                    tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString());
                                }
                                else
                                {
                                    tRemainLl = "\n (N/A) ";
                                }
                            }
                            //след выполнение
                            Lifelength next =
                                maintenanceCheck.NextPerformances.Count != 0
                                    ? maintenanceCheck.NextPerformances[0].PerformanceSource
                                    : Lifelength.Null;
                            tNextLl = "\n" + (next.IsNullOrZero() ? "N/A" : next.ToString());

                            //название чеков
                            tNext = "\n" + maintenanceCheck.Name + " ";

                            Action <string, string, string, string> addLast = AddNextCheckItem;
                            if (InvokeRequired)
                            {
                                Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                            }
                            else
                            {
                                addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseEntityObject item)
        {
            List <ListViewItem.ListViewSubItem> subItems = new List <ListViewItem.ListViewSubItem>();

            //if(item.ItemId == 41043)
            //{

            //}
            if (item is NextPerformance)
            {
                NextPerformance np = (NextPerformance)item;

                double manHours = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).ManHours : 0;
                double cost     = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).Cost : 0;

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.ATAChapter.ToString(), Tag = np.ATAChapter
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.Title, Tag = np.Title
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.Description, Tag = np.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.Type, Tag = np.Type
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.KitsToString, Tag = np.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.PerformanceSource.ToString(), Tag = np.PerformanceSource
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.Parent.Threshold.RepeatInterval.ToString(), Tag = np.Parent.Threshold.RepeatInterval
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.Remains.ToString(), Tag = np.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.WorkType, Tag = np.WorkType
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = np.PerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)np.PerformanceDate), Tag = np.PerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = manHours.ToString(), Tag = manHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = cost.ToString(), Tag = cost
                });
            }
            else if (item is AbstractPerformanceRecord)
            {
                AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item;
                Lifelength remains            = Lifelength.Null;

                double manHours = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).ManHours : 0;
                double cost     = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).Cost : 0;

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.ATAChapter.ToString(), Tag = apr.ATAChapter
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.Title, Tag = apr.Title
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.Description, Tag = apr.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.KitsToString, Tag = apr.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.OnLifelength.ToString(), Tag = apr.OnLifelength
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.Parent.Threshold.RepeatInterval.ToString(), Tag = apr.Parent.Threshold.RepeatInterval
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = remains.ToString(), Tag = remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = apr.WorkType, Tag = apr.WorkType
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = SmartCore.Auxiliary.Convert.GetDateFormat(apr.RecordDate), Tag = apr.RecordDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = manHours.ToString(), Tag = manHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = cost.ToString(), Tag = cost
                });
            }
            else if (item is Directive)
            {
                Directive     directive = (Directive)item;
                AtaChapter    ata       = directive.ATAChapter;
                DirectiveType pdType    = directive.DirectiveType;
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata.ToString(), Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = directive.Title, Tag = directive.Title
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = directive.Description, Tag = directive.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = pdType.ShortName, Tag = pdType.ShortName
                });

                #region Определение текста для колонки "КИТы"
                subItems.Add(new ListViewItem.ListViewSubItem
                {
                    Text = directive.Kits.Count > 0 ? directive.Kits.Count + " kits" : "",
                    Tag  = directive.Kits.Count
                });
                #endregion

                #region Определение текста для колонки "Первое выполнение"

                ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                if (directive.Threshold.FirstPerformanceSinceNew != null && !directive.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + directive.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = directive.Threshold.FirstPerformanceSinceNew;
                }
                if (directive.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !directive.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (subItem.Text != "")
                    {
                        subItem.Text += " or ";
                    }
                    else
                    {
                        subItem.Text = "";
                        subItem.Tag  = directive.Threshold.FirstPerformanceSinceEffectiveDate;
                    }
                    subItem.Text += "s/e.d: " + directive.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                subItems.Add(subItem);
                #endregion

                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new ListViewItem.ListViewSubItem();
                if (!directive.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = directive.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = directive.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion

                #region Определение текста для колонки "Остаток/Просрочено на сегодня"
                subItems.Add(new ListViewItem.ListViewSubItem
                {
                    Text = directive.Remains.ToString(),
                    Tag  = directive.Remains
                });
                #endregion

                #region Определение текста для колонки "Тип работ"

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = directive.WorkType.ToString(), Tag = directive.WorkType
                });
                #endregion

                #region Определение текста для колонки "Следующее выполнение"
                subItems.Add(new ListViewItem.ListViewSubItem
                {
                    Text = directive.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)directive.NextPerformanceDate),
                    Tag  = directive.NextPerformanceDate
                });
                #endregion

                #region Определение текста для колонки "Человек/Часы"

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = directive.ManHours.ToString(), Tag = directive.ManHours
                });
                #endregion

                #region Определение текста для колонки "Стоимость"

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = directive.Cost.ToString(), Tag = directive.Cost
                });
                #endregion
            }
            else if (item is BaseComponent)
            {
                BaseComponent bd  = (BaseComponent)item;
                AtaChapter    ata = bd.ATAChapter;

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata.ToString(), Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.PartNumber, Tag = bd.PartNumber
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.Description, Tag = bd.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.MaintenanceControlProcess.ShortName, Tag = bd.MaintenanceControlProcess.ShortName
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.Kits.Count > 0 ? bd.Kits.Count + " kits" : "", Tag = bd.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.LifeLimit.ToString(), Tag = bd.LifeLimit
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.Remains.ToString(), Tag = bd.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ComponentRecordType.Remove.ToString(), Tag = ComponentRecordType.Remove
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)bd.NextPerformanceDate), Tag = bd.NextPerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.ManHours.ToString(), Tag = bd.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = bd.Cost.ToString(), Tag = bd.Cost
                });
            }
            else if (item is Component)
            {
                Component  d   = (Component)item;
                AtaChapter ata = d.ATAChapter;

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata.ToString(), Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.PartNumber, Tag = d.PartNumber
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.Description, Tag = d.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.MaintenanceControlProcess.ShortName, Tag = d.MaintenanceControlProcess.ShortName
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.Kits.Count > 0 ? d.Kits.Count + " kits" : "", Tag = d.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.LifeLimit != null ? d.LifeLimit.ToString() : "", Tag = d.LifeLimit
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.Remains != null ? d.Remains.ToString() : "", Tag = d.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ComponentRecordType.Remove.ToString(), Tag = ComponentRecordType.Remove
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)d.NextPerformanceDate), Tag = d.NextPerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.ManHours.ToString(), Tag = d.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = d.Cost.ToString(), Tag = d.Cost
                });
            }
            else if (item is ComponentDirective)
            {
                ComponentDirective dd  = (ComponentDirective)item;
                AtaChapter         ata = dd.ParentComponent.ATAChapter;

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata != null ? ata.ToString() : "", Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.Remarks, Tag = dd.Remarks
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "", Tag = dd.Kits.Count
                });
                #region Определение текста для колонки "Первое выполнение"

                ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + dd.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = dd.Threshold.FirstPerformanceSinceNew;
                }
                subItems.Add(subItem);
                #endregion
                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new ListViewItem.ListViewSubItem();
                if (!dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = dd.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = dd.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.Remains.ToString(), Tag = dd.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.DirectiveType.ToString(), Tag = dd.DirectiveType
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)dd.NextPerformanceDate), Tag = dd.NextPerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.ManHours.ToString(), Tag = dd.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = dd.Cost.ToString(), Tag = dd.Cost
                });
            }
            else if (item is MaintenanceCheck)
            {
                MaintenanceCheck mc = (MaintenanceCheck)item;
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Name + (mc.Schedule ? " Shedule" : " Unshedule"), Tag = mc.Name
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Name, Tag = mc.Name
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Kits.Count > 0 ? mc.Kits.Count + " kits" : "", Tag = mc.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Interval.ToString(), Tag = mc.Interval
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Remains.ToString(), Tag = mc.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)mc.NextPerformanceDate), Tag = mc.NextPerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.ManHours.ToString(), Tag = mc.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = mc.Cost.ToString(), Tag = mc.Cost
                });
            }
            else if (item is MaintenanceDirective)
            {
                MaintenanceDirective md  = (MaintenanceDirective)item;
                AtaChapter           ata = md.ATAChapter;
                string type = md.MaintenanceCheck != null ? md.MaintenanceCheck.Name : "MPD";

                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata != null ? ata.ToString() : "", Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.TaskNumberCheck, Tag = md.TaskNumberCheck
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.Description, Tag = md.Description,
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = type, Tag = type,
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", Tag = md.Kits.Count
                });
                #region Определение текста для колонки "Первое выполнение"

                ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                if (md.Threshold.FirstPerformanceSinceNew != null && !md.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + md.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = md.Threshold.FirstPerformanceSinceNew;
                }
                if (md.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !md.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (subItem.Text != "")
                    {
                        subItem.Text += " or ";
                    }
                    else
                    {
                        subItem.Text = "";
                        subItem.Tag  = md.Threshold.FirstPerformanceSinceEffectiveDate;
                    }
                    subItem.Text += "s/e.d: " + md.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                subItems.Add(subItem);
                #endregion
                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new ListViewItem.ListViewSubItem();
                if (!md.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = md.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = md.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.Remains.ToString(), Tag = md.Remains
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.MaintenanceCheck?.ToString(), Tag = md.MaintenanceCheck
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.WorkType.ToString(), Tag = md.WorkType
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), Tag = md.NextPerformanceDate
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.ManHours.ToString(), Tag = md.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = md.Cost.ToString(), Tag = md.Cost
                });
            }
            else if (item is NonRoutineJob)
            {
                NonRoutineJob job = (NonRoutineJob)item;
                AtaChapter    ata = job.ATAChapter;
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = ata != null ? ata.ToString() : "", Tag = ata
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = job.Description, Tag = job.Description
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "NRC", Tag = "NRC"
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = job.Kits.Count > 0 ? job.Kits.Count + " kits" : "", Tag = job.Kits.Count
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = Lifelength.Null
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = ""
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = "", Tag = DateTimeExtend.GetCASMinDateTime()
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = job.ManHours.ToString(), Tag = job.ManHours
                });
                subItems.Add(new ListViewItem.ListViewSubItem {
                    Text = job.Cost.ToString(), Tag = job.Cost
                });
            }
            else
            {
                throw new ArgumentOutOfRangeException($"1135: Takes an argument has no known type {item.GetType()}");
            }

            return(subItems.ToArray());
        }
        ///<summary>
        ///</summary>
        public void UpdateInformation()
        {
            if (_currentComponentDirective == null)
            {
                return;
            }

            if (_currentComponentDirective.ParentComponent is BaseComponent)
            {
                var inspectedBaseComponent = (BaseComponent)_currentComponentDirective.ParentComponent;

                var baseComponentTypeString = inspectedBaseComponent.BaseComponentType.ToString();
                labelCompntTCSN.Text = baseComponentTypeString;
            }

            imageLinkLabelStatus.Text       = _currentComponentDirective.DirectiveType.ToString();
            labelFirstPerformanceValue.Text = "n/a";
            if (_currentComponentDirective.Threshold.FirstPerformanceSinceNew != null &&
                !_currentComponentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
            {
                labelFirstPerformanceValue.Text = "s/n: " + _currentComponentDirective.Threshold.FirstPerformanceSinceNew;
            }

            if (_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                !_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
            {
                if (labelFirstPerformanceValue.Text != "n/a")
                {
                    labelFirstPerformanceValue.Text += " or ";
                }
                else
                {
                    labelFirstPerformanceValue.Text = "";
                }
                labelFirstPerformanceValue.Text += "s/e.d: " + _currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate;
            }
            labelRptIntervalValue.Text = _currentComponentDirective.Threshold.RepeatInterval.ToString();

            GlobalObjects.PerformanceCalculator.GetNextPerformance(_currentComponentDirective);

            Lifelength temp;
            ComponentDirectiveThreshold threshold;
            Component tempComponent;
            var       tempAircraft = GlobalObjects.AircraftsCore.GetAircraftById(_currentComponentDirective.ParentComponent.ParentAircraftId);

            labelCompntRemains.Text = "";
            labelCompntSince.Text   = "";
            if (_currentComponentDirective.Remains != null && _currentComponentDirective.Condition != ConditionState.NotEstimated)
            {
                if (_currentComponentDirective.Remains.IsOverdue() && _currentComponentDirective.Condition == ConditionState.Overdue)
                {
                    labelRemains.Text           = "Overdue:";
                    imageLinkLabelStatus.Status = Statuses.NotSatisfactory;
                }
                else if (_currentComponentDirective.Condition == ConditionState.Notify)
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.Notify;
                }
                else if (_currentComponentDirective.Condition == ConditionState.Satisfactory)
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.Satisfactory;
                }
                else
                {
                    labelRemains.Text           = "Remains:";
                    imageLinkLabelStatus.Status = Statuses.NotActive;
                }

                labelCompntRemains.Text = _currentComponentDirective.Remains.ToString();
            }

            labelDateLast.Text         = "";
            labelCompntTCSNLast.Text   = "";
            labelAircraftTCSNLast.Text = "";

            labelDateNext.Text         = "n/a";
            labelCompntTCSNNext.Text   = "n/a";
            labelAircraftTCSNNext.Text = "n/a";
            labelRemarksValue.Text     = _currentComponentDirective.Remarks;

            if (_currentComponentDirective.LastPerformance != null)
            {
                //Заполнение Last-ов
                //дата последнего выполнения
                labelDateLast.Text = SmartCore.Auxiliary.Convert.GetDateFormat(_currentComponentDirective.LastPerformance.RecordDate);

                Lifelength current;
                if (_currentComponentDirective.ParentComponent is BaseComponent)
                {
                    current = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseComponent)_currentComponentDirective.ParentComponent);
                }
                else
                {
                    current = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentComponentDirective.ParentComponent);
                }
                //наработка компонента на последнем исполнении
                temp = _currentComponentDirective.LastPerformance.OnLifelength;
                if (temp != Lifelength.Null)
                {
                    labelCompntTCSNLast.Text = temp.ToString();
                    if (!current.IsNullOrZero())
                    {
                        current.Substract(temp);
                        labelCompntSince.Text = current.ToString();
                    }
                }

                //наработка самолета на последнем исполнении
                temp = tempAircraft != null &&
                       _currentComponentDirective.ParentComponent.TransferRecords.GetLast().TransferDate < _currentComponentDirective.LastPerformance.RecordDate
                                ? _currentComponentDirective.LastPerformance.OnLifelength
                                : Lifelength.Null;

                if (temp != Lifelength.Null)
                {
                    labelAircraftTCSNLast.Text = temp.ToString();
                }



                //Заполнение Next-ов
                threshold = _currentComponentDirective.Threshold;
                if (threshold.RepeatInterval != null && !threshold.RepeatInterval.IsNullOrZero())
                {
                    //дата Следующего исполнения
                    //если в наработке на первом выполнении заданы дни
                    //то выводится точная дата следующего выполнения
                    if (threshold.RepeatInterval.Days != null)
                    {
                        labelDateNext.Text =
                            SmartCore.Auxiliary.Convert.GetDateFormat(
                                _currentComponentDirective.LastPerformance.RecordDate.AddDays(
                                    (double)threshold.RepeatInterval.Days));
                    }                    //иначе, точную дату выполнения расчитать нельзя


                    //наработка компонента на следующее исполнение
                    Lifelength nextComponentTsnCsn =
                        new Lifelength(_currentComponentDirective.LastPerformance.OnLifelength);
                    nextComponentTsnCsn.Add(threshold.RepeatInterval);
                    nextComponentTsnCsn.Resemble(threshold.RepeatInterval);
                    labelCompntTCSNNext.Text = nextComponentTsnCsn.ToString();

                    //наработка самолета на следующее исполнение

                    //Могут вводится записи, которые были сделаны на агрегате еще
                    //до появления этого агрегате в системе. в данном случае надо проверять
                    //не является ли наработка на след.выполнение меньше той наработки
                    //при которой был установлен агрегат

                    ActualStateRecord asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst();
                    if (asr != null && tempAircraft != null &&
                        threshold.FirstPerformanceSinceNew.IsGreaterNullable(_currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst().OnLifelength))
                    {
                        //наработка на след выполнение больше той, что была при установке агрегата
                        temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft);
                        //temp.Add(remains);
                        temp.Add(_currentComponentDirective.Remains);
                        temp.Resemble(threshold.RepeatInterval);
                        labelAircraftTCSNNext.Text = temp.ToString();
                    }
                    else
                    {
                        labelAircraftTCSNNext.Text = "";
                    }
                    //_temp на данный момент содержит наработку самолета на последнем исполнении
                    //temp.Add(threshold.RepeatInterval);
                    //temp.Resemble(threshold.RepeatInterval);
                    //labelAircraftTCSNNext.Text = temp.ToString();
                }
            }
            else
            {
                //последнего исполнения не было
                //расчет ведется по FirstPerformance

                //Заполнение Next-ов
                threshold     = _currentComponentDirective.Threshold;
                tempComponent = _currentComponentDirective.ParentComponent;
                if (threshold.FirstPerformanceSinceNew != null && !threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    //дата Следующего исполнения
                    if (threshold.FirstPerformanceSinceNew.Days != null)
                    {
                        //если в первом выполнении заданы дни
                        //то выводится точная дата следующего выполнения

                        //дата = дата_производства + первое_исполнение.дни
                        labelDateNext.Text =
                            SmartCore.Auxiliary.Convert.GetDateFormat(
                                tempComponent.ManufactureDate.AddDays((double)threshold.FirstPerformanceSinceNew.Days));
                    }                    //иначе, точную дату выполнения расчитать нельзя


                    //наработка компонента на следующее исполнение
                    labelCompntTCSNNext.Text = threshold.FirstPerformanceSinceNew.ToString();

                    //наработка самолета на следующее исполнение
                    //наработка = наработка самолета на сегодня + остаток до первого исполнения
                    ActualStateRecord asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst();
                    if (asr != null && tempAircraft != null &&
                        threshold.FirstPerformanceSinceNew.IsGreaterNullable(_currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst().OnLifelength))
                    {
                        //наработка на след выполнение больше той, что была при установке агрегата
                        temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft);
                        //temp.Add(remains);
                        temp.Add(_currentComponentDirective.Remains);
                        temp.Resemble(threshold.FirstPerformanceSinceNew);
                        labelAircraftTCSNNext.Text = temp.ToString();
                    }
                    else
                    {
                        labelAircraftTCSNNext.Text = "";
                    }
                }
                else if (threshold.FirstPerformanceSinceEffectiveDate != null &&
                         !threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    //дата Следующего исполнения
                    if (threshold.FirstPerformanceSinceEffectiveDate.Days != null)
                    {
                        //если в первом выполнении заданы дни
                        //то выводится точная дата следующего выполнения

                        //дата = дата_производства + первое_исполнение.дни
                        labelDateNext.Text =
                            SmartCore.Auxiliary.Convert.GetDateFormat(
                                threshold.EffectiveDate.AddDays((double)threshold.FirstPerformanceSinceEffectiveDate.Days));
                    }                    //иначе, точную дату выполнения расчитать нельзя


                    //наработка компонента на следующее исполнение
                    //Определение наработки
                    if (threshold.EffectiveDate < DateTime.Today)
                    {
                        Lifelength sinceEffDate = _currentComponentDirective.ParentComponent is BaseComponent
                                                        ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((BaseComponent)_currentComponentDirective.ParentComponent, _currentComponentDirective.Threshold.EffectiveDate)
                                                        : GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_currentComponentDirective.ParentComponent, _currentComponentDirective.Threshold.EffectiveDate);

                        sinceEffDate.Add(_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate);
                        sinceEffDate.Resemble(_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate);

                        if (labelCompntTCSNNext.Text != "n/a")
                        {
                            labelCompntTCSNNext.Text += " or ";
                        }
                        else
                        {
                            labelCompntTCSNNext.Text = "";
                        }
                        labelCompntTCSNNext.Text += "s/e.d: " + sinceEffDate;
                    }
                    //наработка самолета на следующее исполнение
                    //наработка = наработка самолета на сегодня + остаток до первого исполнения
                    ActualStateRecord asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst();
                    if (asr != null && tempAircraft != null &&
                        threshold.FirstPerformanceSinceEffectiveDate.IsGreaterNullable(asr.OnLifelength))
                    {
                        //наработка на след выполнение больше той, что была при установке агрегата
                        temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft);
                        //temp.Add(remains);
                        temp.Add(_currentComponentDirective.Remains);
                        temp.Resemble(threshold.FirstPerformanceSinceNew);
                        labelAircraftTCSNNext.Text = temp.ToString();
                    }
                    else
                    {
                        labelAircraftTCSNNext.Text = "";
                    }

                    //temp = tempAircraft != null
                    //? GlobalObjects.CasEnvironment.Calculator.GetLifelength(tempAircraft)
                    //: Lifelength.Zero;
                    //temp.Add(remains);
                    //temp.Resemble(threshold.FirstPerformance);
                    //labelAircraftTCSNNext.Text = temp.ToString();
                }
            }
        }
Exemplo n.º 13
0
        //protected override void SetItemColor(ListViewItem listViewItem, BaseEntityObject item)
        //{
        //    if (item is NextPerformance)
        //    {
        //        NextPerformance nextPerformance = item as NextPerformance;
        //        if(_currentDirective.Status != WorkPackageStatus.Closed)
        //        {
        //            if (nextPerformance.BlockedByPackage != null)
        //            {
        //                listViewItem.ToolTipText = "This performance blocked by work package:" +
        //                   nextPerformance.BlockedByPackage.Title;
        //                listViewItem.BackColor = Color.FromArgb(Highlight.Grey.Color);
        //            }
        //            else if (nextPerformance.Condition == ConditionState.Notify)
        //                listViewItem.BackColor = Color.FromArgb(Highlight.Yellow.Color);
        //            else if (nextPerformance.Condition == ConditionState.Overdue)
        //                listViewItem.BackColor = Color.FromArgb(Highlight.Red.Color);
        //        }
        //        else
        //        {
        //            //Если это следующее выполнение, но рабочий пакет при этом закрыт
        //            //значит, выполнение для данной задачи в рамках данного рабочего пакета
        //            //не было введено

        //            //пометка этого выполнения краным цветом
        //            listViewItem.BackColor = Color.FromArgb(Highlight.Red.Color);
        //            //подсказка о том, что выполнение не было введено
        //            listViewItem.ToolTipText = "Performance for this directive within this work package is not entered.";
        //            if (nextPerformance.BlockedByPackage != null)
        //            {
        //                //дополнитльная подсказака, если предшествующее выполнение
        //                //имеется в другом открытом рабочем пакете
        //                listViewItem.ToolTipText += "\nThis performance blocked by work package:" +
        //                   nextPerformance.BlockedByPackage.Title +
        //                   "\nFirst, enter the performance of this directive as part of this work package ";
        //            }
        //        }

        //        if (nextPerformance.Parent.IsDeleted)
        //        {
        //            //запись так же может быть удаленной

        //            //шрифт серым цветом
        //            listViewItem.ForeColor = Color.Gray;
        //            if (listViewItem.ToolTipText.Trim() != "")
        //                listViewItem.ToolTipText += "\n";
        //            listViewItem.ToolTipText += string.Format("This {0} is deleted",nextPerformance.Parent.SmartCoreObjectType);
        //        }
        //    }
        //    else if (item is AbstractPerformanceRecord)
        //    {
        //        AbstractPerformanceRecord apr = (AbstractPerformanceRecord) item;
        //        if (apr.Parent.IsDeleted)
        //        {
        //            //запись так же может быть удаленной

        //            //шрифт серым цветом
        //            listViewItem.ForeColor = Color.Gray;
        //            if (listViewItem.ToolTipText.Trim() != "")
        //                listViewItem.ToolTipText += "\n";
        //            listViewItem.ToolTipText += string.Format("This {0} is deleted", apr.Parent.SmartCoreObjectType);
        //        }
        //    }
        //    else
        //    {
        //        if(!(item is NonRoutineJob))
        //        {
        //            //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа
        //            //значит, выполнение для данной задачи расчитать нельзя

        //            //пометка этого выполнения синим цветом
        //            listViewItem.BackColor = Color.FromArgb(Highlight.Blue.Color);
        //            //подсказка о том, что выполнение не возможео расчитать
        //            listViewItem.ToolTipText = "Performance for this directive can not be calculated";
        //        }

        //        if (item.IsDeleted)
        //        {
        //            //запись так же может быть удаленной

        //            //шрифт серым цветом
        //            listViewItem.ForeColor = Color.Gray;
        //            if (listViewItem.ToolTipText.Trim() != "")
        //                listViewItem.ToolTipText += "\n";
        //            listViewItem.ToolTipText += string.Format("This {0} is deleted", item.SmartCoreObjectType);
        //        }
        //    }
        //}
        #endregion

        #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseSmartCoreObject item)

        protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item)
        {
            var temp     = ListViewGroupHelper.GetGroupString(item);
            var subItems = new List <CustomCell>()
            {
                CreateRow(temp, temp)
            };
            var author = GlobalObjects.CasEnvironment.GetCorrector(item);

            //if(item.ItemId == 41043)
            //{

            //}
            if (item is NextPerformance)
            {
                NextPerformance np = (NextPerformance)item;

                double manHours = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).ManHours : 0;
                double cost     = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).Cost : 0;

                subItems.Add(CreateRow(np.ATAChapter.ToString(), np.ATAChapter));
                subItems.Add(CreateRow(np.Title, np.Title));
                subItems.Add(CreateRow(np.Description, np.Description));
                subItems.Add(CreateRow(np.KitsToString, np.Kits.Count));
                subItems.Add(CreateRow(np.PerformanceSource.ToString(), np.PerformanceSource));
                subItems.Add(CreateRow(np.Parent.Threshold.RepeatInterval.ToString(), np.Parent.Threshold.RepeatInterval));
                subItems.Add(CreateRow(np.Remains.ToString(), np.Remains));
                subItems.Add(CreateRow(np.WorkType, Tag = np.WorkType));
                subItems.Add(CreateRow(np.PerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)np.PerformanceDate), np.PerformanceDate));
                subItems.Add(CreateRow(manHours.ToString(), manHours));
                subItems.Add(CreateRow(cost.ToString(), cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is AbstractPerformanceRecord)
            {
                //DirectiveRecord directiveRecord = (DirectiveRecord)item;
                AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item;
                Lifelength remains            = Lifelength.Null;
                double     manHours           = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).ManHours : 0;
                double     cost = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).Cost : 0;

                subItems.Add(CreateRow(apr.ATAChapter.ToString(), apr.ATAChapter));
                subItems.Add(CreateRow(apr.Title, apr.Title));
                subItems.Add(CreateRow(apr.Description, apr.Description));
                subItems.Add(CreateRow(apr.KitsToString, apr.Kits.Count));
                subItems.Add(CreateRow(apr.OnLifelength.ToString(), apr.OnLifelength));
                subItems.Add(CreateRow(apr.Parent.Threshold.RepeatInterval.ToString(), apr.Parent.Threshold.RepeatInterval));
                subItems.Add(CreateRow(remains.ToString(), remains));
                subItems.Add(CreateRow(apr.WorkType, apr.WorkType));
                subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(apr.RecordDate), apr.RecordDate));
                subItems.Add(CreateRow(manHours.ToString(), manHours));
                subItems.Add(CreateRow(cost.ToString(), cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is Directive)
            {
                Directive directive = (Directive)item;

                AtaChapter ata = directive.ATAChapter;
                subItems.Add(CreateRow(ata.ToString(), ata));
                subItems.Add(CreateRow(directive.Title, directive.Title));
                subItems.Add(CreateRow(directive.Description, directive.Description));

                #region Определение текста для колонки "КИТы"
                subItems.Add(CreateRow(directive.Kits.Count > 0 ? directive.Kits.Count + " kits" : "", directive.Kits.Count));
                #endregion

                #region Определение текста для колонки "Первое выполнение"

                var subItem = new CustomCell();
                if (directive.Threshold.FirstPerformanceSinceNew != null && !directive.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + directive.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = directive.Threshold.FirstPerformanceSinceNew;
                }
                if (directive.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !directive.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (subItem.Text != "")
                    {
                        subItem.Text += " or ";
                    }
                    else
                    {
                        subItem.Text = "";
                        subItem.Tag  = directive.Threshold.FirstPerformanceSinceEffectiveDate;
                    }
                    subItem.Text += "s/e.d: " + directive.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                subItems.Add(subItem);
                #endregion

                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new CustomCell();
                if (!directive.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = directive.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = directive.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion

                #region Определение текста для колонки "Остаток/Просрочено на сегодня"
                subItems.Add(CreateRow(directive.Remains.ToString(), directive.Remains));
                #endregion

                #region Определение текста для колонки "Тип работ"

                subItems.Add(CreateRow(directive.WorkType.ToString(), directive.WorkType));
                #endregion

                #region Определение текста для колонки "Следующее выполнение"
                subItems.Add(CreateRow(directive.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)directive.NextPerformanceDate), directive.NextPerformanceDate));
                #endregion

                #region Определение текста для колонки "Человек/Часы"

                subItems.Add(CreateRow(directive.ManHours.ToString(), directive.ManHours));
                #endregion

                #region Определение текста для колонки "Стоимость"

                subItems.Add(CreateRow(directive.Cost.ToString(), directive.Cost));
                #endregion
                subItems.Add(CreateRow(author, author));
            }
            else if (item is BaseComponent)
            {
                BaseComponent bd  = (BaseComponent)item;
                AtaChapter    ata = bd.ATAChapter;

                subItems.Add(CreateRow(ata.ToString(), ata));
                subItems.Add(CreateRow(bd.PartNumber, bd.PartNumber));
                subItems.Add(CreateRow(bd.Description, bd.Description));
                subItems.Add(CreateRow(bd.Kits.Count > 0 ? bd.Kits.Count + " kits" : "", bd.Kits.Count));
                subItems.Add(CreateRow(bd.LifeLimit.ToString(), bd.LifeLimit));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow(bd.Remains.ToString(), bd.Remains));
                subItems.Add(CreateRow(ComponentRecordType.Remove.ToString(), ComponentRecordType.Remove));
                subItems.Add(CreateRow(bd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)bd.NextPerformanceDate), bd.NextPerformanceDate));
                subItems.Add(CreateRow(bd.ManHours.ToString(), bd.ManHours));
                subItems.Add(CreateRow(bd.Cost.ToString(), bd.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is Component)
            {
                Component  d   = (Component)item;
                AtaChapter ata = d.ATAChapter;

                subItems.Add(CreateRow(ata.ToString(), ata));
                subItems.Add(CreateRow(d.PartNumber, d.PartNumber));
                subItems.Add(CreateRow(d.Description, d.Description));
                subItems.Add(CreateRow(d.Kits.Count > 0 ? d.Kits.Count + " kits" : "", d.Kits.Count));
                subItems.Add(CreateRow(d.LifeLimit != null ? d.LifeLimit.ToString() : "", d.LifeLimit));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow(d.Remains != null ? d.Remains.ToString() : "", d.Remains));
                subItems.Add(CreateRow(ComponentRecordType.Remove.ToString(), ComponentRecordType.Remove));
                subItems.Add(CreateRow(d.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)d.NextPerformanceDate), d.NextPerformanceDate));
                subItems.Add(CreateRow(d.ManHours.ToString(), d.ManHours));
                subItems.Add(CreateRow(d.Cost.ToString(), d.Cost));
                subItems.Add(CreateRow(author, Tag = author));
            }
            else if (item is ComponentDirective)
            {
                ComponentDirective dd  = (ComponentDirective)item;
                AtaChapter         ata = dd.ParentComponent.ATAChapter;

                subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow(dd.Remarks, dd.Remarks));
                subItems.Add(CreateRow(dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "", dd.Kits.Count));
                #region Определение текста для колонки "Первое выполнение"

                var subItem = new CustomCell();
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + dd.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = dd.Threshold.FirstPerformanceSinceNew;
                }
                subItems.Add(subItem);
                #endregion
                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new CustomCell();
                if (!dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = dd.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = dd.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion
                subItems.Add(CreateRow(dd.Remains.ToString(), dd.Remains));
                subItems.Add(CreateRow(dd.DirectiveType.ToString(), dd.DirectiveType));
                subItems.Add(CreateRow(dd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)dd.NextPerformanceDate), dd.NextPerformanceDate));
                subItems.Add(CreateRow(dd.ManHours.ToString(), dd.ManHours));
                subItems.Add(CreateRow(dd.Cost.ToString(), dd.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is MaintenanceCheck)
            {
                MaintenanceCheck mc = (MaintenanceCheck)item;
                subItems.Add(CreateRow("", null));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow(mc.Name + (mc.Schedule ? " Shedule" : " Unshedule"), mc.Name));
                subItems.Add(CreateRow(mc.Kits.Count > 0 ? mc.Kits.Count + " kits" : "", mc.Kits.Count));
                subItems.Add(CreateRow(mc.Interval.ToString(), mc.Interval));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow(mc.Remains.ToString(), mc.Remains));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow(mc.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)mc.NextPerformanceDate), mc.NextPerformanceDate));
                subItems.Add(CreateRow(mc.ManHours.ToString(), mc.ManHours));
                subItems.Add(CreateRow(mc.Cost.ToString(), mc.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is MaintenanceDirective)
            {
                MaintenanceDirective md  = (MaintenanceDirective)item;
                AtaChapter           ata = md.ATAChapter;

                subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata));
                subItems.Add(CreateRow(md.ToString(), md.ToString()));
                subItems.Add(CreateRow(md.Description, md.Description));
                subItems.Add(CreateRow(md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", md.Kits.Count));
                #region Определение текста для колонки "Первое выполнение"

                var subItem = new CustomCell();
                if (md.Threshold.FirstPerformanceSinceNew != null && !md.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + md.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = md.Threshold.FirstPerformanceSinceNew;
                }
                if (md.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !md.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (subItem.Text != "")
                    {
                        subItem.Text += " or ";
                    }
                    else
                    {
                        subItem.Text = "";
                        subItem.Tag  = md.Threshold.FirstPerformanceSinceEffectiveDate;
                    }
                    subItem.Text += "s/e.d: " + md.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                subItems.Add(subItem);
                #endregion
                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new CustomCell();
                if (!md.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = md.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = md.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion
                subItems.Add(CreateRow(md.Remains.ToString(), md.Remains));
                subItems.Add(CreateRow(md.WorkType.ToString(), md.WorkType));
                subItems.Add(CreateRow(md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), md.NextPerformanceDate));
                subItems.Add(CreateRow(md.ManHours.ToString(), md.ManHours));
                subItems.Add(CreateRow(md.Cost.ToString(), md.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is Procedure)
            {
                Procedure md = (Procedure)item;

                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow(md.ToString(), md.ToString()));
                subItems.Add(CreateRow(md.Description, md.Description));
                subItems.Add(CreateRow(md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", md.Kits.Count));

                #region Определение текста для колонки "Первое выполнение"

                var subItem = new CustomCell();
                if (md.Threshold.FirstPerformanceSinceNew != null && !md.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    subItem.Text = "s/n: " + md.Threshold.FirstPerformanceSinceNew;
                    subItem.Tag  = md.Threshold.FirstPerformanceSinceNew;
                }
                if (md.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                    !md.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
                {
                    if (subItem.Text != "")
                    {
                        subItem.Text += " or ";
                    }
                    else
                    {
                        subItem.Text = "";
                        subItem.Tag  = md.Threshold.FirstPerformanceSinceEffectiveDate;
                    }
                    subItem.Text += "s/e.d: " + md.Threshold.FirstPerformanceSinceEffectiveDate;
                }

                subItems.Add(subItem);
                #endregion

                #region Определение текста для колонки "повторяющийся интервал"

                subItem = new CustomCell();
                if (!md.Threshold.RepeatInterval.IsNullOrZero())
                {
                    subItem.Text = md.Threshold.RepeatInterval.ToString();
                    subItem.Tag  = md.Threshold.RepeatInterval;
                }
                else
                {
                    subItem.Text = "";
                    subItem.Tag  = Lifelength.Null;
                }
                subItems.Add(subItem);
                #endregion

                subItems.Add(CreateRow(md.Remains.ToString(), md.Remains));
                subItems.Add(CreateRow(md.ProcedureType.ToString(), md.ProcedureType));
                subItems.Add(CreateRow(md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), md.NextPerformanceDate));
                subItems.Add(CreateRow(md.ManHours.ToString(), md.ManHours));
                subItems.Add(CreateRow(md.Cost.ToString(), md.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else if (item is NonRoutineJob)
            {
                NonRoutineJob job = (NonRoutineJob)item;
                AtaChapter    ata = job.ATAChapter;
                subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata));
                subItems.Add(CreateRow(job.Title, job.Title));
                subItems.Add(CreateRow(job.Description, job.Description));
                subItems.Add(CreateRow(job.Kits.Count > 0 ? job.Kits.Count + " kits" : "", job.Kits.Count));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow("", Lifelength.Null));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", DateTimeExtend.GetCASMinDateTime()));
                subItems.Add(CreateRow(job.ManHours.ToString(), job.ManHours));
                subItems.Add(CreateRow(job.Cost.ToString(), job.Cost));
                subItems.Add(CreateRow(author, author));
            }
            else
            {
                throw new ArgumentOutOfRangeException($"1135: Takes an argument has no known type {item.GetType()}");
            }

            return(subItems);
        }
Exemplo n.º 14
0
        protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseEntityObject item)
        {
            ListViewItem.ListViewSubItem[] subItems = new ListViewItem.ListViewSubItem[21];

            DateTime?  approx;
            Lifelength remains, next;
            AtaChapter ata;
            MaintenanceControlProcess maintenanceType;
            DateTime   transferDate = DateTimeExtend.GetCASMinDateTime();
            Lifelength firstPerformance = Lifelength.Null,
                       lastPerformance = Lifelength.Null,
                       warranty, repeatInterval = Lifelength.Null;
            string partNumber = "",
                   description,
                   serialNumber          = "",
                   position              = "",
                   lastPerformanceString = "",
                   kitRequieredString,
                   remarks,
                   hiddenRemarks,
                   workType = "";
            double manHours,
                   cost,
                   costServiceable = 0,
                   costOverhaul    = 0;

            if (item is Component)
            {
                Component componentItem = (Component)item;
                //if(detailItem is BaseDetail)
                //    GlobalObjects.CasEnvironment.Calculator.GetLifelength((BaseDetail)detailItem, out cond, out remains, out next, out approx);
                //else GlobalObjects.CasEnvironment.Calculator.GetLifelength(detailItem, out cond, out remains, out next, out approx);
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(detailItem);
                approx             = componentItem.NextPerformanceDate;
                next               = componentItem.NextPerformanceSource;
                remains            = componentItem.Remains;
                ata                = componentItem.ATAChapter;
                partNumber         = componentItem.PartNumber;
                description        = componentItem.Description;
                serialNumber       = componentItem.SerialNumber;
                position           = componentItem.TransferRecords.GetLast().Position.ToUpper();
                maintenanceType    = componentItem.MaintenanceControlProcess;
                transferDate       = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance   = componentItem.LifeLimit;
                warranty           = componentItem.Warranty;
                kitRequieredString = componentItem.Kits.Count + " kits";
                manHours           = componentItem.ManHours;
                cost               = componentItem.Cost;
                costOverhaul       = componentItem.CostOverhaul;
                costServiceable    = componentItem.CostServiceable;
                remarks            = componentItem.Remarks;
                hiddenRemarks      = componentItem.HiddenRemarks;
            }
            else
            {
                ComponentDirective dd = (ComponentDirective)item;
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }
                if (dd.LastPerformance != null)
                {
                    lastPerformanceString =
                        SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " +
                        dd.LastPerformance.OnLifelength;
                    lastPerformance = dd.LastPerformance.OnLifelength;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd, out next, out remains, out approx, out cond);
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd);
                approx             = dd.NextPerformanceDate;
                next               = dd.NextPerformanceSource;
                remains            = dd.Remains;
                ata                = dd.ParentComponent.ATAChapter;
                description        = "    " + dd.ParentComponent.Description;// +" " + dd.DirectiveType;
                maintenanceType    = dd.ParentComponent.MaintenanceControlProcess;
                warranty           = dd.Threshold.Warranty;
                kitRequieredString = dd.Kits.Count + " kits";
                manHours           = dd.ManHours;
                cost               = dd.Cost;
                remarks            = dd.Remarks;
                hiddenRemarks      = dd.HiddenRemarks;
                workType           = dd.DirectiveType.ToString();
            }

            subItems[0] = new ListViewItem.ListViewSubItem {
                Text = ata.ToString(), Tag = ata
            };
            subItems[1] = new ListViewItem.ListViewSubItem {
                Text = partNumber, Tag = partNumber
            };
            subItems[2] = new ListViewItem.ListViewSubItem {
                Text = description, Tag = description
            };
            subItems[3] = new ListViewItem.ListViewSubItem {
                Text = serialNumber, Tag = serialNumber
            };
            subItems[4] = new ListViewItem.ListViewSubItem {
                Text = position, Tag = position
            };
            subItems[5] = new ListViewItem.ListViewSubItem {
                Text = maintenanceType.ShortName, Tag = maintenanceType
            };
            subItems[6] = new ListViewItem.ListViewSubItem
            {
                Text = transferDate > DateTimeExtend.GetCASMinDateTime()
                                        ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "",
                Tag = transferDate
            };
            subItems[7] = new ListViewItem.ListViewSubItem {
                Text = workType, Tag = workType
            };
            subItems[8] = new ListViewItem.ListViewSubItem {
                Text = firstPerformance.ToString(), Tag = firstPerformance
            };
            subItems[9] = new ListViewItem.ListViewSubItem {
                Text = repeatInterval.ToString(), Tag = repeatInterval
            };
            subItems[10] = new ListViewItem.ListViewSubItem
            {
                Text = approx == null
                    ? ""
                    : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next,
                Tag = approx == null?DateTimeExtend.GetCASMinDateTime() : (DateTime)approx
            };
            subItems[11] = new ListViewItem.ListViewSubItem
            {
                Text = remains != null && !remains.IsNullOrZero()
                                       ? remains.ToString()
                                       : "",
                Tag = remains ?? Lifelength.Null
            };
            subItems[12] = new ListViewItem.ListViewSubItem {
                Text = lastPerformanceString, Tag = lastPerformance
            };
            subItems[13] = new ListViewItem.ListViewSubItem {
                Text = warranty.ToString(), Tag = warranty
            };
            subItems[14] = new ListViewItem.ListViewSubItem {
                Text = kitRequieredString, Tag = kitRequieredString
            };
            subItems[15] = new ListViewItem.ListViewSubItem {
                Text = manHours.ToString(), Tag = manHours
            };
            subItems[16] = new ListViewItem.ListViewSubItem {
                Text = cost.ToString(), Tag = cost
            };
            subItems[17] = new ListViewItem.ListViewSubItem {
                Text = costOverhaul.ToString(), Tag = costOverhaul
            };
            subItems[18] = new ListViewItem.ListViewSubItem {
                Text = costServiceable.ToString(), Tag = costServiceable
            };
            subItems[19] = new ListViewItem.ListViewSubItem {
                Text = remarks, Tag = remarks
            };
            subItems[20] = new ListViewItem.ListViewSubItem {
                Text = hiddenRemarks, Tag = hiddenRemarks
            };

            return(subItems);
        }
Exemplo n.º 15
0
        private void GenerateRows()
        {
            listViewProgramChecks.Items.Clear();
            if (_grouping)
            {
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupWhereCheckIsSeniorByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                mcc.Clear();
            }
            else
            {
                foreach (MaintenanceCheck t in _maintenanceCheckItems)
                {
                    ListViewItem listViewItem = new ListViewItem {
                        Text = t.Name
                    };

                    listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                    listViewItem.SubItems.Add(t.Cost.ToString());
                    listViewItem.SubItems.Add(t.ManHours.ToString());

                    Lifelength lastPerformance = t.LastPerformance != null
                        ? new Lifelength(t.LastPerformance.OnLifelength)
                        : Lifelength.Null;
                    int?last = lastPerformance.GetSubresource(_subResource);

                    listViewItem.SubItems.Add(last != null ? lastPerformance.ToString(_subResource, true) : "");

                    if (t.Schedule == _schedule)
                    {
                        Lifelength nextPerformance = lastPerformance + t.Interval;
                        int?       next            = nextPerformance.GetSubresource(_subResource);
                        listViewItem.SubItems.Add(next != null ? nextPerformance.ToString(_subResource, true) : "");
                    }
                    else
                    {
                        listViewItem.SubItems.Add("N/A");
                    }
                    listViewProgramChecks.Items.Add(listViewItem);
                }
            }
        }