public HouseCountersSubjectionAddChangeForm(HouseApartmentCounter houseApartmentCounter) : this() { this.m_houseApartmentCounter = houseApartmentCounter ?? HouseApartmentCounter.Null; if (this.m_houseApartmentCounter != HouseApartmentCounter.Null) { if (this.m_houseApartmentCounter.FromDate != Constants.NullDate) { this.datePeriod.DateBegin = this.m_houseApartmentCounter.FromDate; } if (this.m_houseApartmentCounter.ToDate != Constants.NullDate) { this.datePeriod.DateEnd = this.m_houseApartmentCounter.ToDate; } this.bsHouseApartmentCounters.set_DataSource(HouseApartmentCounter.FindByHouseCounterIdAllLinkage(this.m_houseApartmentCounter.HouseCounterId)); this.bsHouseApartmentCounters.set_Sort("addressName"); this.SetCurrenthouseApartmentCounter(houseApartmentCounter); if (this.m_houseApartmentCounter.IsNew) { this.set_Text("Добавление связи прибора учета"); this.btnOK.set_Text("Добавить"); } else { this.set_Text("Изменение связи прибора учета"); this.btnOK.set_Text("Изменить"); } } }
private void SetCurrenthouseApartmentCounter(HouseApartmentCounter houseApartmentCounter) { for (int i = 0; i < this.bsHouseApartmentCounters.get_Count(); i = (int) (i + 1)) { HouseApartmentCounter counter = (HouseApartmentCounter) this.bsHouseApartmentCounters.get_Item(i); if ((counter.ApartmentCounterId == houseApartmentCounter.ApartmentCounterId) && (counter.HouseCounterId == houseApartmentCounter.HouseCounterId)) { this.bsHouseApartmentCounters.set_Position(i); return; } } }
private void tsbAdd_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_counter == HouseCounter.Null) { this.bsHouseApartmentCountersLinkage.Clear(); } else { HouseApartmentCounter houseApartmentCounter = new HouseApartmentCounter { HouseCounterId = this.m_counter.Id }; HouseCountersSubjectionAddChangeForm form = new HouseCountersSubjectionAddChangeForm(houseApartmentCounter); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Updata(); this.IsChangedLinkage = true; this.bsHouseApartmentCountersLinkage.set_Position(this.bsHouseApartmentCountersLinkage.IndexOf(houseApartmentCounter)); } } }