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);
     }
 }
Ejemplo n.º 3
0
 private void tsBtnMerge_Click(object sender, System.EventArgs e)
 {
     if (this.dateMergeSplit.IsNull)
     {
         Messages.ShowMessage("Введите дату");
     }
     else
     {
         int num = 0;
         Apartment @null = Apartment.Null;
         this.dgvApartments.EndEdit();
         foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvApartments.Rows)
         {
             if ((row.Cells.get_Item("selectForMergeDataGridViewCheckBoxColumn").get_Value() != null) && ((bool) row.Cells.get_Item("selectForMergeDataGridViewCheckBoxColumn").get_Value()))
             {
                 @null = (Apartment) row.get_DataBoundItem();
                 num = (int) (num + 1);
                 if (num > 1)
                 {
                     break;
                 }
             }
         }
         if (num <= 1)
         {
             Messages.ShowMessage("Количество выбранных паспортов квартир должны быть больше 1.");
         }
         else if (Messages.QuestionYesNo(this, "Данная операция приведет к закрытию выбранных паспортов кв. и созданию нового,продолжить?") == System.Windows.Forms.DialogResult.Yes)
         {
             Apartment apartment2 = new Apartment {
                 AdrId = @null.AdrId,
                 Number = ((long) @null.AdrId).ToString(),
                 FromDate = this.dateMergeSplit.Value,
                 Created = System.DateTime.Now
             };
             apartment2.Insert();
             apartment2.Number = ((long) apartment2.Id).ToString();
             apartment2.SaveChanges();
             foreach (System.Windows.Forms.DataGridViewRow row2 in (System.Collections.IEnumerable) this.dgvApartments.Rows)
             {
                 if ((row2.Cells.get_Item("selectForMergeDataGridViewCheckBoxColumn").get_Value() != null) && ((bool) row2.Cells.get_Item("selectForMergeDataGridViewCheckBoxColumn").get_Value()))
                 {
                     @null = (Apartment) row2.get_DataBoundItem();
                     @null.ToDate = this.dateMergeSplit.Value.AddDays((double) -1.0);
                     @null.SaveChanges();
                     new ApartmentMergeHistory { PreviousApartmentId = @null.Id, NextApartmentId = apartment2.Id, FromDate = apartment2.FromDate, Created = apartment2.Created }.SaveChanges();
                 }
             }
             this.UpdateCurrentApartments();
             this.bsCurrentApartments.set_Position(this.bsCurrentApartments.Find("Id", (long) apartment2.Id));
         }
     }
 }