protected bool AddNewDirective(bool changePageName) { generalDataAndPerformanceControl.SaveData(addedDirective, changePageName); addedDirective.FirstPerformSinceNew = new Lifelength(generalDataAndPerformanceControl.Frequency); parentBaseDetail.Add(addedDirective); return(true); }
protected bool AddNewDirective(bool changePageName) { if (generalDataAndPerformanceControl.Description == "") { MessageBox.Show("You should enter Title", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (generalDataAndPerformanceControl.RepeatInterval == null) { MessageBox.Show("You should enter Repeat Interval", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (!generalDataAndPerformanceControl.SaveData(addedDirective, changePageName)) { return(false); } addedDirective.FirstPerformSinceNew = new Lifelength(generalDataAndPerformanceControl.RepeatInterval); if (parentBaseDetail is Aircraft) { addedDirective.EffectivityDate = ((Aircraft)parentBaseDetail).ManufactureDate; } else { addedDirective.EffectivityDate = ((BaseDetail)parentBaseDetail).ParentAircraft.ManufactureDate; } addedDirective.PerformSinceEffectivityDate = true; addedDirective.RepeatedlyPerform = true; parentBaseDetail.Add(addedDirective); /* if (addedDirective.DirectiveType == DirectiveTypeCollection.Instance.SBDirectiveType) * { * if (generalDataAndPerformanceControl.Supersedes != "") * { * BaseDetailDirective directive = GetSBDirectiveByTitle(generalDataAndPerformanceControl.Supersedes); * if (directive != null) * { * directive.SupersededBy = currentDirective.Title; * directive.Save(); * DetailRecord record = new DetailRecord(); * record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType; * directive.AddRecord(record); * } * } * if (generalDataAndPerformanceControl.SupersededBy != "") * { * BaseDetailDirective directive = * GetSBDirectiveByTitle(generalDataAndPerformanceControl.SupersededBy); * if (directive != null) * { * directive.Supersedes = currentDirective.Title; * directive.Save(); * DetailRecord record = new DetailRecord(); * record.RecordType = RecordTypesCollection.Instance.DirectiveSupersedingRecordType; * currentDirective.AddRecord(record); * } * } * }*/ return(true); }
protected bool AddNewDirective(bool changePageName) { if (generalDataAndPerformanceControl.CPCPNumber == "") { MessageBox.Show("You should enter CPCP Number", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (generalDataAndPerformanceControl.RepeatInterval == null) { MessageBox.Show("You should enter Repeat Interval", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (!generalDataAndPerformanceControl.SaveData(addedDirective, changePageName)) { return(false); } addedDirective.FirstPerformSinceNew = new Lifelength(generalDataAndPerformanceControl.RepeatInterval); parentBaseDetail.Add(addedDirective); return(true); }
private 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); } else { generalDataAndPerformanceControl.SaveData(addedDirective, changePageName); attributesAndParametersControl.SaveData(addedDirective); parentBaseDetail.Add(addedDirective); return(true); } }
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); }