private void btnCountersChange_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; } } ApartmentCounter currentCounter = this.GetCurrentCounter(); if (currentCounter != ApartmentCounter.Null) { ApartmentCounterAddChangeForm form = new ApartmentCounterAddChangeForm(currentCounter); if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { this.bsApartmentCounters.set_Sort(this.bsApartmentCounters.get_Sort()); this.UpdateBindingSourceApartmentCounters(); this.bsApartmentCounters.set_Position(this.bsApartmentCounters.IndexOf(currentCounter)); } } }
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 btnCountersAdd_Click(object sender, System.EventArgs e) { if (this.m_Apartment != Apartment.Null) { ApartmentCounter ac = new ApartmentCounter { ApartmentId = this.m_Apartment.Id }; ApartmentCounterAddChangeForm form = new ApartmentCounterAddChangeForm(ac); if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { this.bsApartmentCounters.Add(ac); this.bsApartmentCounters.set_Sort(this.bsApartmentCounters.get_Sort()); this.bsApartmentCounters.set_Position(this.bsApartmentCounters.IndexOf(ac)); } } }
private void btnCountersChange_Click(object sender, System.EventArgs e) { ApartmentCounter currentCounter = this.GetCurrentCounter(); if (currentCounter != ApartmentCounter.Null) { ApartmentCounterAddChangeForm form = new ApartmentCounterAddChangeForm(currentCounter); if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { this.bsApartmentCounters.set_Sort(this.bsApartmentCounters.get_Sort()); this.UpdateBindingSourceApartmentCounters(); this.bsApartmentCounters.set_Position(this.bsApartmentCounters.IndexOf(currentCounter)); } } }
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)); } } } } }