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)); } } } } }
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)); } } } } }
private void tsbdgvCounterValueAdd_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; } } if (this.m_ApartmentCounter != ApartmentCounter.Null) { if (this.m_ApartmentCounter.CounterSize == 0) { Messages.ShowWarning("Добавление нового показания невозможно, так как разрядность данного прибора учета равна 0. \nИзмените разрядность. "); } else { ApartmentCounterIndicationAddChangeForm form = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, false, false, false) { m_act = this.m_act }; if (this.IsForProvider) { form.IsForProvider = true; } if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { ApartmentCounterIndication apartmentCounterIndication = form.ApartmentCounterIndication; this.bsCounterIndications.Add(apartmentCounterIndication); this.bsCounterIndications.set_Sort(this.bsCounterIndications.get_Sort()); this.bsCounterIndications.set_Position(this.bsCounterIndications.IndexOf(apartmentCounterIndication)); if (apartmentCounterIndication.ValTypeName == "Конечное") { this.AddCounterIndicarions(); } } } } }
private void tsbdgvCounterValueChange_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; } } ApartmentCounterIndication currentCounterIndication = this.GetCurrentCounterIndication(); if (currentCounterIndication != ApartmentCounterIndication.Null) { if (this.m_ApartmentCounter.CounterSize == 0) { Messages.ShowWarning("Измение показания невозможно, так как разрядность данного прибора учета равна 0. \nИзмените разрядность. "); } else if ((currentCounterIndication.Created < CalcPeriod.GetFromDateLastPeriods()) && !User.IsMemberOf(RightsEnum.ИзменениеУдалениеПоказанийЗаПредыдущиеПериоды)) { Messages.ShowMessage("У вас нет права для изменение показаний за предыдущие периоды"); } else if ((currentCounterIndication.UserId != User.CurrentUser.Id) && !User.IsMemberOf(RightsEnum.ИзменениеУдалениеПоказанийДругогоПользователя)) { Messages.ShowMessage("У вас нет права для удаления показаний за предыдущие периоды"); } else { ApartmentCounterIndicationAddChangeForm form = new ApartmentCounterIndicationAddChangeForm(this.m_ApartmentCounter, currentCounterIndication, false, false, false); if (this.IsForProvider) { form.IsForProvider = true; if (currentCounterIndication.ValTypeName != "Контрольное (информационное)") { System.Windows.Forms.MessageBox.Show("Можно изменять только контрольно-информационные показания!"); return; } } form.ShowDialog(this); currentCounterIndication = form.ApartmentCounterIndication; this.UpdateBindingSourceCounterIndications(); this.bsCounterIndications.set_Position(this.bsCounterIndications.Find("Id", (long) currentCounterIndication.Id)); } } }
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); } } } } } }