예제 #1
0
        /// <summary>
        ///
        /// </summary>
        private void GetRecordInstance(WorkPackageClosingDataGridViewRow row,
                                       Audit wp,
                                       NextPerformance nextPerformance = null,
                                       AuditRecord workPackageRecord   = null)
        {
            if (row.ClosingItem == null)
            {
                return;
            }

            IDirective currentClosingItem = row.ClosingItem;

            if (currentClosingItem is Procedure)
            {
                row.Record = new DirectiveRecord();
            }
            if (nextPerformance != null)
            {
                row.Record.PerformanceNum = nextPerformance.PerformanceNum;
            }
            if (workPackageRecord != null)
            {
                row.Record.PerformanceNum = workPackageRecord.PerformanceNumFromStart;
            }

            row.Record.Parent             = currentClosingItem;
            row.Record.ParentId           = currentClosingItem.ItemId;
            row.Record.DirectivePackageId = wp.ItemId;
        }
예제 #2
0
        private void SetValues(WorkPackageClosingDataGridViewRow row,
                               Audit wp,
                               AuditRecord workPackageRecord)
        {
            if (workPackageRecord != null)
            {
                row.WorkPackage = wp;
                row.ClosingItem = workPackageRecord.Task;
            }

            GetRecordInstance(row, wp, workPackageRecord: workPackageRecord);
            SetLabelsAndText(row);

            if (row.ClosingItem.IsClosed)
            {
                DataGridViewCell cell = row.Cells[ColumnClosed.Index];

                cell.Value           = false;
                cell.ReadOnly        = true;
                cell.Style.BackColor = Color.DimGray;
                cell.ToolTipText     = "This item is closed and can't be perform";

                SetCellReadOnly(row,
                                new[] {
                    ColumnClosed.Index,
                    ColumnHours.Index,
                    ColumnCycles.Index,
                    ColumnDays.Index,
                    ColumnDate.Index
                },
                                false);
            }
        }
예제 #3
0
        private void SetLabelsAndText(WorkPackageClosingDataGridViewRow row)
        {
            if (row.ClosingItem == null)
            {
                return;
            }

            IDirective closingItem = row.ClosingItem;

            if (closingItem is Procedure)
            {
                Procedure directive = (Procedure)closingItem;
                row.Cells[ColumnType.Index].Value = "Procedure: ";
                row.Cells[ColumnTask.Index].Value = directive.Title + " " + directive.ProcedureType;

                string taskCardCellValue;
                Color  taskCardCellBackColor = Color.White;

                if (string.IsNullOrEmpty(directive.CheckList) && directive.CheckListFile == null)
                {
                    taskCardCellValue     = "Not set Check List file.";
                    taskCardCellBackColor = Color.Red;
                }
                else if (!string.IsNullOrEmpty(directive.CheckList) && directive.CheckListFile == null)
                {
                    taskCardCellValue     = $"Not set Check List File. (Check List No {directive.CheckList}.)";
                    taskCardCellBackColor = Color.Red;
                }
                else if (string.IsNullOrEmpty(directive.CheckList) && directive.CheckListFile != null)
                {
                    taskCardCellValue     = $"Not set Check List name. (File name {directive.CheckListFile.FileName}.)";
                    taskCardCellBackColor = Color.Red;
                }
                else
                {
                    taskCardCellValue = directive.CheckList;
                }

                row.Cells[ColumnTaskCard.Index].Value           = taskCardCellValue;
                row.Cells[ColumnTaskCard.Index].Style.BackColor = taskCardCellBackColor;
            }
        }
