private void button1_Click(object sender, EventArgs e) { frmConfirmacao form = new frmConfirmacao(); form.Tag = "Confirma deleção de Pais?"; if (form.ShowDialog() == DialogResult.Yes) { if (Convert.ToInt32(lblId.Text) > 0) { int id = Int16.Parse(grid_pais.SelectedRows[0].Cells[0].Value.ToString()); Pais_Controle controle = new Pais_Controle(); controle.DeletarPais(id); //LimparFormulario(); CarregarGrid(); MessageBox.Show("Pais excluído com sucesso!!!"); } else { MessageBox.Show("Nenhum garçom Pais!!!"); } } }
private void ok_pais_Click(object sender, EventArgs e) { Pais_Model pais = new Pais_Model(); Pais_Controle pais_control = new Pais_Controle(); pais.Nome = txtbox_nome_pais.Text; pais_control.Inserir_Pais(pais); this.paisTableAdapter2.Fill(this.dataset_Pais.pais); //CarregarGrid(); }
private void grid_pais_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { int id = Int16.Parse(grid_pais.SelectedRows[0].Cells[0].Value.ToString()); Pais_Controle controle = new Pais_Controle(); Pais_Model pais = controle.BuscarPorPaisID(id); CarregarFormDePais(pais); } catch (Exception ex) { MessageBox.Show("ERRO: " + ex.Message); } }
public void CarregarGrid() { try { grid_pais.Rows.Clear(); Pais_Controle controleGar = new Pais_Controle(); List <Pais_Model> lista = controleGar.BuscarTodosPaises(); foreach (Pais_Model garcom in lista) { grid_pais.Rows.Add(garcom.Id, garcom.Nome); } } catch (Exception ex) { MessageBox.Show("ERRO: " + ex.Message); } }