private ContextMenuStrip CreateContextMenuToLandingGear(TemplateGearAssembly gearAssembly) { ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem titleToolStripMenuItem = new ToolStripMenuItem(); ToolStripMenuItem addComponentToolStripMenuItem1 = new ToolStripMenuItem(); ToolStripMenuItem deleteToolStripMenuItem = new ToolStripMenuItem(); ToolStripSeparator toolStripSeparator1 = new ToolStripSeparator(); // // titleToolStripMenuItem // titleToolStripMenuItem.Text = gearAssembly.ToString(); titleToolStripMenuItem.Click += titleToolStripMenuItem_Click; // // addComponentToolStripMenuItem1 // addComponentToolStripMenuItem1.Text = "Add component"; addComponentToolStripMenuItem1.Click += addComponentToolStripMenuItem1_Click; // // deleteToolStripMenuItem // deleteToolStripMenuItem.Text = "Delete"; deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click; // // LandingGearsButtonsControl // addComponentToolStripMenuItem1.Enabled = DetailCollection.HasAccess(Users.CurrentUser.Role, DataEvent.Create); deleteToolStripMenuItem.Enabled = BaseDetailCollection.HasAccess(Users.CurrentUser.Role, DataEvent.Remove); contextMenuStrip.Items.AddRange(new ToolStripItem[] { titleToolStripMenuItem, toolStripSeparator1, addComponentToolStripMenuItem1, deleteToolStripMenuItem }); return(contextMenuStrip); }
/// <summary> /// Сохранаяет данные заданного шаблонного агрегата /// </summary> /// <param name="detail">Агрегат</param> /// <param name="changePageName">Менять ли название вкладки</param> public void SaveData(TemplateAbstractDetail detail, bool changePageName) { if (detail == null) { throw new ArgumentNullException("detail"); } int amount; CheckAmount(out amount); if (textBoxPartNo.Text != detail.PartNumber) { detail.PartNumber = textBoxPartNo.Text; if (changePageName) { string caption; if (detail is TemplateBaseDetail) { caption = ((TemplateBaseDetail)detail).ParentAircraft.Model + ". Component PN " + detail.PartNumber; } else { if (detail.Parent != null) { caption = ((TemplateAircraft)detail.Parent.Parent).Model + ". Component PN " + detail.PartNumber; } else { caption = "Component PN " + detail.PartNumber; } } if (DisplayerRequested != null) { DisplayerRequested(this, new ReferenceEventArgs(null, ReflectionTypes.ChangeTextOfContainingDisplayer, caption)); } } } if (detail is TemplateDetail) { TemplateDetail det = (TemplateDetail)detail; det.AtaChapter = ATAChapter; } if (textBoxDescription.Text != detail.Description) { detail.Description = textBoxDescription.Text; } if (detail is TemplateGearAssembly) { TemplateGearAssembly gearAssembly = (TemplateGearAssembly)detail; if (gearAssembly.LandingGearMark != LandingGearMark) { gearAssembly.LandingGearMark = LandingGearMark; } } if (textBoxModel.Text != detail.Model) { detail.Model = textBoxModel.Text; } if (textBoxManufacturer.Text != detail.Manufacturer) { detail.Manufacturer = textBoxManufacturer.Text; } if (MaintenanceType != detail.MaintenanceType) { detail.MaintenanceType = MaintenanceType; } if (textBoxAmount.Text != detail.Amount.ToString()) { detail.Amount = amount; } if (textBoxRemarks.Text != detail.Remarks) { detail.Remarks = textBoxRemarks.Text; } if (checkBoxHoursApplicable.Checked != detail.Lifelength.IsHoursApplicable) { detail.Lifelength.IsHoursApplicable = checkBoxHoursApplicable.Checked; } if (checkBoxCyclesApplicable.Checked != detail.Lifelength.IsCyclesApplicable) { detail.Lifelength.IsCyclesApplicable = checkBoxCyclesApplicable.Checked; } if (checkBoxCalendarApplicable.Checked != detail.Lifelength.IsCalendarApplicable) { detail.Lifelength.IsCalendarApplicable = checkBoxCalendarApplicable.Checked; } }