private void CadastroVegetais_Load(object sender, EventArgs e) { var grupoVegetalLogica = new GrupoVegetalLogica(); var grupos = grupoVegetalLogica.Listar(); if (grupos != null) { foreach (var grupo in grupos) { cbxGrupo.Items.Add(grupo); } } if (_vegetal != null) { txtCodigo.Text = _vegetal.Codigo.ToString(); txtNome.Text = _vegetal.Nome.ToString(); txtTam.Text = _vegetal.Tamanho.ToString(); var grupo = grupos.FirstOrDefault(x => x.Codigo == _vegetal.GrupoVegetal_Codigo); var index = grupos.IndexOf(grupo); cbxGrupo.SelectedIndex = index; } }
private void ListaGrupos_Load(object sender, EventArgs e) { try { var logica = new GrupoVegetalLogica(); dgvListaGrupos.DataSource = logica.Listar(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }