Exemplo n.º 1
0
 private void tsbChangeCounterIndications_Click(object sender, System.EventArgs e)
 {
     if ((System.Windows.Forms.Application.OpenForms.get_Item(0).GetType().ToString() == "AIS.SN.UI.Provider.ProviderMainForm") && !User.IsMemberOf(RightsEnum.ПравоНеограниченнойРаботыСПоказаниями))
     {
         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;
         }
     }
     HomeCountersIndicationAddChangeForm form = new HomeCountersIndicationAddChangeForm(this.m_counter, this.GetCurrentCounterIndication());
     if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         this.bsHouseCounterIndication.set_DataSource(HouseCounterIndication.FindByCounterId(this.m_counter.Id));
     }
 }
Exemplo n.º 2
0
 private void btnAddChange_Click(object sender, System.EventArgs e)
 {
     BalloonWindow window;
     ServiceTypeOld old = (this.bsServiceTypes.get_Current() as ServiceTypeOld) ?? ServiceTypeOld.Null;
     if (string.IsNullOrEmpty(this.selectType.get_Text()) || string.IsNullOrEmpty(this.tbCounterName.get_Text()))
     {
         window = new BalloonWindow("Не все поля заполнены.");
         window.Show(this.btnAddChange);
     }
     else if (this.dbFromDate.IsNull)
     {
         window = new BalloonWindow("Не введена дата открытия.");
         window.Show(this.btnAddChange);
     }
     else if (((int) this.nudCapacity.Value) <= 0)
     {
         window = new BalloonWindow("Разрядность должна быть больше 0.");
         window.Show(this.btnAddChange);
     }
     else if (old == ServiceTypeOld.Null)
     {
         window = new BalloonWindow("Выберите тип услуги");
         window.Show(this.btnAddChange);
     }
     else
     {
         long num;
         if (!string.IsNullOrEmpty(this.tbCodeASKUPE.get_Text()) && !long.TryParse(this.tbCodeASKUPE.get_Text(), ref num))
         {
             new BalloonWindow("Код АСКУПЭ должен содержать только цифры").Show(this.btnAddChange);
         }
         else
         {
             if ((this.m_HouseCounter == null) || (this.m_HouseCounter == HouseCounter.Null))
             {
                 this.m_HouseCounter = new HouseCounter();
                 this.m_HouseCounter.HouseId = this.m_HouseId;
             }
             bool flag1 = this.m_HouseCounter.FromDate != this.dbFromDate.Value;
             bool flag2 = this.m_HouseCounter.ToDate != this.dbToDate.Value;
             this.m_HouseCounter.FromDate = this.dbFromDate.Value;
             if (!this.dbToDate.IsNull)
             {
                 this.m_HouseCounter.ToDate = this.dbToDate.Value;
             }
             this.m_HouseCounter.TypeCounterName = this.selectType.SelectedFasetItem.ToString();
             this.m_HouseCounter.TypeCounterId = this.selectType.SelectedFasetItem.Id;
             this.m_HouseCounter.CounterName = this.tbCounterName.get_Text();
             this.m_HouseCounter.CounterNumber = this.tbCounterNumber.get_Text();
             this.m_HouseCounter.Capacity = (int) this.nudCapacity.Value;
             this.m_HouseCounter.MarkId = (this.cbMark.get_SelectedItem() as CounterMark).Id;
             this.m_HouseCounter.FromDate = this.dbFromDate.Value;
             this.m_HouseCounter.ToDate = this.dbToDate.Value;
             this.m_HouseCounter.ServiceTypeId = old.Id;
             this.m_HouseCounter.Factor = this.nudFactor.Value;
             this.m_HouseCounter.StatusAscupe = (this.cbStatusASKUPE.get_SelectedItem() as FasetItem).Id;
             this.m_HouseCounter.PointAccounting = this.tbCodeASKUPE.get_Text();
             this.m_HouseCounter.IsInternal = this.chbIsInternal.get_Checked();
             bool isNew = this.m_HouseCounter.IsNew;
             this.m_HouseCounter.Note = this.tbNote.get_Text();
             this.m_HouseCounter.SaveChanges();
             this.m_HouseCounter.ServiceTypeCode = (int) ((int) old.Code);
             this.m_HouseCounter.ServiceTypeName = old.ShortName;
             if (isNew)
             {
                 this.m_HouseCounterFromIndication.CounterId = this.m_HouseCounter.Id;
                 this.m_HouseCounterFromIndication.ValDate = this.dbFromDate.Value;
                 this.m_HouseCounterFromIndication.ValTypeName = "Начальное";
                 HomeCountersIndicationAddChangeForm form = new HomeCountersIndicationAddChangeForm(this.m_HouseCounter, this.m_HouseCounterFromIndication, true);
                 form.ShowDialog(this);
             }
             else if (!this.m_HouseCounterFromIndication.IsNew && (this.m_HouseCounterFromIndication.ValDate != this.dbFromDate.Value))
             {
                 this.m_HouseCounterFromIndication.ValDate = this.dbFromDate.Value;
                 this.m_HouseCounterFromIndication.SaveChanges();
             }
             if (!this.dbToDate.IsNull)
             {
                 this.m_HouseCounterToIndication.CounterId = this.m_HouseCounter.Id;
                 this.m_HouseCounterToIndication.ValDate = this.dbToDate.Value;
                 this.m_HouseCounterToIndication.ValTypeName = "Конечное";
                 new HomeCountersIndicationAddChangeForm(this.m_HouseCounter, this.m_HouseCounterToIndication, true).ShowDialog(this);
             }
             else if ((this.m_HouseCounterToIndication != null) && (this.m_HouseCounterToIndication != HouseCounterIndication.Null))
             {
                 this.m_HouseCounterToIndication.Delete();
             }
             base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
             base.Close();
         }
     }
 }