public CAACourseCloseForm(SmartCore.CAA.CAAWP.CoursePackage currentWp) : this() { if (currentWp == null) { return; } _currentWp = currentWp; UpdateInformation(); }
///<summary> /// Создаёт экземпляр элемента управления, отображающего список директив ///</summary> ///<param name="currentOperator">ВС, которому принадлежат директивы</param>> public CourseRecordListScreen(Operator currentOperator, SmartCore.CAA.CAAWP.CoursePackage wp) : this() { if (currentOperator == null) { throw new ArgumentNullException("currentOperator"); } _wp = wp; aircraftHeaderControl1.Operator = currentOperator; statusControl.ShowStatus = false; labelTitle.Visible = false; _filter = new CommonFilterCollection(typeof(CourseRecord)); InitListView(); UpdateInformation(); }
private void ButtonCreateWorkPakageClick(object sender, EventArgs e) { if (_directivesViewer.SelectedItems.Count <= 0) { return; } var items = _directivesViewer.SelectedItems; var first = items.FirstOrDefault(); if (!items.All(i => i.Education?.Task.ItemId == first.Education?.Task.ItemId)) { MessageBox.Show("Not all educations has equality Task!", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("Create and save a Work Package?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var wp = new SmartCore.CAA.CAAWP.CoursePackage(); wp.OperatorId = _operatorId; wp.Settings.OpeningDate = DateTime.Now; wp.Settings.CreateDate = DateTime.Now; wp.Settings.Author = GlobalObjects.CaaEnvironment.IdentityUser.ItemId; wp.Settings.Number = $"{GlobalObjects.CaaEnvironment.ObtainId()}"; wp.Settings.TaskId = first.Education?.Task.ItemId; wp.Title = $"{first.Education?.Task.FullName} - {DateTime.Now:d}"; GlobalObjects.NewKeeper.Save(wp); foreach (var item in items) { if (item.Record == null) { item.Record = new CAAEducationRecord() { EducationId = item.Education.ItemId, OccupationId = item.Occupation.ItemId, SpecialistId = item.Specialist.ItemId, OperatorId = item.Specialist.OperatorId, PriorityId = item.Education.Priority.ItemId, Settings = new CAAEducationRecordSettings() { IsCombination = item.IsCombination, BlockedWpId = wp.ItemId } }; } else { item.Record.Settings.BlockedWpId = wp.ItemId; } GlobalObjects.NewKeeper.Save(item.Record); GlobalObjects.NewKeeper.Save(new CourseRecord() { ObjectId = item.Record.ItemId, WorkPackageId = wp.ItemId, SpecialistId = item.Specialist.ItemId, Parent = item, }); } _directivesViewer.UpdateItemColor(); //Добавление нового рабочего пакета в коллекцию открытых рабочих пакетов _openPubWorkPackages.Add(wp); //Создание пункта в меню открытых рабочих пакетов var raditem = new RadMenuItem(wp.Title); raditem.Click += AddToWorkPackageItemClick; raditem.Tag = wp; _toolStripMenuItemsWorkPackages.Items.Add(raditem); if (MessageBox.Show("Items added successfully. Open work package?", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { var refE = new ReferenceEventArgs(); refE.TypeOfReflection = ReflectionTypes.DisplayInNew; refE.DisplayerText = $"WP:{wp.Title}"; refE.RequestedEntity = new CourseRecordListScreen(CurrentOperator, wp); InvokeDisplayerRequested(refE); } } }