Ejemplo n.º 1
0
 public static void AddHouseAndApartment(LocalAddressDTO dto, LocalAddress address)
 {
     if (dto.NewApartment && (Apartment.FindByAddress(address).get_Count() == 0))
     {
         if (House.FindByAddress((LocalAddress) address.Parent) == House.Null)
         {
             AddHouse((LocalAddress) address.Parent);
         }
         Apartment apartment = new Apartment {
             AdrId = address.Id
         };
         apartment.SetNewNumber();
         apartment.HouseId = (address.Level == AddressLevel.MaxAddress) ? address.GetParent().GetHouse().Id : address.GetHouse().Id;
         apartment.SaveChanges();
     }
     if (dto.NewHouse && (House.FindByAddress(address) == House.Null))
     {
         AddHouse(address);
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }