public ApartmentNode(Apartment apartment) { base.set_Tag(apartment); base.set_Text(apartment.ToString()); }
private void AddApartmment() { if (House.FindByAddress((LocalAddress) this.SelectedAddress.Parent) == House.Null) { LocalAddress.AddHouse((LocalAddress) this.SelectedAddress.Parent); } Apartment apartment = new Apartment { AdrId = this.SelectedAddress.Id }; apartment.SetNewNumber(); apartment.HouseId = (this.SelectedAddress.Level == AddressLevel.MaxAddress) ? this.SelectedAddress.GetParent().GetHouse().Id : this.SelectedAddress.GetHouse().Id; if (Apartment.IsExistNumber(apartment.Number)) { Messages.ShowWarning("На этот адрес заведен паспорт квартиры. Попробуйте поменять номер имеющегося паспорта квартиры, чтобы избежать повторения номеров паспортов."); } else { apartment.SaveChanges(); System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode(apartment.ToString()); node.set_Tag(apartment); base.SelectedNode.Nodes.Add(node); base.SelectedNode.Expand(); base.set_SelectedNode(node); } }