예제 #4
0
        private void SetValues(WorkPackageClosingDataGridViewRow row,
                               Audit wp,
                               AbstractPerformanceRecord apr)
        {
            row.WorkPackage = wp;
            row.Record      = apr;
            if (apr != null)
            {
                row.ClosingItem = apr.Parent;
            }

            if (row.ClosingItem == null || apr == null)
            {
                return;
            }

            SetLabelsAndText(row);

            if (apr is DirectiveRecord || apr is MaintenanceCheckRecord)
            {
                row.Cells[ColumnClosed.Index].Value = true;
                //Lifelength performanceSource = apr.OnLifelength;
                //row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "n/a";
                //row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null ? performanceSource.Cycles.ToString() : "n/a";
                //row.Cells[ColumnDays.Index].Value = performanceSource.Days != null ? performanceSource.Days.ToString() : "n/a";
                row.Cells[ColumnDate.Index].Value = apr.RecordDate;

                row.PrevPerfDate = apr.PrevPerformanceDate;
                row.NextPerfDate = apr.NextPerformanceDate;
            }
            else if (apr is TransferRecord)
            {
                TransferRecord tr = (TransferRecord)apr;
                if (tr.ItemId > 0)
                {
                    //если запись о перемещении имеет itemID > 0
                    //и она не подтвержддена стороной получателя, то ее можно редактировать и удалять
                    //если подтверждена, то редактировать и удалять ее нельзя
                    if (tr.DODR)
                    {
                        row.Cells[ColumnHours.Index].ReadOnly = false;
                        row.PrevPerfDate = tr.PrevPerformanceDate;
                        row.NextPerfDate = tr.TransferDate;
                    }
                    else
                    {
                        row.Cells[ColumnHours.Index].ReadOnly = true;
                        row.PrevPerfDate = tr.PrevPerformanceDate;
                        row.NextPerfDate = tr.NextPerformanceDate;
                    }
                    row.Cells[ColumnCycles.Index].Value = "Transfer to: " + GetDestination(tr);
                    row.Cells[ColumnDate.Index].Value   = tr.StartTransferDate;
                }
                else
                {
                    row.Cells[ColumnCycles.Index].Value = "Transfer to: ";
                    row.PrevPerfDate = apr.PrevPerformanceDate;
                    row.NextPerfDate = apr.NextPerformanceDate;
                }
                row.Cells[ColumnClosed.Index].Value = true;
            }

            DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell;

            if (cc != null)
            {
                if (row.PrevPerfDate != null)
                {
                    cc.MinDate = (DateTime)row.PrevPerfDate;
                }
                else
                {
                    cc.MinDate = DateTimeExtend.GetCASMinDateTime();
                }
                if (row.NextPerfDate != null)
                {
                    cc.MaxDate = (DateTime)row.NextPerfDate;
                }
                else
                {
                    cc.MaxDate = DateTime.Now;
                }
            }

            row.MinPerfSource = apr.PrevPerformanceSource.IsNullOrZero()
                                                                        ? Lifelength.Zero
                                                                        : apr.PrevPerformanceSource;
            row.MaxPerfSource = apr.NextPerformanceSource.IsNullOrZero()
                                //TODO:(Evgenii Babak) пересмотреть подход, наработка считается на конец дня, а в метод передаем DateTime.Now(может быть и концом дня)
                                                                        ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now)
                                                                        : apr.NextPerformanceSource;
        }
예제 #5
0
        private void SetValues(WorkPackageClosingDataGridViewRow row,
                               Audit wp,
                               NextPerformance nextPerformance)
        {
            row.WorkPackage     = wp;
            row.NextPerformance = nextPerformance;
            if (row.NextPerformance != null)
            {
                row.ClosingItem = nextPerformance.Parent;
            }

            GetRecordInstance(row, wp, nextPerformance);
            SetLabelsAndText(row);

            if (row.ClosingItem == null)
            {
                return;
            }

            if (row.ClosingItem.IsClosed)
            {
                DataGridViewCell cell = row.Cells[ColumnClosed.Index];

                cell.Value           = false;
                cell.ReadOnly        = true;
                cell.Style.BackColor = Color.DimGray;
                cell.ToolTipText     = "This item is closed and can't be perform";

                SetCellReadOnly(row,
                                new[] {
                    ColumnClosed.Index,
                    ColumnHours.Index,
                    ColumnCycles.Index,
                    ColumnDays.Index,
                    ColumnDate.Index
                },
                                false);
            }

            if (nextPerformance == null)
            {
                return;
            }

            row.PrevPerfDate  = nextPerformance.PrevPerformanceDate;
            row.NextPerfDate  = nextPerformance.NextPerformanceDate;
            row.MinPerfSource = nextPerformance.PrevPerformanceSource.IsNullOrZero()
                                                                        ? Lifelength.Zero
                                                                        : nextPerformance.PrevPerformanceSource;
            row.MaxPerfSource = nextPerformance.NextPerformanceSource.IsNullOrZero()
                                                                        ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now)
                                                                        : nextPerformance.NextPerformanceSource;

            row.Cells[ColumnClosed.Index].Value = true;
            //if(!(row.ClosingItem is Detail))
            //{
            //    Lifelength performanceSource = nextPerformance.PerformanceSource;
            //    row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "n/a";
            //    row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null ? performanceSource.Cycles.ToString() : "n/a";
            //    row.Cells[ColumnDays.Index].Value = performanceSource.Days != null ? performanceSource.Days.ToString() : "n/a";
            //}
            if (nextPerformance.PerformanceDate != null)
            {
                row.Cells[ColumnDate.Index].Value = (DateTime)nextPerformance.PerformanceDate;
            }

            DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell;

            if (cc != null)
            {
                if (row.PrevPerfDate != null)
                {
                    cc.MinDate = (DateTime)row.PrevPerfDate;
                }
                else
                {
                    cc.MinDate = DateTimeExtend.GetCASMinDateTime();
                }

                if (row.NextPerfDate != null)
                {
                    cc.MaxDate = (DateTime)row.NextPerfDate;
                }
                else
                {
                    cc.MaxDate = DateTime.Now;
                }
            }
        }
예제 #6
0
        ///<summary>
        ///</summary>
        private void UpdateInformation()
        {
            if (_currentAudit == null)
            {
                return;
            }

            Text = _currentAudit.Title;
            dataGridViewItems.Rows.Clear();

            DateTime minComplianceDate = DateTimeExtend.GetCASMinDateTime();

            IEnumerable <AuditRecord> proceduresRecords =
                _currentAudit.AuditRecords.Where(wpr => wpr.Task != null &&
                                                 wpr.Task is Procedure);

            List <IGrouping <string, AuditRecord> > groupedDirectiveWprs =
                proceduresRecords.GroupBy(wpr => (((Procedure)wpr.Task).ProcedureType).FullName).ToList();

            checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged;

            foreach (IGrouping <string, AuditRecord> grouping in groupedDirectiveWprs)
            {
                //добавить расчеты ComlianceDate
                foreach (AuditRecord item in grouping)
                {
                    if (item.Task is Procedure ||
                        item.Task is Directive ||
                        item.Task is ComponentDirective ||
                        item.Task is MaintenanceCheck ||
                        item.Task is MaintenanceDirective)
                    {
                        //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow();
                        //r.CreateCells(dataGridViewItems);
                        //int index = dataGridViewItems.Rows.Add(r);
                        //index.ToString();

                        WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow)
                                                              dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())];
                        if (item.Task.NextPerformances.Count > 0)
                        {
                            SetValues(r, _currentAudit, item.Task.NextPerformances[0]);
                        }
                        else if (item.Task.PerformanceRecords.Cast <AbstractPerformanceRecord>().Any(pr => pr.DirectivePackageId == _currentAudit.ItemId))
                        {
                            AbstractPerformanceRecord apr =
                                item.Task.PerformanceRecords
                                .Cast <AbstractPerformanceRecord>()
                                .First(pr => pr.DirectivePackageId == _currentAudit.ItemId);
                            SetValues(r, _currentAudit, apr);
                        }
                        else
                        {
                            SetValues(r, _currentAudit, item);
                        }
                    }

                    if (item.Task is Component)
                    {
                        //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow();
                        //r.CreateCells(dataGridViewItems);
                        //dataGridViewItems.Rows.Add(r);

                        WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow)
                                                              dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())];

                        Component component = (Component)item.Task;
                        if (component.NextPerformances.Count > 0)
                        {
                            SetValues(r, _currentAudit, component.NextPerformances[0]);
                        }
                        else if (component.TransferRecords.Any(pr => pr.DirectivePackageId == _currentAudit.ItemId))
                        {
                            AbstractPerformanceRecord apr =
                                component.TransferRecords
                                .Cast <AbstractPerformanceRecord>()
                                .First(pr => pr.DirectivePackageId == _currentAudit.ItemId);
                            SetValues(r, _currentAudit, apr);
                        }
                        else
                        {
                            SetValues(r, _currentAudit, item);
                        }
                    }
                }
            }

            dateTimePickerClosingDate.ValueChanged -= DateTimePickerClosingDateValueChanged;

            dateTimePickerClosingDate.Value = _currentAudit.Status != WorkPackageStatus.Closed
                                ? minComplianceDate
                                : _currentAudit.ClosingDate;
            dateTimePickerClosingDate.MinDate = _currentAudit.MinClosingDate != null
                                ? _currentAudit.MinClosingDate.Value
                                : DateTimeExtend.GetCASMinDateTime();
            dateTimePickerClosingDate.MaxDate = _currentAudit.MaxClosingDate != null
                                ? _currentAudit.MaxClosingDate.Value
                                : DateTimeExtend.GetCASMinDateTime();

            dateTimePickerClosingDate.ValueChanged += DateTimePickerClosingDateValueChanged;

            checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged;

            fileControl.AttachedFile = _currentAudit.AttachedFile;
        }
예제 #7
0
        private void DataGridViewItemsCellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            #region             //Проверка колонки "Выполнено"
            if (e.ColumnIndex == ColumnClosed.Index)
            {
                checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged;

                IEnumerable <WorkPackageClosingDataGridViewRow> rows =
                    dataGridViewItems.Rows.OfType <WorkPackageClosingDataGridViewRow>();
                bool checkedValue   = rows.FirstOrDefault(r => (bool)r.Cells[ColumnClosed.Index].Value) != null;
                bool unCheckedValue = rows.FirstOrDefault(r => !(bool)r.Cells[ColumnClosed.Index].Value) != null;
                if (checkedValue && unCheckedValue)
                {
                    checkBoxSelectAll.CheckState = CheckState.Indeterminate;
                }
                else if (checkedValue)
                {
                    checkBoxSelectAll.CheckState = CheckState.Checked;
                }
                else
                {
                    checkBoxSelectAll.CheckState = CheckState.Unchecked;
                }

                checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged;
            }
            #endregion

            #region             //Проверка колонки "Часы"
            if (e.ColumnIndex == ColumnHours.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }
                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateHours(value))
                {
                    int?totalMinutes = Lifelength.ParseTotalMinutes(value);
                    if (totalMinutes == null)
                    {
                        return;
                    }

                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.TotalMinutes != null &&
                        row.MinPerfSource.TotalMinutes > totalMinutes)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Циклы"
            if (e.ColumnIndex == ColumnCycles.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }

                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateCyclesOrDays(value))
                {
                    int?cycles = Lifelength.ParseCyclesOrDays(value);
                    if (cycles == null)
                    {
                        return;
                    }
                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.Cycles != null &&
                        row.MinPerfSource.Cycles > cycles)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Дни"
            if (e.ColumnIndex == ColumnDays.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }

                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateCyclesOrDays(value))
                {
                    int?cycles = Lifelength.ParseCyclesOrDays(value);
                    if (cycles == null)
                    {
                        return;
                    }
                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.Days != null &&
                        row.MinPerfSource.Days > cycles)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Дата"

            if (e.ColumnIndex == ColumnDate.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row != null && !(row.ClosingItem is Component))
                {
                    DateTime dateTime = Convert.ToDateTime(row.Cells[ColumnDate.Index].Value);

                    if (row.PrevPerfDate != null && dateTime < row.PrevPerfDate)
                    {
                        row.Cells[ColumnDate.Index].Value = row.PrevPerfDate.Value;
                    }
                    else if (dateTime < new DateTime(1950, 1, 1))
                    {
                        row.Cells[ColumnDate.Index].Value = DateTimeExtend.GetCASMinDateTime();
                    }
                    if (row.NextPerfDate != null && dateTime > row.NextPerfDate)
                    {
                        row.Cells[ColumnDate.Index].Value = row.NextPerfDate.Value;
                    }
                    else if (dateTime > DateTime.Now)
                    {
                        row.Cells[ColumnDate.Index].Value = DateTime.Now;
                    }

                    if (row.ClosingItem.LifeLengthParent is Operator)
                    {
                        row.Cells[ColumnHours.Index].Value  = "n/a";
                        row.Cells[ColumnCycles.Index].Value = "n/a";
                        row.Cells[ColumnDays.Index].Value   = "n/a";
                    }
                    else
                    {
                        Lifelength performanceSource =
                            GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(row.ClosingItem.LifeLengthParent, dateTime);
                        row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null?performanceSource.ToHoursMinutesFormat("") : "n/a";

                        row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null?performanceSource.Cycles.ToString() : "n/a";

                        row.Cells[ColumnDays.Index].Value = performanceSource.Days != null?performanceSource.Days.ToString() : "n/a";
                    }
                }
            }
            #endregion
        }