示例#1
0
        private void ButtonRegisterActualStateClick(object sender, EventArgs e)
        {
            List <MaintenanceCheckRecord> records =
                CheckItems.Where(c => c.Grouping)
                .SelectMany(c => c.PerformanceRecords)
                .ToList();
            List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>();

            foreach (MaintenanceCheckRecord record in records)
            {
                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);
                }
            }

            MaintenanceProgramChangeDialog actualStateDialog =
                new MaintenanceProgramChangeDialog(_currentAircraft, maintenanceCheckRecordGroups)
            {
                Text = "Add new Maintenance program change record"
            };

            actualStateDialog.ShowDialog();
            if (actualStateDialog.DialogResult == DialogResult.OK)
            {
                InvokeComplianceAdded(null);
            }
        }
示例#2
0
        private void Edit()
        {
            DialogResult dlgResult = DialogResult.None;

            if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["overdue"])
            {
                MaintenanceComplainceForm complainceForm =
                    new MaintenanceComplainceForm(_currentAircraft, (MaintenanceCheckGroupByType)listViewCompliance.SelectedItems[0].Tag);
                dlgResult = complainceForm.ShowDialog(this);
            }
            else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["next"])
            {
                if (listViewCompliance.SelectedItems[0].Tag is NextPerformance)
                {
                    NextPerformance np = (NextPerformance)listViewCompliance.SelectedItems[0].Tag;
                    //if (np.Condition != ConditionState.Overdue || np.PerformanceDate > DateTime.Now)
                    //{
                    //    MessageBox.Show("You can not enter a record for not delayed performance",
                    //                    (string)new GlobalTermsProvider()["SystemName"],
                    //                    MessageBoxButtons.OK,
                    //                    MessageBoxIcon.Warning,
                    //                    MessageBoxDefaultButton.Button1);
                    //    return;
                    //}
                    if (np.BlockedByPackage != null)
                    {
                        MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text +
                                        "\nblocked by Work Package:" +
                                        "\n" + np.BlockedByPackage.Title,
                                        (string)new GlobalTermsProvider()["SystemName"],
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);
                        return;
                    }
                }

                if (listViewCompliance.SelectedItems[0].Tag is MaintenanceNextPerformance)
                {
                    MaintenanceNextPerformance mnp = listViewCompliance.SelectedItems[0].Tag as MaintenanceNextPerformance;
                    if (mnp.PerformanceGroup == null)
                    {
                        return;
                    }
                    MaintenanceCheckGroupByType pg             = mnp.PerformanceGroup;
                    MaintenanceComplainceForm   complainceForm = new MaintenanceComplainceForm(_currentAircraft, pg);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                else if (listViewCompliance.SelectedItems[0].Tag is NextPerformance)
                {
                    NextPerformance np = listViewCompliance.SelectedItems[0].Tag as NextPerformance;
                    if (np.Parent == null)
                    {
                        return;
                    }
                    MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, np);
                    dlgResult = complainceForm.ShowDialog(this);
                }
            }
            else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["last"])
            {
                if (listViewCompliance.SelectedItems[0].Tag is List <MaintenanceCheckRecord> )
                {
                    MaintenanceComplainceForm complainceForm =
                        new MaintenanceComplainceForm(_currentAircraft, (List <MaintenanceCheckRecord>)listViewCompliance.SelectedItems[0].Tag);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                else if (listViewCompliance.SelectedItems[0].Tag is MaintenanceProgramChangeRecord)
                {
                    List <MaintenanceCheckRecord> records =
                        CheckItems.Where(c => c.Grouping)
                        .SelectMany(c => c.PerformanceRecords)
                        .ToList();
                    List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>();

                    foreach (MaintenanceCheckRecord record in records)
                    {
                        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);
                        }
                    }
                    MaintenanceProgramChangeDialog complainceForm =
                        new MaintenanceProgramChangeDialog((MaintenanceProgramChangeRecord)listViewCompliance.SelectedItems[0].Tag,
                                                           maintenanceCheckRecordGroups);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                //MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm
                //{
                //    PerformanceRecords = ((List<MaintenanceCheckRecord>)
                //                     listViewCompliance.SelectedItems[0].Tag),
                //    CurrentAircraft = this.CurentAircraft,
                //    NumGroup = ((List<MaintenanceCheckRecord>)
                //        listViewCompliance.SelectedItems[0].Tag)[0].NumGroup
                //};
                // dlgResult = complainceForm.ShowDialog(this);
            }
            if (dlgResult == DialogResult.OK)
            {
                InvokeComplianceAdded(null);
            }
        }