private void ButtonDeleteClick(object sender, EventArgs e) { if (listViewBindedTasks.SelectedItems.Count == 0) { return; } foreach (BaseEntityObject selectedItem in listViewBindedTasks.SelectedItems) { KitSuppliersRelation ksr = selectedItem as KitSuppliersRelation; if (ksr == null) { continue; } try { GlobalObjects.CasEnvironment.NewKeeper.Delete(ksr); } catch (Exception ex) { Program.Provider.Logger.Log("Error while delete bind task record", ex); } } _animatedThreadWorker.RunWorkerAsync(); }
///<summary> /// Конструктор, принимающий поставщика KITа для отображения ///</summary> public KitSupplierFormItem(KitSuppliersRelation kitSuppliersRelation) { _currentKitSupplier = kitSuppliersRelation; _comboBoxItemToolTip = new ToolTip(); InitializeComponent(); UpdateInformation(); }
private void ButtonAddClick(object sender, EventArgs e) { KitSuppliersRelation newksr = new KitSuppliersRelation(_parentKit); _parentKit.SupplierRelations.Add(newksr); KitSupplierFormItem newKitSupplierControl = new KitSupplierFormItem(newksr); _kitSuppliersControls.Add(newKitSupplierControl); newKitSupplierControl.Deleted += KitSupplierDeleted; flowLayoutPanelCharts.Controls.Remove(panelButtons); flowLayoutPanelCharts.Controls.Add(newKitSupplierControl); flowLayoutPanelCharts.Controls.Add(panelButtons); }
private void KitSupplierDeleted(object sender, EventArgs e) { KitSupplierFormItem control = (KitSupplierFormItem)sender; control.Deleted -= KitSupplierDeleted; KitSuppliersRelation ksr = control.KitSuppliersRelation; //У связи поставщика с китами нет дочерних объектов для сохранения //поэтому он удаляется напрямую - через Keeper, а не Manipulator GlobalObjects.NewKeeper.Delete(ksr); _parentKit.SupplierRelations.Remove(ksr); _kitSuppliersControls.Remove(control); flowLayoutPanelCharts.Controls.Remove(control); }
//public bool Equals(DetailModel other) //{ // //Без переопределения метода GetHashCode данный метод не работает // //Почему? - ХЗ // //Check whether the compared object is null. // if (ReferenceEquals(other, null)) return false; // //Check whether the compared object references the same data. // if (ReferenceEquals(this, other)) return true; // if (ItemId > 0 && other.ItemId > 0) // return ItemId == other.ItemId; // //Check whether the products' properties are equal. // ShortName = "", // Model = "", // Series = "", // ManufactureReg = ManufactureRegion.Unknown, // Manufacturer = "", // Designer = "" // return FullName == other.FullName && // FullName == other.FullName && // FullName == other.FullName && // FullName == other.FullName && // FullName == other.FullName && // FullName == other.FullName && // GoodsClass == other.GoodsClass && // Standart == other.Standart && // PartNumber == other.PartNumber && // Description == other.Description; //} #endregion public new ComponentModel GetCopyUnsaved() { ComponentModel product = (ComponentModel)MemberwiseClone(); product.ItemId = -1; product.Name += " Copy"; product.UnSetEvents(); product.SupplierRelations = new CommonCollection <KitSuppliersRelation>(); foreach (KitSuppliersRelation kitSuppliers in SupplierRelations) { KitSuppliersRelation newObject = kitSuppliers.GetCopyUnsaved(); product.SupplierRelations.Add(newObject); } return(product); }
/* * Свойства */ /* * Методы */ public new AircraftModel GetCopyUnsaved() { var model = (AircraftModel)MemberwiseClone(); model.ItemId = -1; model.Name += " Copy"; model.UnSetEvents(); model.SupplierRelations = new CommonCollection <KitSuppliersRelation>(); foreach (KitSuppliersRelation kitSuppliers in SupplierRelations) { KitSuppliersRelation newObject = kitSuppliers.GetCopyUnsaved(); model.SupplierRelations.Add(newObject); } return(model); }
private void Save() { foreach (BaseEntityObject selectedItem in listViewBindedTasks.SelectedItems) { KitSuppliersRelation ksr = selectedItem as KitSuppliersRelation; if (ksr == null) { continue; } try { GlobalObjects.CasEnvironment.Manipulator.Save(ksr); } catch (Exception ex) { Program.Provider.Logger.Log("Error while delete bind task record", ex); } } }
private void ButtonAddClick(object sender, EventArgs e) { if (listViewTasksForSelect.SelectedItems.Count == 0) { return; } foreach (BaseEntityObject selectedItem in listViewTasksForSelect.SelectedItems) { Product product = selectedItem as Product; if (product == null) { continue; } product.Suppliers.Add(_supplier); KitSuppliersRelation record = new KitSuppliersRelation { Supplier = _supplier, KitId = product.ItemId, ParentTypeId = product.SmartCoreObjectType.ItemId, }; try { GlobalObjects.CasEnvironment.NewKeeper.Save(record); product.SupplierRelations.Add(record); } catch (Exception ex) { Program.Provider.Logger.Log("Error while save bind task record", ex); } } _animatedThreadWorker.RunWorkerAsync(); }