private void VacancyForm_Load(object sender, EventArgs e) { try { List <FirmVM> list = Flogic.Read(null); if (list != null) { comboBoxFirm.DisplayMember = "Name"; comboBoxFirm.ValueMember = "Id"; comboBoxFirm.DataSource = list; comboBoxFirm.SelectedItem = null; } if (id.HasValue) { var view = Vlogic.Read(new VacancyBM { Id = id })?[0]; if (view != null) { textBoxSchedule.Text = view.Schedule; textBoxPosition.Text = view.Position; textBoxSalary.Text = view.Salary.ToString(); FirmVM firm = Flogic.Read(new FirmBM { Name = view.FirmName })?[0]; foreach (var currentFirm in list) { if (currentFirm.Name == firm.Name) { comboBoxFirm.SelectedItem = currentFirm; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadData() { try { var list = logic.Read(null); if (list != null) { dataGridViewFirms.DataSource = list; dataGridViewFirms.Columns[0].Visible = false; dataGridViewFirms.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CreateFirmForm_Load(object sender, EventArgs e) { if (id.HasValue) { try { var view = logic.Read(new FirmBM { Id = id })?[0]; if (view != null) { textBoxName.Text = view.Name; textBoxAddress.Text = view.Address; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }