private void DoWork() { _addedRecord.Clear(); _supplierShipper.Clear(); _supplierShipper.AddRange(GlobalObjects.CasEnvironment.Loader.GetObjectList <Supplier>(new ICommonFilter[] { new CommonFilter <int>(Supplier.SupplierClassProperty, SupplierClass.Shipper.ItemId) })); _order.ShipCompany = _supplierShipper.FirstOrDefault(i => i.ItemId == _order.ShipCompanyId) ?? Supplier.Unknown; _setting = GlobalObjects.CasEnvironment.NewLoader.GetObject <SettingDTO, Settings>(); if (_setting == null) { _setting = new Settings(); } foreach (var record in _order.AdditionalInformation.PurchaseShippers) { record.Shipper = _supplierShipper.FirstOrDefault(i => i.ItemId == record.ShipperId) ?? Supplier.Unknown; record.Currency = Сurrency.GetItemById(record.CurrencyId); record.PONumber = _order.Number; } _addedRecord.AddRange(_order.AdditionalInformation.PurchaseShippers); }
/// <summary> /// Загружает данные из экзепляра Supplier в контролы для редактирования /// </summary> private void UpdateInformation() { _courses.Clear(); var ds = GlobalObjects.CaaEnvironment.Execute($" select ItemId from [dbo].[CoursePackage] where JSON_VALUE(JSON_QUERY(SettingsJSON, '$.Offering'), '$.ProviderId') = {_currentSupplier.ItemId}"); var data = ds.Tables[0].AsEnumerable().Select(dataRow => new { ItemId = dataRow.Field <int>("ItemId") }); if (data.Any()) { _initialDocumentArray.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <CoursePackageDTO, SmartCore.CAA.CAAWP.CoursePackage>(new Filter("ItemId", data.Select(i => i.ItemId)))); foreach (var package in _initialDocumentArray) { _courses.Add(new SupplierCourse() { No = package.Settings.Number, Title = package.Title, Total = package.Settings.Offering?.Total, PerOne = package.Settings.Offering?.PerOne, Currency = Сurrency.GetItemById(package.Settings.Offering.TotalCurrency).ShortName, Duration = package.Settings.Offering?.Duration.ToString(), Location = package.Settings.Offering?.Location, }); } } textBoxName.Text = _currentSupplier.Name; textBoxShortName.Text = _currentSupplier.ShortName; textBoxAirCode.Text = _currentSupplier.AirCode; textBoxVendorCode.Text = _currentSupplier.VendorCode; textBoxPhone.Text = _currentSupplier.Phone; textBoxFax.Text = _currentSupplier.Fax; textBoxAddress.Text = _currentSupplier.Address; textBoxAccount.Text = _currentSupplier.ContactPerson; textBoxEmail.Text = _currentSupplier.Email; textBoxWebSite.Text = _currentSupplier.WebSite; textBoxRemarks.Text = _currentSupplier.Remarks; textBoxSubject.Text = _currentSupplier.Subject; checkBoxApproved.Checked = _currentSupplier.Approved; var fca = (FormControlAttribute) typeof(Supplier) .GetProperty("SupplierClass") .GetCustomAttributes(typeof(FormControlAttribute), false) .FirstOrDefault(); if (fca != null) { comboBoxSupplierClass.RootNodesNames = fca.TreeDictRootNodes; } comboBoxSupplierClass.Type = typeof(SupplierClass); comboBoxSupplierClass.SelectedItem = _currentSupplier.SupplierClass; _documents.Clear(); _documents.AddRange(_currentSupplier.SupplierDocs.ToArray()); documentationListView.SetItemsArray(_documents.ToArray()); // dataGridViewControlSuppliers.ViewedTypeProperties.Clear(); // dataGridViewControlSuppliers.ViewedTypeProperties.AddRange(new[] // { // Product.NameProperty, // Product.PartNumberProperty, // Product.DescriptionProperty, // }); // dataGridViewControlSuppliers.ViewedType = typeof(Product); dataGridViewControlSuppliers.SetItemsArray(_courses.ToArray()); documentationListView.Focus(); }
private void UpdateInformation() { var providers = GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAASupplierDTO, Supplier>(new Filter("SupplierClassId", 100)); comboBoxProvider.Items.Clear(); comboBoxProvider.Items.AddRange(providers.ToArray()); comboBoxProvider.Items.Add(Supplier.Unknown); comboBoxProvider.SelectedItem = providers.FirstOrDefault(i => i.ItemId == _currentWp.Settings.Offering.ProviderId) ?? Supplier.Unknown; comboBoxTotal.Items.Clear(); comboBoxTotal.Items.AddRange(Сurrency.Items.ToArray()); comboBoxTotal.SelectedItem = Сurrency.UNK; if (_currentWp.ItemId <= 0) { _currentWp.Settings.Number = $"{GlobalObjects.CaaEnvironment.ObtainId()} {DateTime.Now:G}"; } var author = GlobalObjects.CaaEnvironment?.GetCorrector(_currentWp.Settings.Author); var published = GlobalObjects.CaaEnvironment?.GetCorrector(_currentWp.Settings.PublishedBy); var closed = GlobalObjects.CaaEnvironment?.GetCorrector(_currentWp.Settings.ClosedBy); textBoxWpNumber.Text = _currentWp.Settings.Number; textBoxDescription.Text = _currentWp.Settings.Description; dateTimePickerIssueCreateDate.Value = _currentWp.Settings.CreateDate; dateTimePickerPublishingDate.Value = _currentWp.Settings.PublishingDate ?? SmartCore.Auxiliary.DateTimeExtend.GetCASMinDateTime(); textBoxAuthor.Text = author; textBoxClosedBy.Text = closed; textBoxPublishingRemark.Text = _currentWp.Settings.PublishingRemarks; textBoxTitle.Text = _currentWp.Title; textBoxStatus.Text = _currentWp.Status.ToString(); dateTimePickerOpeningDate.Value = _currentWp.Settings.OpeningDate; dateTimePickerClosingDate.Value = _currentWp.Settings.ClosingDate ?? SmartCore.Auxiliary.DateTimeExtend.GetCASMinDateTime(); textBoxPublishedBy.Text = published; textBoxRemarks.Text = _currentWp.Settings.Remarks; textBoxClosingRemarks.Text = _currentWp.Settings.ClosingRemarks; lifelengthViewerDuration.Lifelength = _currentWp.Settings.Offering.Duration; textBoxLocation.Text = _currentWp.Settings.Offering.Location; dateTimePickerFlightDate.Value = _currentWp.Settings.Offering.PerformDate; comboBoxTotal.SelectedItem = Сurrency.GetItemById(_currentWp.Settings.Offering.TotalCurrency); numericUpTotal.Value = _currentWp.Settings.Offering.Total; numericUpDownPerOne.Value = _currentWp.Settings.Offering.PerOne; numericUpDownMin.Value = _currentWp.Settings.Offering.Min; numericUpDownMax.Value = _currentWp.Settings.Offering.Max; numericUpDownFact.Value = _currentWp.Settings.Offering.Fact; foreach (var control in DocumentControls) { control.Added += DocumentControl1_Added; } if (_currentWp.Settings.ClosingDocument == null) { _currentWp.Settings.ClosingDocument = new List <SmartCore.Entities.General.Document>(); } if (_currentWp.Settings.DocumentIds != null && _currentWp.Settings.DocumentIds.Any()) { _currentWp.Settings.ClosingDocument.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAADocumentDTO, SmartCore.Entities.General.Document>(new Filter("ItemId", _currentWp.Settings.DocumentIds))); } if (_currentWp.Settings.ClosingDocument != null) { for (int i = 0; i < _currentWp.Settings.ClosingDocument.Count; i++) { var control = DocumentControls[i]; control.CurrentDocument = _currentWp.Settings.ClosingDocument[i]; } } }