private void ButtonSave_Click(object sender, EventArgs e) { if (textBoxAgeFrom.Text == "" || textBoxAgeTo.Text == "" || textBoxYears.Text == "") { MessageBox.Show("Заполните все поля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } logic.CreateOrUpdate(new ExperienceBindingModel { CounsellorId = this.counsellorId, AgeFrom = Convert.ToInt32(textBoxAgeFrom.Text), AgeTo = Convert.ToInt32(textBoxAgeTo.Text), Years = Convert.ToInt32(textBoxYears.Text) }); Id = logic.Read(new ExperienceBindingModel { CounsellorId = this.counsellorId, AgeFrom = Convert.ToInt32(textBoxAgeFrom.Text), AgeTo = Convert.ToInt32(textBoxAgeTo.Text), Years = Convert.ToInt32(textBoxYears.Text) })[0].Id.Value; DialogResult = DialogResult.OK; Close(); }
public FormCounsellorExperience(ExperienceLogic logic) { InitializeComponent(); List <ExperienceViewModel> list = logic.Read(null); if (list != null) { textBoxAgeFrom.Text = AgeFrom.ToString(); textBoxAgeTo.Text = AgeTo.ToString(); textBoxYears.Text = Years.ToString(); } }