public FormSN(INapravlenie logic) { InitializeComponent(); List <NapravlenieVM> list = logic.Read(null); if (list != null) { comboBoxName.DisplayMember = "NapravlenieName"; comboBoxName.ValueMember = "Id"; comboBoxName.DataSource = list; comboBoxName.SelectedItem = null; comboBoxNumber.DisplayMember = "Number"; comboBoxNumber.ValueMember = "Id"; comboBoxNumber.DataSource = list; comboBoxNumber.SelectedItem = null; } }
private void LoadData() { try { var list = logic.Read(null); if (list != null) { dataGridView.DataSource = list; dataGridView.Columns[0].Visible = false; dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FormNapravlenie_Load(object sender, EventArgs e) { if (id.HasValue) { try { var view = logic.Read(new NapravlenieBM { Id = id })?[0]; if (view != null) { textBoxName.Text = view.NapravlenieName; textBoxNumber.Text = view.Number; textBoxNumber.Text = view.Number; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }