コード例 #1
0
 public ApartmentCounterIndicationAddChangeForm(ApartmentCounter apartmentCounter, AIS.SN.Model.DomainObjects.ApartmentCounterIndication in_ci, bool isBegin, bool isEnd, bool isMaddleType)
     : this(apartmentCounter, isBegin, isEnd, isMaddleType)
 {
     this.m_ci = in_ci;
     this.list = Mappers.ApartmentCounterIndicationMapper.GetNextAndPrevious(this.m_ApartmentCounter.Id, this.m_ci.Created);
 }
コード例 #2
0
 private void tsbChangingCounters_Click(object sender, System.EventArgs e)
 {
     if (System.Windows.Forms.Application.OpenForms.get_Item(0).GetType().ToString() == "AIS.SN.UI.Provider.ProviderMainForm")
     {
         string valueByName = Setting.GetValueByName("Работа с приборами учета", "Диапазон в который разрешено редактирование в Поставщике");
         if ((System.Convert.ToInt32(valueByName.Substring(0, valueByName.IndexOf('-'))) > System.DateTime.Now.get_Day()) || (System.Convert.ToInt32(valueByName.Substring((int) (valueByName.IndexOf('-') + 1), (int) ((valueByName.get_Length() - valueByName.IndexOf('-')) - 1))) < System.DateTime.Now.get_Day()))
         {
             System.Windows.Forms.MessageBox.Show(string.Concat((string[]) new string[] { "Вам разрешено редактирование данных только с ", valueByName.Substring(0, valueByName.IndexOf('-')), " по ", valueByName.Substring((int) (valueByName.IndexOf('-') + 1), (int) ((valueByName.get_Length() - valueByName.IndexOf('-')) - 1)), " числа месяца" }), "Редактирование запрещено", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
             return;
         }
     }
     if (this.m_Apartment != Apartment.Null)
     {
         ApartmentCounter currentCounter = this.GetCurrentCounter();
         if (currentCounter != ApartmentCounter.Null)
         {
             ApartmentCounterIndication indication = new ApartmentCounterIndication {
                 CounterId = currentCounter.Id,
                 ValType = FasetItem.FindByName(FasetsEnum.CounterIndicationType, "Конечное").Id
             };
             ApartmentCounterIndicationAddChangeForm form = new ApartmentCounterIndicationAddChangeForm(currentCounter, indication, false, false, false);
             form.cbTypeValue.set_Enabled(false);
             if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
             {
                 ApartmentCounter ac = new ApartmentCounter {
                     ApartmentId = currentCounter.ApartmentId,
                     CounterName = currentCounter.CounterName,
                     CounterTypeId = currentCounter.CounterTypeId,
                     CounterTypeName = currentCounter.CounterTypeName,
                     PointAccounting = currentCounter.PointAccounting,
                     CounterSize = currentCounter.CounterSize,
                     MaddleTypeId = currentCounter.MaddleTypeId,
                     MaddleTypeName = currentCounter.MaddleTypeName,
                     PlaceId = currentCounter.PlaceId,
                     PlaceName = currentCounter.PlaceName,
                     TypeScaleCounterId = currentCounter.TypeScaleCounterId,
                     TypeScaleCounterName = currentCounter.TypeScaleCounterName,
                     FromDate = indication.ValDate.AddDays((double) 1.0)
                 };
                 ApartmentCounterAddChangeForm form2 = new ApartmentCounterAddChangeForm(ac);
                 if (form2.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                 {
                     foreach (AccountServiceCounter counter3 in AccountServiceCounter.FindByApartmentCounterId(currentCounter.Id))
                     {
                         if (counter3.ToDate == Constants.NullDate)
                         {
                             counter3.ToDate = currentCounter.ToDate;
                             counter3.SaveChanges();
                             counter3.Id = -1L;
                             counter3.CounterId = ac.Id;
                             counter3.FromDate = ac.FromDate;
                             counter3.ToDate = ac.ToDate;
                             counter3.SaveChanges();
                         }
                         else if (counter3.ToDate > currentCounter.ToDate)
                         {
                             counter3.ToDate = currentCounter.ToDate;
                             counter3.SaveChanges();
                         }
                     }
                     foreach (ApartmentEquipmentCounter counter4 in ApartmentEquipmentCounter.FindByApartmentIdCounterId(currentCounter.ApartmentId, currentCounter.Id))
                     {
                         if (counter4.Datee == Constants.NullDate)
                         {
                             counter4.Datee = currentCounter.ToDate;
                             counter4.SaveChanges();
                             counter4.Id = -1L;
                             counter4.CounterId = ac.Id;
                             counter4.Dateb = ac.FromDate;
                             counter4.Datee = ac.ToDate;
                             counter4.SaveChanges();
                         }
                         else if (counter4.Datee > currentCounter.ToDate)
                         {
                             counter4.Datee = currentCounter.ToDate;
                             counter4.SaveChanges();
                         }
                     }
                     this.UpdateBindingSourceApartmentCounters();
                     this.bsApartmentCounters.set_Sort(this.bsApartmentCounters.get_Sort());
                     this.bsApartmentCounters.set_Position(this.bsApartmentCounters.IndexOf(ac));
                 }
             }
         }
     }
 }
コード例 #3
0
 private void CounterIndicationAddChangeForm_Load(object sender, System.EventArgs e)
 {
     bool flag2;
     this.m_ci = this.m_ci ?? new AIS.SN.Model.DomainObjects.ApartmentCounterIndication();
     this.set_Font(Manager.WindowFont);
     this.set_Text(this.m_ci.IsNew ? ((string) "Добавление новых показаний") : ((string) "Изменение показаний прибора учета"));
     this.btOk.set_Text(this.m_ci.IsNew ? ((string) "Добавить") : ((string) "Изменить"));
     this.tbComment.set_Text(this.m_ci.Comment);
     this.udValue.set_Value(this.m_ci.Val);
     this.dbBegin.Value = this.m_ci.ValDate;
     this.cbTypeValue.Faset = FasetsEnum.CounterIndicationType;
     this.cbTypeValue.RefreshValuesWithNull();
     bool flag = false;
     if ((System.Windows.Forms.Application.OpenForms.get_Item(0).GetType().ToString() == "AIS.SN.UI.Provider.ProviderMainForm") && !User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями))
     {
         string valueByName = Setting.GetValueByName("Работа с приборами учета", "Диапазон в котором отменен перерасчет в Поставщике");
         if ((!string.IsNullOrEmpty(valueByName) && (System.Convert.ToInt32(valueByName.Substring(0, valueByName.IndexOf('-'))) <= System.DateTime.Now.get_Day())) && (System.Convert.ToInt32(valueByName.Substring((int) (valueByName.IndexOf('-') + 1), (int) ((valueByName.get_Length() - valueByName.IndexOf('-')) - 1))) >= System.DateTime.Now.get_Day()))
         {
             flag = true;
             this.chbxNotRecalc.set_Checked(true);
         }
     }
     if (Setting.GetValueByName("Работа с приборами учета", "Не делать перерасчет при вводе показаний").Trim().ToLower() == "да")
     {
         flag = true;
         this.chbxNotRecalc.set_Checked(true);
     }
     if (User.IsMemberOf(RightsEnum.СохранениеПоказанийБезПерерасчета))
     {
         this.chbxNotRecalc.set_Enabled(true);
     }
     else if (!flag)
     {
         this.chbxNotRecalc.set_Width((int) (this.chbxNotRecalc.get_Width() - 0x10));
         this.epNotRecalc.SetError(this.chbxNotRecalc, "У Вас нет прав на сохранение показаний без перерасчета");
     }
     if (this.m_ci != AIS.SN.Model.DomainObjects.ApartmentCounterIndication.Null)
     {
         this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf((this.m_ci.ValType == 0) ? FasetItem.Null : Register.GetFasetItem(FasetsEnum.CounterIndicationType, this.m_ci.ValType)));
     }
     this.cbTypeValue.set_Enabled(flag2 = User.IsMemberOf(RightsEnum.ИзменениеТипаПоказанийСчетчика));
     if (!flag2)
     {
         this.cbTypeValue.set_Width((int) (this.cbTypeValue.get_Width() - 0x10));
         if (this.m_ci.IsNew && (this.m_ci.ValType == 0))
         {
             foreach (FasetItem item in this.cbTypeValue.Items)
             {
                 if (item.Name == "Контрольное")
                 {
                     this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf(item));
                 }
             }
         }
         this.epRights.SetError(this.cbTypeValue, "У Вас нет прав на изменение типа показаний счетчика");
     }
     if (!this.m_isMaddleType)
     {
         if (!this.m_AddEndInd)
         {
             goto Label_0480;
         }
         this.m_ci.ValDate = this.m_ApartmentCounter.ToDate;
         foreach (FasetItem item3 in this.cbTypeValue.Items)
         {
             if (item3.Name == "Конечное")
             {
                 this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf(item3));
                 this.cbTypeValue.set_Enabled(false);
                 this.dbBegin.set_Enabled(false);
                 break;
             }
         }
     }
     else
     {
         this.m_ci.ValDate = this.m_ApartmentCounter.FromDate;
         foreach (FasetItem item2 in this.cbTypeValue.Items)
         {
             if (item2.Name == "Ср.мес.")
             {
                 this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf(item2));
                 this.cbTypeValue.set_Enabled(false);
                 this.dbBegin.set_Enabled(false);
                 break;
             }
         }
         this.udValue.Select();
         return;
     }
     this.udValue.Select();
     Label_0480:
     if (this.m_AddBeginInd)
     {
         this.m_ci.ValDate = this.m_ApartmentCounter.FromDate;
         foreach (FasetItem item4 in this.cbTypeValue.Items)
         {
             if (item4.Name == "Начальное")
             {
                 this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf(item4));
                 this.cbTypeValue.set_Enabled(false);
                 this.dbBegin.set_Enabled(false);
                 break;
             }
         }
         this.udValue.Select();
     }
     if (this.IsForProvider)
     {
         if (this.m_ci.IsNew)
         {
             this.cbTypeValue.set_SelectedIndex(this.cbTypeValue.Items.IndexOf(Register.GetFasetItem(FasetsEnum.CounterIndicationType, FasetItem.FindByName(FasetsEnum.CounterIndicationType, "Контрольное (информационное)").Id)));
         }
         this.cbTypeValue.set_Enabled(false);
     }
 }
コード例 #4
0
 private void btOk_Click(object sender, System.EventArgs e)
 {
     this.old_ci = this.m_ci.Clone<AIS.SN.Model.DomainObjects.ApartmentCounterIndication>();
     this.old_ci.Id = this.m_ci.Id;
     AIS.SN.Model.DomainObjects.ApartmentCounterIndication indication = Mappers.ApartmentCounterIndicationMapper.FindLastIndication(this.m_ApartmentCounter.Id);
     if (((!this.m_ApartmentCounter.IsNew && !User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями)) && ((this.m_ApartmentCounter.ToDate > System.DateTime.MinValue) && (this.m_ApartmentCounter.ToDate < System.DateTime.Today))) && (this.cbTypeValue.get_Text() != "Конечное"))
     {
         System.Windows.Forms.MessageBox.Show("Показание не может быть добавленно на недействующий счетчик", "Ошибка", System.Windows.Forms.MessageBoxButtons.OK);
     }
     else
     {
         this.m_ci.ValType = (this.cbTypeValue.get_SelectedItem() as FasetItem).Id;
         this.m_ci.Val = this.udValue.Value;
         this.m_ci.Comment = this.tbComment.get_Text();
         this.m_ci.UserId = User.CurrentUser.Id;
         this.m_ci.SessionId = Session.CurrentSessionId;
         this.m_ci.CounterId = this.m_ApartmentCounter.Id;
         this.m_ci.ValDate = this.dbBegin.Value;
         this.m_ci.Act = this.m_act ? ((byte) ((byte) 2)) : ((byte) ((byte) 1));
         if (!this.m_ci.Validation(this.m_ApartmentCounter))
         {
             new BalloonWindow(this.m_ci.ValidationMessage).Show(this.btOk);
         }
         else
         {
             if (this.m_ci.IsNew)
             {
                 if ((this.cbTypeValue.SelectedFasetItem.Name == "Начальное") && (AIS.SN.Model.DomainObjects.ApartmentCounterIndication.FindFirstIndicationByCounterId(this.m_ApartmentCounter.Id) != AIS.SN.Model.DomainObjects.ApartmentCounterIndication.Null))
                 {
                     Messages.ShowWarning("Невозможно добавить начальное показание, так как оно уже существует.");
                     return;
                 }
                 if ((this.cbTypeValue.SelectedFasetItem.Name == "Конечное") && (AIS.SN.Model.DomainObjects.ApartmentCounterIndication.FindLastIndicationByCounterId(this.m_ApartmentCounter.Id) != AIS.SN.Model.DomainObjects.ApartmentCounterIndication.Null))
                 {
                     Messages.ShowWarning("Невозможно добавить конечное показание, так как оно уже существует.");
                     return;
                 }
                 if (!User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями) && !this.ApartmentCounterIndication.ValidationNewIndication(this.m_ApartmentCounter.Id, this.m_ApartmentCounter.CounterSize, this.m_ci.Val, this.m_ci.ValDate, indication.Val, indication.ValDate, this.cbTypeValue.SelectedFasetItem.Name))
                 {
                     return;
                 }
             }
             if (this.m_AddBeginInd || this.m_AddEndInd)
             {
                 System.DateTime nullDate = Constants.NullDate;
                 System.DateTime previousToDate = Constants.NullDate;
                 if (this.m_AddEndInd)
                 {
                     ApartmentCounter counter = ApartmentCounter.FindById(this.m_ApartmentCounter.Id);
                     nullDate = counter.FromDate;
                     previousToDate = counter.ToDate;
                 }
                 this.m_ApartmentCounter.EndEdit();
                 this.m_ApartmentCounter.SaveChanges();
                 if (this.m_AddEndInd)
                 {
                     this.m_ApartmentCounter.UpdateAccountServiceCounters(nullDate, previousToDate);
                 }
                 this.m_ci.CounterId = this.m_ApartmentCounter.Id;
                 this.m_ci.SaveChanges();
             }
             if (this.cbTypeValue.SelectedFasetItem.Name == "Начальное")
             {
                 if (!this.m_AddBeginInd)
                 {
                     if (!User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями) && !AIS.SN.Model.DomainObjects.ApartmentCounterIndication.ValidationChangeIndication(this.m_ApartmentCounter.Id, this.m_ApartmentCounter.CounterSize, this.m_ci.Val, this.m_ci.ValDate, this.m_ci.Created))
                     {
                         return;
                     }
                     this.m_ci.SaveChanges();
                     System.DateTime fromDate = this.m_ApartmentCounter.FromDate;
                     System.DateTime toDate = this.m_ApartmentCounter.ToDate;
                     this.m_ApartmentCounter.FromDate = this.m_ci.ValDate;
                     this.m_ApartmentCounter.EndEdit();
                     this.m_ApartmentCounter.SaveChanges();
                     this.m_ApartmentCounter.UpdateAccountServiceCounters(fromDate, toDate);
                 }
                 base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
             }
             else
             {
                 try
                 {
                     if (!User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями) && !AIS.SN.Model.DomainObjects.ApartmentCounterIndication.ValidationChangeIndication(this.m_ApartmentCounter.Id, this.m_ApartmentCounter.CounterSize, this.m_ci.Val, this.m_ci.ValDate, this.m_ci.Created))
                     {
                         return;
                     }
                     this.m_ci.SaveChanges();
                 }
                 catch (System.Exception exception)
                 {
                     Messages.ShowException(this, exception);
                     return;
                 }
                 if (!this.chbxNotRecalc.get_Checked())
                 {
                     long num;
                     try
                     {
                         num = this.m_ci.Recalc();
                     }
                     catch (System.Exception exception2)
                     {
                         if (this.old_ci.IsNew)
                         {
                             this.m_ci.Delete();
                             this.m_ci = this.old_ci;
                         }
                         else
                         {
                             this.m_ci = this.old_ci;
                             this.m_ci.SaveChanges();
                         }
                         Messages.ShowException(this, exception2);
                         return;
                     }
                     this.m_ci.SaveRecalc(num);
                 }
                 if (!this.m_AddEndInd && (this.cbTypeValue.SelectedFasetItem.Name == "Конечное"))
                 {
                     System.DateTime previousFromDate = this.m_ApartmentCounter.FromDate;
                     System.DateTime time6 = this.m_ApartmentCounter.ToDate;
                     this.m_ApartmentCounter.ToDate = this.m_ci.ValDate;
                     this.m_ApartmentCounter.EndEdit();
                     this.m_ApartmentCounter.SaveChanges();
                     this.m_ApartmentCounter.UpdateAccountServiceCounters(previousFromDate, time6);
                 }
                 base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
             }
         }
     }
 }
コード例 #5
0
 private void tsbChangingCounters_Click(object sender, System.EventArgs e)
 {
     if (this.m_Apartment != Apartment.Null)
     {
         ApartmentCounter currentCounter = this.GetCurrentCounter();
         if (currentCounter != ApartmentCounter.Null)
         {
             ApartmentCounterIndication indication = new ApartmentCounterIndication {
                 CounterId = currentCounter.Id,
                 ValType = FasetItem.FindByName(FasetsEnum.CounterIndicationType, "Конечное").Id
             };
             ApartmentCounterIndicationAddChangeForm form = new ApartmentCounterIndicationAddChangeForm(currentCounter, indication, false, false, false);
             form.cbTypeValue.set_Enabled(false);
             if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
             {
                 ApartmentCounter ac = new ApartmentCounter {
                     ApartmentId = currentCounter.ApartmentId,
                     CounterName = currentCounter.CounterName,
                     CounterTypeId = currentCounter.CounterTypeId,
                     CounterTypeName = currentCounter.CounterTypeName,
                     PointAccounting = currentCounter.PointAccounting,
                     CounterSize = currentCounter.CounterSize,
                     MaddleTypeId = currentCounter.MaddleTypeId,
                     MaddleTypeName = currentCounter.MaddleTypeName,
                     PlaceId = currentCounter.PlaceId,
                     PlaceName = currentCounter.PlaceName,
                     TypeScaleCounterId = currentCounter.TypeScaleCounterId,
                     TypeScaleCounterName = currentCounter.TypeScaleCounterName,
                     CounterServiceTypeId = currentCounter.CounterServiceTypeId,
                     CounterServiceTypeName = currentCounter.CounterServiceTypeName,
                     FromDate = indication.ValDate.AddDays((double) 1.0)
                 };
                 ApartmentCounterAddChangeForm form2 = new ApartmentCounterAddChangeForm(ac, true);
                 if (form2.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                 {
                     foreach (AccountServiceCounter counter3 in AccountServiceCounter.FindByApartmentCounterId(currentCounter.Id))
                     {
                         if (counter3.ToDate == currentCounter.ToDate)
                         {
                             counter3.Id = -1L;
                             counter3.CounterId = ac.Id;
                             counter3.FromDate = ac.FromDate;
                             counter3.ToDate = ac.ToDate;
                             counter3.SaveChanges();
                         }
                         else if (counter3.ToDate > currentCounter.ToDate)
                         {
                             counter3.ToDate = currentCounter.ToDate;
                             counter3.SaveChanges();
                         }
                     }
                     foreach (ApartmentEquipmentCounter counter4 in ApartmentEquipmentCounter.FindByApartmentIdCounterId(currentCounter.ApartmentId, currentCounter.Id))
                     {
                         if (counter4.Datee == Constants.NullDate)
                         {
                             counter4.Datee = currentCounter.ToDate;
                             counter4.SaveChanges();
                             counter4.Id = -1L;
                             counter4.CounterId = ac.Id;
                             counter4.Dateb = ac.FromDate;
                             counter4.Datee = ac.ToDate;
                             counter4.SaveChanges();
                         }
                         else if (counter4.Datee > currentCounter.ToDate)
                         {
                             counter4.Datee = currentCounter.ToDate;
                             counter4.SaveChanges();
                         }
                     }
                     this.UpdateBindingSourceApartmentCounters();
                     this.bsApartmentCounters.set_Sort(this.bsApartmentCounters.get_Sort());
                     this.bsApartmentCounters.set_Position(this.bsApartmentCounters.IndexOf(ac));
                 }
             }
         }
     }
 }
コード例 #6
0
 private void btnRecalc_Click(object sender, System.EventArgs e)
 {
     if (this.datePeriod.DateBeginIsNull || this.datePeriod.DateEndIsNull)
     {
         new BalloonWindow("Не задан период").Show(this.btnRecalc);
     }
     else
     {
         ApartmentCounter currentApartmentCounter = this.GetCurrentApartmentCounter();
         if (currentApartmentCounter == ApartmentCounter.Null)
         {
             this.dgvCounterIndications.Rows.Clear();
         }
         else if (this.dgvCounterIndications.Rows.get_Count() == 0)
         {
             new BalloonWindow("Не рассчитаны новые значения").Show(this.btnRecalc);
         }
         else if (((string) this.dgvCounterIndications.Rows.get_Item(0).Cells.get_Item(2).get_Value()) == "")
         {
             new BalloonWindow("Не рассчитаны новые значения").Show(this.btnRecalc);
         }
         else
         {
             ApartmentCounterIndication.DeleteOnMounths(currentApartmentCounter.Id, this.datePeriod.DateBegin);
             FasetItem item = Mappers.FasetItemMapper.FindByName(FasetsEnum.CounterIndicationType, "При оплате");
             decimal num = System.Convert.ToDecimal(this.tbxIndBegin.get_Text());
             foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvCounterIndications.Rows)
             {
                 System.DateTime time = (System.DateTime) row.Cells.get_Item(0).get_Value();
                 time = time.AddMonths(1).AddDays((double) -1.0);
                 ApartmentCounterIndication indication = new ApartmentCounterIndication {
                     CounterId = currentApartmentCounter.Id,
                     ValDate = time
                 };
                 num += decimal.Parse((string) ((string) row.Cells.get_Item(2).get_Value()));
                 indication.Val = num;
                 indication.ValType = item.Id;
                 indication.SaveChanges();
             }
             System.DateTime toDate = this.datePeriod.DateEnd.AddMonths(-1).AddDays((double) 1.0);
             ApartmentCounterIndication.RecalIndicationsMounths(this.m_Account.Id, this.datePeriod.DateBegin, toDate);
             new BalloonWindow("Перерасчет выполнен").Show(this.btnRecalc);
         }
     }
 }
コード例 #7
0
 private void btOk_Click(object sender, System.EventArgs e)
 {
     System.DateTime time = Mappers.CalcPeriodMapper.GetFromDateLastPeriods().AddMonths(-1);
     if ((this.m_ApartmentCounter.IsNew && (time > this.dbBegin.Value)) && !User.IsMemberOf(RightsEnum.АРМБухгалтерЛСПриборыучётаЗаведениеПУНаПрошедшиеПериоды))
     {
         System.Windows.Forms.MessageBox.Show("У вас нет прав устанавливать дату заведения ПУ меньше текушего отчетного периода");
     }
     else
     {
         long num;
         if (!string.IsNullOrEmpty(this.m_ApartmentCounter.PointAccounting) && !long.TryParse(this.m_ApartmentCounter.PointAccounting, ref num))
         {
             System.Windows.Forms.MessageBox.Show("Номер точки учета поставщика услуг должен содержать только цифры");
         }
         else if ((this.bsServiceType.get_Current() as ServiceType) == ServiceType.Null)
         {
             System.Windows.Forms.MessageBox.Show("Выберите тип услуги");
         }
         else
         {
             this.m_ApartmentCounter.CounterTypeId = (this.cbType.get_SelectedItem() as FasetItem).Id;
             this.m_ApartmentCounter.CommunalShareTypeId = (this.cbCommunalType.get_SelectedItem() as FasetItem).Id;
             this.m_ApartmentCounter.MaddleTypeId = (this.cbMaddle.get_SelectedItem() as FasetItem).Id;
             this.m_ApartmentCounter.MaddleTypeName = (this.cbMaddle.get_SelectedItem() as FasetItem).Name;
             this.m_ApartmentCounter.StatusAscupe = (this.cbStatusASKUPE.get_SelectedItem() as FasetItem).Id;
             this.m_ApartmentCounter.StatusAscupeName = (this.cbStatusASKUPE.get_SelectedItem() as FasetItem).Name;
             this.m_ApartmentCounter.MarkId = (this.selectCounetMark.SelectedCounterMark == null) ? CounterMark.Null.Id : this.selectCounetMark.SelectedCounterMark.Id;
             this.m_ApartmentCounter.TypeScaleCounterId = (this.cbTypeScaleCounter.get_SelectedItem() as FasetItem).Id;
             this.m_ApartmentCounter.CounterServiceTypeId = ((this.bsServiceType.get_Current() as ServiceType) ?? ServiceType.Null).Id;
             this.m_ApartmentCounter.CounterServiceTypeName = this.cbTypeService.get_Text();
             this.m_ApartmentCounter.Act = this.m_act ? ((byte) ((byte) 2)) : ((byte) ((byte) 1));
             this.m_ApartmentCounter.UserId = User.CurrentUser.Id;
             this.m_ApartmentCounter.SessionId = Session.CurrentSessionId;
             if (this.nudCounterSize.Value == 0M)
             {
                 BalloonWindow.Show(this.nudCounterSize, "Разрядность прибора учета не может быть равна 0.");
             }
             else if (this.dbBegin.Value == Constants.NullDate)
             {
                 BalloonWindow.Show(this.dbBegin, "Не указанa дата начала");
             }
             else if ((this.dbEnd.Value != Constants.NullDate) && (this.dbBegin.Value >= this.dbEnd.Value))
             {
                 BalloonWindow.Show(this.dbBegin, "Неправильно задан период действия");
             }
             else if (!this.m_ApartmentCounter.GetCountIndicationDoesNotMatchTheBitCounter(this.m_ApartmentCounter.Id, this.m_ApartmentCounter.CounterSize) || (Messages.QuestionYesNo(this, "Имеются показания счетчика, имеющие большую разрядность. Изменить разрядность?") != System.Windows.Forms.DialogResult.No))
             {
                 bool isMaddleType = false;
                 if ((this.m_ApartmentCounter.MaddleTypeId != FasetItem.Null.Id) && (this.m_ApartmentCounter.MaddleTypeName != "Нет"))
                 {
                     isMaddleType = true;
                 }
                 if (this.m_ApartmentCounter.IsNew)
                 {
                     ApartmentCounterIndication indication = new ApartmentCounterIndication {
                         ValDate = this.dbBegin.Value
                     };
                     ApartmentCounterIndicationAddChangeForm form = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, indication, true, false, isMaddleType);
                     if (form.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
                     {
                         base.Close();
                         this.m_ApartmentCounter.CancelEdit();
                         return;
                     }
                     this.SaveAccountServiceCounters();
                     base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
                 }
                 if (((this.m_ApartmentCounter.FromDate != Constants.NullDate) && (this.m_FromDate != Constants.NullDate)) && ((this.m_ApartmentCounter.FromDate != this.m_FromDate) && !isMaddleType))
                 {
                     ApartmentCounterIndication indication2 = ApartmentCounterIndication.FindFirstIndicationByCounterId(this.m_ApartmentCounter.Id);
                     indication2.ValDate = this.dbBegin.Value;
                     if (indication2 == ApartmentCounterIndication.Null)
                     {
                         indication2 = new ApartmentCounterIndication();
                     }
                     ApartmentCounterIndicationAddChangeForm form2 = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, indication2, true, false, isMaddleType);
                     if (form2.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
                     {
                         base.Close();
                         this.m_ApartmentCounter.CancelEdit();
                         return;
                     }
                     this.SaveAccountServiceCounters();
                     base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
                 }
                 if (((this.m_ApartmentCounter.ToDate != Constants.NullDate) && (this.m_ToDate == Constants.NullDate)) && (!isMaddleType && (Messages.QuestionYesNo(this, "Ввести конечные показания?") == System.Windows.Forms.DialogResult.Yes)))
                 {
                     ApartmentCounterIndication indication3 = new ApartmentCounterIndication {
                         ValDate = this.dbEnd.Value
                     };
                     ApartmentCounterIndicationAddChangeForm form3 = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, indication3, false, true, isMaddleType);
                     if (form3.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                     {
                         this.SaveAccountServiceCounters();
                         base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
                     }
                     else
                     {
                         base.Close();
                         this.m_ApartmentCounter.CancelEdit();
                     }
                 }
                 else if (((this.m_ApartmentCounter.ToDate != Constants.NullDate) && (this.m_ToDate != Constants.NullDate)) && ((this.m_ApartmentCounter.ToDate != this.m_ToDate) && !isMaddleType))
                 {
                     ApartmentCounterIndication indication4 = ApartmentCounterIndication.FindLastIndicationByCounterId(this.m_ApartmentCounter.Id);
                     if (indication4 == ApartmentCounterIndication.Null)
                     {
                         indication4 = new ApartmentCounterIndication();
                     }
                     indication4.ValDate = this.dbEnd.Value;
                     ApartmentCounterIndicationAddChangeForm form4 = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, indication4, false, true, isMaddleType);
                     if (form4.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                     {
                         this.SaveAccountServiceCounters();
                         base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
                     }
                     else
                     {
                         base.Close();
                         this.m_ApartmentCounter.CancelEdit();
                     }
                 }
                 else
                 {
                     if ((this.m_ApartmentCounter.ToDate == Constants.NullDate) && (this.m_ToDate != Constants.NullDate))
                     {
                         ApartmentCounterIndication.FindLastIndicationByCounterId(this.m_ApartmentCounter.Id).Delete();
                     }
                     if (base.DialogResult != System.Windows.Forms.DialogResult.OK)
                     {
                         this.m_ApartmentCounter.EndEdit();
                         this.m_ApartmentCounter.SaveChanges();
                         this.SaveAccountServiceCounters();
                         base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
                     }
                 }
             }
         }
     }
 }