private void tsbDeleteCounter_Click(object sender, System.EventArgs e)
 {
     if ((this.GetAccountServiceCounter() != AccountServiceCounter.Null) && (Messages.QuestionYesNo(this, "Вы действительно хотите удалить?") != System.Windows.Forms.DialogResult.No))
     {
         this.m_AccountServiceCounter = this.GetAccountServiceCounter();
         if ((this.m_AccountServiceCounter != null) && (this.m_AccountServiceCounter != AccountServiceCounter.Null))
         {
             this.m_AccountServiceCounter.Delete();
             this.UpdateBindingAccountServiceCounters();
             this.IsUpdate = true;
         }
     }
 }
 private void FillBindingSourceAccountServiceCounter(AddressLevel addressLevel)
 {
     this.bsAccountServiceCounter.Clear();
     foreach (Service service in this.m_ApartmentCounter.GetServicetForBindingToCounterBy(addressLevel))
     {
         AccountServiceCounter counter = new AccountServiceCounter {
             ServiceCode = (int) ((int) service.Code),
             ServiceName = service.ShortName,
             ServiceId = service.Id,
             ServiceTypeName = service.TypeName,
             OrgName = service.OrgName,
             Share = 1M
         };
         this.bsAccountServiceCounter.Add(counter);
     }
 }
 private void tsbAddCounter_Click(object sender, System.EventArgs e)
 {
     if (this.m_AccountService != AccountService.Null)
     {
         AccountServiceCounter accountServiceCounter = new AccountServiceCounter {
             AccountServiceId = this.m_AccountService.Id
         };
         AccountServiceCountersAddChangeForm form = new AccountServiceCountersAddChangeForm(accountServiceCounter, this.m_ApartmentId);
         if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             this.bsAccountServiceCounters.Add(accountServiceCounter);
             this.bsAccountServiceCounters.set_Sort(this.bsAccountServiceCounters.get_Sort());
             this.bsAccountServiceCounters.set_Position(this.bsAccountServiceCounters.IndexOf(accountServiceCounter));
             this.IsUpdate = true;
         }
     }
 }
 private void ShowAccountServices()
 {
     if (this.m_ApartmentCounter.CounterServiceTypeId == 0L)
     {
         System.Windows.Forms.MessageBox.Show("На выбранном приборе учета не установлен тип услуги", "Ошибка", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
     }
     else
     {
         this.bsAccountServiceCounter.Clear();
         this.m_AreaSelected = this.selectAddresses1.SelectedArea;
         this.m_AreaSelected.GetAreaApartments();
         foreach (AccountService service in Mappers.AccountServiceMapper.FindByAreaServiceTypeId(this.m_AreaSelected.Id, this.m_ApartmentCounter.CounterServiceTypeId))
         {
             AccountServiceCounter counter = new AccountServiceCounter {
                 AccountServiceId = service.Id,
                 FromDate = service.FromDate,
                 ToDate = service.ToDate,
                 ServiceCode = service.ServiceCode,
                 ServiceName = service.ServiceShortName,
                 ServiceId = service.ServiceId,
                 ServiceTypeName = service.ServiceTypeName,
                 OrgName = service.OrgName,
                 AccountId = service.AccountId,
                 Share = 1M,
                 AccountAddressName = service.ApartmentAddrName,
                 AccountNumber = service.AccountNumber
             };
             this.bsAccountServiceCounter.Add(counter);
         }
     }
 }
 public AccountServiceCountersAddChangeForm(AccountServiceCounter accountServiceCounter, long aparmentId)
     : this()
 {
     this.m_AccountServiceCounter = accountServiceCounter;
     this.m_ApartmentId = aparmentId;
 }
 public AccountServiceCountersAddChangeForm()
 {
     this.m_AccountServiceCounter = AccountServiceCounter.Null;
     this.InitializeComponent();
     this.set_Font(Manager.WindowFont);
 }
 private void bUnbinding_Click(object sender, System.EventArgs e)
 {
     AccountServiceCounter counter = new AccountServiceCounter();
     new ObjectList<ApartmentCounter>();
     try
     {
         foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvBindingServices.Rows)
         {
             if (System.Convert.ToBoolean(row.Cells.get_Item("isSelected").get_Value()))
             {
                 Mappers.AccountServiceCounterMapper.GetAccountServiceCountersByAccountServiceIdAndCounterId(Mappers.AccountServiceMapper.FindOpenedByApartmentIdAndServiceId(System.Convert.ToInt64(row.Cells.get_Item("apartmentId").get_Value()), this.serviceId).get_Item(0).Id, System.Convert.ToInt64(row.Cells.get_Item("Id").get_Value())).get_Item(0).Delete();
             }
         }
         if (this.tsbAllCounters.get_Checked())
         {
             this.tsbAllCounters_Click(sender, e);
         }
         if (this.tsbCurrentCounters.get_Checked())
         {
             this.tsbCurrentCounters_Click(sender, e);
         }
         BalloonWindow.Show(this.bBinding, "Отвязка услуг завершилась успешно");
     }
     catch
     {
         BalloonWindow.Show(this.bBinding, "Отвязка услуг завершилась неуспешно");
     }
 }
 private void bBinding_Click(object sender, System.EventArgs e)
 {
     bool flag = false;
     AccountServiceCounter counter = new AccountServiceCounter();
     try
     {
         foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvBindingServices.Rows)
         {
             if (System.Convert.ToBoolean(row.Cells.get_Item("isSelected").get_Value()))
             {
                 counter.AccountServiceId = Mappers.AccountServiceMapper.FindOpenedByApartmentIdAndServiceId(System.Convert.ToInt64(row.Cells.get_Item("apartmentId").get_Value()), this.serviceId).get_Item(0).Id;
                 counter.CounterId = System.Convert.ToInt64(row.Cells.get_Item("Id").get_Value());
                 counter.FromDate = System.Convert.ToDateTime(row.Cells.get_Item("FromDateApartmentCounter").get_Value());
                 counter.ToDate = System.Convert.ToDateTime(row.Cells.get_Item("ToDateApartmentCounter").get_Value());
                 if (Mappers.AccountServiceCounterMapper.GetAccountServiceCountersByAccountServiceIdAndCounterId(counter.AccountServiceId, counter.CounterId).get_Count() == 0)
                 {
                     counter.Insert();
                 }
                 else
                 {
                     flag = true;
                 }
             }
         }
         if (!flag && (this.dgvBindingServices.get_RowCount() != 0))
         {
             BalloonWindow.Show(this.bBinding, "Привязка услуг завершилась успешно");
             if (this.tsbAllCounters.get_Checked())
             {
                 this.tsbAllCounters_Click(sender, e);
             }
             if (this.tsbCurrentCounters.get_Checked())
             {
                 this.tsbCurrentCounters_Click(sender, e);
             }
         }
         else
         {
             BalloonWindow.Show(this.bBinding, "Некоторые услуги не были привязаны");
         }
     }
     catch
     {
         BalloonWindow.Show(this.bBinding, "Привязка услуг завершилась неуспешно");
     }
 }