private void ApplicantForm_Load(object sender, EventArgs e) { if (id.HasValue) { try { var view = logic.Read(new ApplicantBM { Id = id })?[0]; if (view != null) { textBoxName.Text = view.Name; textBoxSurname.Text = view.Surname; textBoxPatronymic.Text = view.Patronymic; dateTimePickerBirthday.Value = view.Birthday; textBoxEducation.Text = view.Education; textBoxSpecialty.Text = view.Specialty; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void LoadData() { try { var list = logic.Read(null); if (list != null) { dataGridViewApplicants.DataSource = list; dataGridViewApplicants.Columns[0].Visible = false; dataGridViewApplicants.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DealForm_Load(object sender, EventArgs e) { try { List <EmployeeVM> Elist = Elogic.Read(null); if (Elist != null) { comboBoxEmployee.DisplayMember = "Surname"; comboBoxEmployee.ValueMember = "Id"; comboBoxEmployee.DataSource = Elist; comboBoxEmployee.SelectedItem = null; } List <ApplicantVM> Alist = Alogic.Read(null); if (Alist != null) { comboBoxApplicant.DisplayMember = "Surname"; comboBoxApplicant.ValueMember = "Id"; comboBoxApplicant.DataSource = Alist; comboBoxApplicant.SelectedItem = null; } List <VacancyVM> Vlist = Vlogic.Read(new VacancyBM { Employment = false }); if (Vlist != null) { comboBoxVacancy.DisplayMember = "Position"; comboBoxVacancy.ValueMember = "Id"; comboBoxVacancy.DataSource = Vlist; comboBoxVacancy.SelectedItem = null; } if (id.HasValue) { var view = Dlogic.Read(new DealBM { Id = id })?[0]; if (view != null) { dateTimePickerDate.Value = view.Date; EmployeeVM employee = Elogic.Read(new EmployeeBM { Id = view.EmployeeId })?[0]; foreach (var currentEmployee in Elist) { if (currentEmployee.Id == employee.Id) { comboBoxEmployee.SelectedItem = currentEmployee; } } ApplicantVM applicant = Alogic.Read(new ApplicantBM { Id = view.ApplicantId })?[0]; foreach (var currentApplicant in Alist) { if (currentApplicant.Id == applicant.Id) { comboBoxApplicant.SelectedItem = currentApplicant; } } Vlist = Vlogic.Read(new VacancyBM { Employment = true }); VacancyVM vacancy = Vlogic.Read(new VacancyBM { Id = view.VacancyId })?[0]; foreach (var currentVacancy in Vlist) { if (currentVacancy.Id == vacancy.Id) { comboBoxVacancy.SelectedItem = currentVacancy; } } Vlist = Vlogic.Read(new VacancyBM { Employment = false }); if (Elist != null) { comboBoxVacancy.DisplayMember = "Position"; comboBoxVacancy.ValueMember = "Id"; comboBoxVacancy.DataSource = Vlist; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }