private void menuSalvar_Click(object sender, EventArgs e) { try { using (var bo = new FormacaoTaticaBO()) { PreencherFormacao(); bo.Save(_formacao); MessageBox.Show("Formação salva com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); if (string.IsNullOrEmpty(txtId.Text)) { LimparCampos(); } else { Hide(); } _lista.AtualizarGrid(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void menuRemover_Click(object sender, EventArgs e) { try { using (var bo = new FormacaoTaticaBO()) { var id = txtId.Text.ToInt(); if (id > 0) { var result = MessageBox.Show($"Tem certeza que deseja excluir a formação {txtFormacao.Text}?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { bo.Remove(id); } } Hide(); _lista.AtualizarGrid(); } } catch (Exception) { throw; } }
private void CadastroClubesForm_Load(object sender, EventArgs e) { using (var bo = new FormacaoTaticaBO()) { cbxFormacoes.DataSource = bo.List(); var formacao = bo.List(); if (_clube != null) { txtId.Text = _clube.Id.ToString(); txtNome.Text = _clube.Nome; txtSigla.Text = _clube.Sigla; cbxFormacoes.SelectedIndex = formacao.IndexOf(formacao.FirstOrDefault(x => x.Id == _clube.FormacaoTatica_Id)); txtImagemId.Text = _clube.Escudo_Id.ToString(); pcbEscudo.Image = ImagemBO.ByteToImage(_clube.Escudo?.bytes); menuRemover.Visible = true; AtualizarGrid(); } else { menuRemover.Visible = false; } } }
public void AtualizarGrid() { using (var bo = new FormacaoTaticaBO()) { dgvFomacoes.AutoGenerateColumns = false; bsFormacoes.DataSource = bo.List(); } }
public SelectList PreencherFormacoesTaticas() { using (var bo = new FormacaoTaticaBO()) { var formacoes = bo.List(); return(formacoes.Select(x => new SelectListItem { Text = x.Descricao, Value = x.Id.ToString() }).ToSelectList()); } }
private void dgvFomacoes_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { using (var bo = new FormacaoTaticaBO()) { var id = dgvFomacoes.Rows[e.RowIndex].Cells["Id"].Value.ToString().ToInt(); var formacao = bo.Get(id); var form = new CadastroFormacoesForm(this, formacao); form.Show(); } } catch (Exception) { throw; } }