public AccountServiceJournalBenefitsAddChangeForm(JnBenefit jnBenefit, long apartmentId)
     : this()
 {
     this.m_JnBenefit = jnBenefit;
     this.selectPersonBenefitOwner.Apartment = ObjectWithId.FindById<Apartment>(apartmentId);
     this.selectPersonExploitingPerson.Apartment = ObjectWithId.FindById<Apartment>(apartmentId);
 }
 private void btnAddChange_Click(object sender, System.EventArgs e)
 {
     if ((this.selectPersonBenefitOwner.SelectedPerson == null) || (this.selectPersonBenefitOwner.SelectedPerson == Person.Null))
     {
         BalloonWindow window = new BalloonWindow("Выберите собственника льготы");
         window.Show(this.btnAddChange);
     }
     else if ((this.bsBenefits.get_Current() == null) || (((Benefit) this.bsBenefits.get_Current()) == Benefit.Null))
     {
         new BalloonWindow("Выберите льготу").Show(this.btnAddChange);
     }
     else
     {
         if (this.m_JnBenefit == null)
         {
             this.m_JnBenefit = new JnBenefit();
             this.m_JnBenefit.Id = -1L;
         }
         this.m_JnBenefit.BenefitOwnerId = this.selectPersonBenefitOwner.SelectedPerson.Id;
         this.m_JnBenefit.ExploitingPersonId = this.selectPersonExploitingPerson.SelectedPerson.Id;
         this.m_JnBenefit.BenefitId = ((Benefit) this.bsBenefits.get_Current()).Id;
         this.m_JnBenefit.Summ = this.nudSumm.Value;
         this.m_JnBenefit.SaveChanges();
         base.set_DialogResult(System.Windows.Forms.DialogResult.OK);
         base.Close();
     }
 }
 public AccountServiceJournalBenefitsForm()
 {
     this.m_Jn = Jn.Null;
     this.m_JnBenefit = JnBenefit.Null;
     this.InitializeComponent();
 }
 private void tsbDelete_Click(object sender, System.EventArgs e)
 {
     if ((this.bsAccountServiceJournalBenefits.get_Current() != null) && (Messages.QuestionYesNo(this, "Вы действительно хотите удалить?") != System.Windows.Forms.DialogResult.No))
     {
         this.m_JnBenefit = this.bsAccountServiceJournalBenefits.get_Current() as JnBenefit;
         if ((this.m_JnBenefit != null) && (this.m_JnBenefit != JnBenefit.Null))
         {
             this.m_JnBenefit.Delete();
             this.bsAccountServiceJournalBenefits.Remove(this.m_JnBenefit);
         }
     }
 }
 private void tsbChange_Click(object sender, System.EventArgs e)
 {
     this.m_JnBenefit = (this.bsAccountServiceJournalBenefits.get_Current() == null) ? JnBenefit.Null : ((JnBenefit) this.bsAccountServiceJournalBenefits.get_Current());
     if (this.m_JnBenefit != JnBenefit.Null)
     {
         AccountServiceJournalBenefitsAddChangeForm form = new AccountServiceJournalBenefitsAddChangeForm(this.m_JnBenefit, this.m_Jn.ApartmentId);
         form.set_Text("Изменение");
         form.ShowDialog(this);
     }
 }
 private void tsbAdd_Click(object sender, System.EventArgs e)
 {
     JnBenefit jnBenefit = new JnBenefit {
         JnId = this.m_Jn.Id
     };
     AccountServiceJournalBenefitsAddChangeForm form = new AccountServiceJournalBenefitsAddChangeForm(jnBenefit, this.m_Jn.ApartmentId);
     form.set_Text("Добавление");
     if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         this.bsAccountServiceJournalBenefits.Add(jnBenefit);
     }
 }