/// <summary> /// Добавляет запись о смене программы обслуживания /// </summary> /// <param name="aircraft">ВС, на которое добавляется запись</param> /// <param name="maintenanceProgramChangeRecord">Запись о смене обслуживания</param> public void RegisterMaintenanceProgramChangeRecord(Aircraft aircraft, MaintenanceProgramChangeRecord maintenanceProgramChangeRecord) { // Проверка на возможность добавления записи о смене программы обслуживания if (aircraft.ItemId <= 0) { throw new Exception("1009: Can not register actual state for not existing aircraft"); } if (aircraft == null) { throw new Exception("1610: Can not register actual state for not existing aircraft"); } // Если на данную дату уже существует запись о смене программы обслуживания - // мы должны изменить уже существующую запись вместо добавления еще одной записи // на одну дату - последствия не предсказуемы var existing = aircraft.MaintenanceProgramChangeRecords[maintenanceProgramChangeRecord.RecordDate.Date]; if (existing != null) { // запись на указанную дату существует // а поэтому изменяем ее данные и сохраняем existing.ParentAircraftId = aircraft.ItemId; existing.OnLifelength = new Lifelength(maintenanceProgramChangeRecord.OnLifelength); // изменяем актуальные данные existing.Remarks = maintenanceProgramChangeRecord.Remarks; // перебиваем комментарии _newKeeper.Save(existing); } else { maintenanceProgramChangeRecord.ParentAircraftId = aircraft.ItemId; // дополняем необходимые данные _newKeeper.Save(maintenanceProgramChangeRecord); // добавляем в базу данных aircraft.MaintenanceProgramChangeRecords.Add(maintenanceProgramChangeRecord); // дабавляем в коллекцию } }
///<summary> ///</summary> ///<param name="maintenanceProgramChangeRecord"></param> ///<param name="maintenanceCheckRecordGroups"></param> public MaintenanceProgramChangeDialog(MaintenanceProgramChangeRecord maintenanceProgramChangeRecord, List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups) : this() { _currentMaintenanceProgramChangeRecord = maintenanceProgramChangeRecord; _currentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(_currentMaintenanceProgramChangeRecord.ParentAircraftId); _maintenanceCheckRecordGroups = maintenanceCheckRecordGroups; UpdateInformation(); }
///<summary> ///</summary> ///<param name="currentAircraft"></param> ///<param name="maintenanceCheckRecordGroups"></param> public MaintenanceProgramChangeDialog(Aircraft currentAircraft, List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups) : this() { if (currentAircraft == null) { throw new ArgumentNullException("currentAircraft", "must be not null"); } _currentAircraft = currentAircraft; _maintenanceCheckRecordGroups = maintenanceCheckRecordGroups; _currentMaintenanceProgramChangeRecord = new MaintenanceProgramChangeRecord { RecordDate = _currentAircraft.ManufactureDate.Date }; UpdateInformation(); }
private void ButtonDeleteClick(object sender, EventArgs e) { if (listViewCompliance.SelectedItems.Count == 0 || listViewCompliance.SelectedItems[0].Group != listViewCompliance.Groups["last"] || (!(listViewCompliance.SelectedItems[0].Tag is List <MaintenanceCheckRecord>) && !(listViewCompliance.SelectedItems[0].Tag is MaintenanceProgramChangeRecord))) { return; } if (listViewCompliance.SelectedItems[0].Tag is List <MaintenanceCheckRecord> ) { List <MaintenanceCheckRecord> records = (List <MaintenanceCheckRecord>)listViewCompliance.SelectedItems[0].Tag; if (records.Any(r => r.DirectivePackage != null)) { MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text + "\nadded by Work Package:" + "\n" + records.First(r => r.DirectivePackage != null).DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package ", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } switch (MessageBox.Show(@"Delete this compliance " + " ?", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)) { case DialogResult.Yes: foreach (MaintenanceCheckRecord record in records) { GlobalObjects.MaintenanceCore.Delete(record); } InvokeComplianceAdded(null); break; case DialogResult.No: //arguments.Cancel = true; break; } } else if (listViewCompliance.SelectedItems[0].Tag is MaintenanceProgramChangeRecord) { MaintenanceProgramChangeRecord record = (MaintenanceProgramChangeRecord)listViewCompliance.SelectedItems[0].Tag; switch (MessageBox.Show(@"Delete this Maintenance program change record ?", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)) { case DialogResult.Yes: GlobalObjects.CasEnvironment.Manipulator.Delete(record); InvokeComplianceAdded(null); break; case DialogResult.No: //arguments.Cancel = true; break; } } }
private ListViewItem GetListViewItem(MaintenanceCheckRecordGroup grouping) { string name = "N/A"; string type = "N/A"; string resource = "N/A"; string group = "N/A"; string num = "N/A"; string recordDate = "N/A"; string performanceSource = "N/A"; string remarksString = "N/A"; Color backColor = Color.White; if (grouping.Records.Count > 0) { grouping.Sort(); MaintenanceCheckRecord mcr = grouping.LastOrDefault(); MaintenanceCheck mc = grouping.GetMaxIntervalCheck(); type = mc.Schedule ? " (Schedule) " : " (Store) "; resource = mc.Resource.ToString(); group = mc.Grouping ? " (Group)" : ""; backColor = mc.Schedule ? Color.White : Color.Gainsboro; if (mcr != null) { num = mc.Grouping ? mcr.NumGroup.ToString() : "N/A"; name = _currentAircraft != null && _currentAircraft.MaintenanceProgramCheckNaming ? (!string.IsNullOrEmpty(grouping.First().ComplianceCheckName) ? mcr.ComplianceCheckName : mc.Name) : mc.Name; recordDate = UsefulMethods.NormalizeDate(mcr.RecordDate); performanceSource = mcr.OnLifelength.ToRepeatIntervalsFormat(); remarksString = mcr.Remarks; if (mc.Grouping) { MaintenanceProgramChangeRecord mpcr = mc.ParentAircraft != null ? mc.ParentAircraft.MaintenanceProgramChangeRecords. GetLastKnownRecord(Convert.ToDateTime(mcr.RecordDate)) : null; if (mpcr == null || mpcr.MSG < MSG.MSG3) { var complianceItems = from compliance in grouping orderby compliance.OnLifelength.Hours descending select compliance; name += " (" + complianceItems.Aggregate("", (current, compliance) => current + (compliance.ParentCheck.Name + " ")) + ")"; } } } } ListViewItem listViewItem = new ListViewItem(num + type + resource + group) { Tag = grouping.ToList(), Group = listViewCompliance.Groups["last"], BackColor = backColor }; listViewItem.SubItems.Add(name); listViewItem.SubItems.Add(recordDate); listViewItem.SubItems.Add(performanceSource); listViewItem.SubItems.Add(remarksString); return(listViewItem); }
private void UpdateInformation() { if (_contextMenuStrip == null) { InitToolStripMenuItems(); } listViewCompliance.Items.Clear(); if (CheckItems == null) { return; } var lastRecords = new List <MaintenanceCheckRecord>(); var nextPerformances = new List <NextPerformance>(); //Поиск и заполнение просроченных директив и записей о перемещении //Объекты для в которые будет извлекаться информация //из записеи о перемещении string[] subs; ListViewItem newItem; var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_currentAircraft.AircraftFrameId); //прогнозируемый ресурс var forecastData = new ForecastData(DateTime.Now, aircraftFrame.AverageUtilization, GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentAircraft)); //GlobalObjects.CasEnvironment.Calculator.GetNextPerformanceGroup(CheckItems, _currentAircraft.Schedule, forecastData); foreach (MaintenanceCheck check in CheckItems) { if (check.Grouping) { foreach (MaintenanceNextPerformance mnp in check.GetPergormanceGroupWhereCheckIsSenior()) { //Добавляются все выполнения, дата которых меньше нынешней //плюс еще одно выполнение дата которого выше нынешней nextPerformances.Add(mnp); if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now) { break; } } } else { foreach (NextPerformance mnp in check.NextPerformances) { //Добавляются все выполнения, дата которых меньше нынешней //плюс еще одно выполнение дата которого выше нынешней nextPerformances.Add(mnp); if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now) { break; } } } lastRecords.AddRange(check.PerformanceRecords.ToArray()); foreach (MaintenanceDirective mpd in check.BindMpds) { GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd, forecastData); } } //////////////////////////////////////////// //загрузка рабочих пакетов для определения //перекрытых ими выполнений задач if (_openPubWorkPackages == null) { _openPubWorkPackages = new CommonCollection <WorkPackage>(); } _openPubWorkPackages.Clear(); _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Opened)); _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Published)); var allWorkPackagesIncludedTask = new CommonCollection <WorkPackage>(); var openPubWorkPackages = new CommonCollection <WorkPackage>(); var closedWorkPackages = new CommonCollection <WorkPackage>(); allWorkPackagesIncludedTask.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.All, CheckItems.Select(m => (IDirective)m).ToList())); #region Добавление в список просроченных выполнений //и сравнение их с открытыми и опубликованными рабочими пакетами openPubWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Opened || wp.Status == WorkPackageStatus.Published)); //сбор всех записей рабочих пакетов для удобства фильтрации List <WorkPackageRecord> openPubWPRecords = new List <WorkPackageRecord>(); foreach (WorkPackage openWorkPackage in openPubWorkPackages) { openPubWPRecords.AddRange(openWorkPackage.WorkPakageRecords); } //LINQ запрос для сортировки записей по дате List <NextPerformance> sortNextRecords = (from record in nextPerformances orderby record.GetPerformanceDateOrDefault() descending select record).ToList(); for (int i = 0; i < sortNextRecords.Count; i++) { //поиск записи в рабочих пакетах по данному чеку //чей номер группы выполнения (по записи) совпадает с расчитанным MaintenanceCheck check = (MaintenanceCheck)sortNextRecords[i].Parent; //if (check.Name == "5C") //{ //} //номер выполнения int parentCountPerf; if (check.LastPerformance != null) { parentCountPerf = check.LastPerformance.NumGroup <= 0 ? 1 : check.LastPerformance.NumGroup; } else { parentCountPerf = 0; } if (check.Grouping) { MaintenanceNextPerformance mnp = sortNextRecords[i] as MaintenanceNextPerformance; if (mnp != null) { parentCountPerf = mnp.PerformanceGroupNum; } else { parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]); parentCountPerf += 1; } } else { parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]); parentCountPerf += 1; } WorkPackageRecord wpr = openPubWPRecords.Where(r => r.PerformanceNumFromStart == parentCountPerf && r.WorkPackageItemType == check.SmartCoreObjectType.ItemId && r.DirectiveId == check.ItemId).FirstOrDefault(); if (wpr != null) { WorkPackage wp = openPubWorkPackages.GetItemById(wpr.WorkPakageId); //запись о выполнении блокируется найденым пакетом sortNextRecords[i].BlockedByPackage = wp; //последующие записи о выполнении так же должны быть заблокированы for (int j = i - 1; j >= 0; j--) { //блокировать нужно все рабочие записи, или до первой записи, //заблокированной другим рабочим пакетом if (sortNextRecords[j].BlockedByPackage != null && sortNextRecords[j].Parent == check || sortNextRecords[j].Condition != ConditionState.Overdue) { break; } if (sortNextRecords[j].Parent == check) { sortNextRecords[j].BlockedByPackage = wp; listViewCompliance.Items[j].BackColor = Color.FromArgb(Highlight.GrayLight.Color); } } } string type = check.Schedule ? " (Schedule) " : " (Store) "; string resource = check.Resource.ToString(); string grouping = check.Grouping ? " (Group)" : ""; string stringNumGr = (sortNextRecords[i] is MaintenanceNextPerformance ? ((MaintenanceNextPerformance)sortNextRecords[i]).PerformanceGroupNum.ToString() : "N/A") + type + resource + grouping; subs = new[] { stringNumGr, sortNextRecords[i].Title, sortNextRecords[i].PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)sortNextRecords[i].PerformanceDate) : "N/A", sortNextRecords[i].PerformanceSource.ToString(), "", }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["next"], Tag = sortNextRecords[i], BackColor = UsefulMethods.GetColor(sortNextRecords[i]) }; listViewCompliance.Items.Add(newItem); } #endregion #region Добавление в список записей о произведенных выполнениях //и сравнение их с закрытыми рабочими пакетами closedWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Closed)); //сбор всех записей рабочих пакетов для удобства фильтрации List <WorkPackageRecord> closedWPRecords = new List <WorkPackageRecord>(); foreach (WorkPackage closedWorkPackage in closedWorkPackages) { closedWPRecords.AddRange(closedWorkPackage.WorkPakageRecords); } List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>(); foreach (MaintenanceCheckRecord record in lastRecords) { //Поиск коллекции групп, в которую входят группы с нужными критериями //по плану, группировка и основному ресурсу if (record.ParentCheck.Grouping) { MaintenanceCheckRecordGroup recordGroup = maintenanceCheckRecordGroups .FirstOrDefault(g => g.Schedule == record.ParentCheck.Schedule && g.Grouping == record.ParentCheck.Grouping && g.Resource == record.ParentCheck.Resource && g.GroupComplianceNum == record.NumGroup); if (recordGroup != null) { //Коллекция найдена //Поиск в ней группы чеков с нужным типом recordGroup.Records.Add(record); } else { //Коллекции с нужными критериями нет //Созадние и добавление recordGroup = new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping, record.ParentCheck.Resource, record.NumGroup); recordGroup.Records.Add(record); maintenanceCheckRecordGroups.Add(recordGroup); } } else { MaintenanceCheckRecordGroup recordGroup = new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping, record.ParentCheck.Resource); recordGroup.Records.Add(record); maintenanceCheckRecordGroups.Add(recordGroup); } } List <object> tempRecords = new List <object>(); tempRecords.AddRange(maintenanceCheckRecordGroups.ToArray()); tempRecords.AddRange(_currentAircraft.MaintenanceProgramChangeRecords.ToArray()); List <object> sortLastRecords = tempRecords.OrderByDescending(tr => (tr is MaintenanceCheckRecordGroup ? ((MaintenanceCheckRecordGroup)tr).LastGroupComplianceDate : tr is AbstractRecord ? ((AbstractRecord)tr).RecordDate : DateTimeExtend.GetCASMinDateTime())) .ToList(); foreach (object t in sortLastRecords) { if (t is MaintenanceCheckRecordGroup) { MaintenanceCheckRecordGroup mcrg = (MaintenanceCheckRecordGroup)t; MaintenanceCheckRecord directiveRecord = mcrg.Records.First(); MaintenanceCheck parentDirective = (MaintenanceCheck)directiveRecord.Parent; newItem = GetListViewItem(mcrg); WorkPackage workPackage = closedWorkPackages.Where(wp => wp.ItemId == directiveRecord.DirectivePackageId).FirstOrDefault(); if (workPackage != null) { //запись о выполнении блокируется найденым пакетом directiveRecord.DirectivePackage = workPackage; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + parentDirective.Name + "\nadded by Work Package:" + "\n" + directiveRecord.DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package "; } listViewCompliance.Items.Add(newItem); } else if (t is MaintenanceProgramChangeRecord) { MaintenanceProgramChangeRecord mpcr = (MaintenanceProgramChangeRecord)t; subs = new[] { "N/A", "Changet to " + mpcr.MSG, UsefulMethods.NormalizeDate(mpcr.RecordDate), mpcr.OnLifelength.ToString(), "", }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["last"], Tag = mpcr, BackColor = Color.FromArgb(Highlight.GrayLight.Color) }; listViewCompliance.Items.Add(newItem); } } #endregion if (_toolStripMenuItemsWorkPackages != null) { foreach (ToolStripMenuItem item in _toolStripMenuItemsWorkPackages.DropDownItems) { item.Click -= AddToWorkPackageItemClick; } _toolStripMenuItemsWorkPackages.DropDownItems.Clear(); foreach (WorkPackage workPackage in _openPubWorkPackages) { ToolStripMenuItem item = new ToolStripMenuItem(workPackage.Title); item.Click += AddToWorkPackageItemClick; item.Tag = workPackage; _toolStripMenuItemsWorkPackages.DropDownItems.Add(item); } } ButtonAdd.Enabled = false; }
private ListViewItem GetListViewItem(MaintenanceCheck check) { ListViewItem listViewItem = new ListViewItem { Tag = check, Text = check.Name }; if (check.Grouping) { MaintenanceNextPerformance np = check.NextPerformances.FirstOrDefault() as MaintenanceNextPerformance; MaintenanceProgramChangeRecord mpcr = np != null && np.PerformanceDate != null ? _currentAircraft.MaintenanceProgramChangeRecords. GetLastKnownRecord(Convert.ToDateTime(np.PerformanceDate)) : null; if (mpcr != null && mpcr.MSG >= MSG.MSG3) { string lastPerformanceDate = "N/A"; string lastPerformanceSource = "N/A"; string lastPerformaceGroup = "N/A"; string lastCheckName = "N/A"; string nextPerformanceDate = "N/A"; string nextPerformanceSource = "N/A"; string nextPerformaceGroup = "N/A"; string nextCheckName = "N/A"; string remains = "N/A"; MaintenanceNextPerformance mnp = check.GetNextPergormanceGroupWhereCheckIsSenior(); if (mnp != null) { nextPerformanceDate = UsefulMethods.NormalizeDate(Convert.ToDateTime(mnp.PerformanceDate)); nextPerformanceSource = mnp.PerformanceSource.ToString(); nextPerformaceGroup = mnp.PerformanceGroupNum + "/" + mnp.PerformanceNum; nextCheckName = mnp.PerformanceGroup.GetGroupName(); remains = mnp.Remains.ToString(); } if (check.LastPerformance != null) { MaintenanceCheckRecord mcr = _checkItems.GetLastCheckRecordWhereCheckIsSenior(check); if (mcr != null) { lastPerformanceDate = UsefulMethods.NormalizeDate(mcr.RecordDate); lastPerformanceSource = mcr.OnLifelength.ToString(); lastPerformaceGroup = mcr.NumGroup + "/" + mcr.PerformanceNum; lastCheckName = _currentAircraft != null && _currentAircraft.MaintenanceProgramCheckNaming ? (!string.IsNullOrEmpty(mcr.ComplianceCheckName) ? mcr.ComplianceCheckName : check.Name) : check.Name; } } listViewItem.SubItems.Add(lastPerformanceDate); listViewItem.SubItems.Add(lastPerformanceSource); listViewItem.SubItems.Add(lastPerformaceGroup); listViewItem.SubItems.Add(lastCheckName); listViewItem.SubItems.Add(nextPerformanceDate); listViewItem.SubItems.Add(nextPerformanceSource); listViewItem.SubItems.Add(nextPerformaceGroup); listViewItem.SubItems.Add(nextCheckName); listViewItem.SubItems.Add(remains); } else { if (check.LastPerformance == null) { listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add(np != null && np.PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)np.PerformanceDate) : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceSource.ToString() : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceGroupNum + "/" + np.PerformanceNum : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceGroup.GetGroupName() : "N/A"); listViewItem.SubItems.Add(np != null ? np.Remains.ToString() : "N/A"); } else { string lastCheckName = _currentAircraft != null && _currentAircraft.MaintenanceProgramCheckNaming ? (!string.IsNullOrEmpty(check.LastPerformance.ComplianceCheckName) ? check.LastPerformance.ComplianceCheckName : check.Name) : check.Name; listViewItem.SubItems.Add(UsefulMethods.NormalizeDate(check.LastPerformance.RecordDate)); listViewItem.SubItems.Add(check.LastPerformance.OnLifelength.ToString()); listViewItem.SubItems.Add(check.LastPerformance.NumGroup + "/" + check.LastPerformance.PerformanceNum); listViewItem.SubItems.Add(lastCheckName); listViewItem.SubItems.Add(np != null && np.PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)np.PerformanceDate) : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceSource.ToString() : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceGroupNum + "/" + np.PerformanceNum : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceGroup.GetGroupName() : "N/A"); listViewItem.SubItems.Add(np != null ? np.Remains.ToString() : "N/A"); } } if (np != null && np.Condition == ConditionState.Overdue) { listViewItem.BackColor = Color.FromArgb(255, 170, 170); } else if (np != null && np.Condition == ConditionState.Notify) { listViewItem.BackColor = Color.FromArgb(255, 255, 170); } else if (np == null || np.Condition == ConditionState.NotEstimated) { listViewItem.BackColor = Color.FromArgb(170, 170, 255); } } else { NextPerformance np = check.NextPerformances.FirstOrDefault(); if (check.LastPerformance == null) { listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add(np != null && np.PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)np.PerformanceDate) : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceSource.ToString() : "N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add(np != null ? np.Remains.ToString() : "N/A"); } else { listViewItem.SubItems.Add(UsefulMethods.NormalizeDate(check.LastPerformance.RecordDate)); listViewItem.SubItems.Add(check.LastPerformance.OnLifelength.ToString()); listViewItem.SubItems.Add(check.LastPerformance.NumGroup.ToString()); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add(np != null && np.PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)np.PerformanceDate) : "N/A"); listViewItem.SubItems.Add(np != null ? np.PerformanceSource.ToString() : "N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add("N/A"); listViewItem.SubItems.Add(np != null ? np.Remains.ToString() : "N/A"); } if (np != null && np.Condition == ConditionState.Overdue) { listViewItem.BackColor = Color.FromArgb(255, 170, 170); } else if (np != null && np.Condition == ConditionState.Notify) { listViewItem.BackColor = Color.FromArgb(255, 255, 170); } else if (np == null || np.Condition == ConditionState.NotEstimated) { listViewItem.BackColor = Color.FromArgb(170, 170, 255); } } listViewItem.Group = GetGroup(check); return(listViewItem); }