示例#1
0
        /// <summary>
        /// Сохраняет данные текущей директивы
        /// </summary>
        protected bool Save()
        {
            double d;

            if (!generalDataAndPerformanceControl.CheckManHours(out d) || !generalDataAndPerformanceControl.CheckCost(out d) || !generalDataAndPerformanceControl.CheckLifelengthes())
            {
                return(false);
            }
            if (generalDataAndPerformanceControl.GetChangeStatus(true) || attributesAndParametersControl.GetChangeStatus(true) || currentDirective.Modified)
            {
                SaveData();
            }
            return(true);
        }
示例#2
0
        protected bool AddNewDirective(bool changePageName)
        {
            double d;

            if (generalDataAndPerformanceControl.ATAChapter == null)
            {
                MessageBox.Show("Please select ATA chapter", (string)new TermsProvider()["SystemName"],
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            if (!generalDataAndPerformanceControl.CheckManHours(out d) ||
                !generalDataAndPerformanceControl.CheckCost(out d) ||
                !generalDataAndPerformanceControl.CheckLifelengthes())
            {
                return(false);
            }
            try
            {
                if (currentDirectiveContainer is Aircraft && directiveApplicabilityControl != null)
                {
                    List <ApplicabilityItem> items = directiveApplicabilityControl.ApplicabilityItems;
                    for (int i = 0; i < items.Count; i++)
                    {
                        BaseDetailDirective directive;
                        if (items[i].Aircraft.ID == ((Aircraft)currentDirectiveContainer).ID)
                        {
                            directive = addedDirective;
                        }
                        else
                        {
                            directive = new BaseDetailDirectiveProxy();
                            directive.SetDirectiveType(CurrentDirectiveType);
                        }
                        generalDataAndPerformanceControl.SaveData(directive, changePageName);
                        attributesAndParametersControl.SaveData(directive);
                        items[i].Aircraft.Add(directive);
                        // generalDataAndPerformanceControl.SaveData(directive, changePageName);
                        if (items[i].RecordType == RecordTypesCollection.Instance.DirectiveNotApplicableRecordType)
                        {
                            directive.AddRecord(RecordTypesCollection.Instance.DirectiveNotApplicableRecordType, "");
                        }
                        else if (items[i].RecordType == RecordTypesCollection.Instance.DirectiveTerminatingType)
                        {
                            directive.AddRecord(RecordTypesCollection.Instance.DirectiveTerminatingType, "");
                        }
                        else if (items[i].RecordType == RecordTypesCollection.Instance.DirectiveClosingRecordType)
                        {
                            directive.AddRecord(RecordTypesCollection.Instance.DirectiveClosingRecordType, "");
                        }
                        if (addedDirective.DirectiveType == DirectiveTypeCollection.Instance.SBDirectiveType || addedDirective.DirectiveType == DirectiveTypeCollection.Instance.ADDirectiveType)
                        {
                            if (generalDataAndPerformanceControl.Supersedes != "" && directive == addedDirective)//todo убрать
                            {
                                BaseDetailDirective supersedesDirective = GetDirectiveByTitle(generalDataAndPerformanceControl.Supersedes, directive);
                                if (supersedesDirective != null)
                                {
                                    if (directive.Paragraph == "" && supersedesDirective.Paragraph == "")
                                    {
                                        supersedesDirective.SupersededBy = directive.Title;
                                        supersedesDirective.Save();
                                    }
                                    DirectiveRecord record = new DirectiveRecord();
                                    record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType;
                                    supersedesDirective.AddRecord(record);
                                }
                            }
                            if (generalDataAndPerformanceControl.SupersededBy != "")
                            {
                                BaseDetailDirective supersededByDirective = null;
                                if (directive == addedDirective)//todo убрать
                                {
                                    supersededByDirective = GetDirectiveByTitle(generalDataAndPerformanceControl.SupersededBy, directive);
                                    if (supersededByDirective != null)
                                    {
                                        if (directive.Paragraph == "" && supersededByDirective.Paragraph == "")
                                        {
                                            supersededByDirective.Supersedes = directive.Title;
                                            supersededByDirective.Save();
                                        }
                                    }
                                }
                                DirectiveRecord record = new DirectiveRecord();
                                record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType;
                                directive.AddRecord(record);
                            }
                        }
                    }
                }
                else
                {
                    generalDataAndPerformanceControl.SaveData(addedDirective, changePageName);
                    attributesAndParametersControl.SaveData(addedDirective);
                    currentDirectiveContainer.Add(addedDirective);
                    if (addedDirective.DirectiveType == DirectiveTypeCollection.Instance.SBDirectiveType || addedDirective.DirectiveType == DirectiveTypeCollection.Instance.ADDirectiveType)
                    {
                        if (generalDataAndPerformanceControl.Supersedes != "")
                        {
                            BaseDetailDirective directive = GetDirectiveByTitle(generalDataAndPerformanceControl.Supersedes, addedDirective);
                            if (directive != null)
                            {
                                directive.SupersededBy = addedDirective.Title;
                                directive.Save();
                                DirectiveRecord record = new DirectiveRecord();
                                record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType;
                                directive.AddRecord(record);
                            }
                        }
                        if (generalDataAndPerformanceControl.SupersededBy != "")
                        {
                            BaseDetailDirective directive = GetDirectiveByTitle(generalDataAndPerformanceControl.SupersededBy, addedDirective);
                            if (directive != null)
                            {
                                if (addedDirective.Paragraph == "" && directive.Paragraph == "")
                                {
                                    directive.Supersedes = addedDirective.Title;
                                }
                                directive.Save();
                                DirectiveRecord record = new DirectiveRecord();
                                record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType;
                                addedDirective.AddRecord(record);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while saving data", ex);
                return(false);
            }
            return(true);
        }