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); }
private void UpdateInformation() { if (_parentKit == null) { return; } flowLayoutPanelCharts.Controls.Remove(panelButtons); for (int i = 0; i < _parentKit.SupplierRelations.Count; i++) { KitSupplierFormItem newKitSupplierControl = new KitSupplierFormItem(_parentKit.SupplierRelations[i]); if (i > 0) { newKitSupplierControl.Extended = false; } _kitSuppliersControls.Add(newKitSupplierControl); newKitSupplierControl.Deleted += KitSupplierDeleted; flowLayoutPanelCharts.Controls.Add(newKitSupplierControl); } flowLayoutPanelCharts.Controls.Add(panelButtons); }