private void btnGravar_Click(object sender, EventArgs e) { try { getData = new Employee() { Id = _id, Name = txtName.Text, Surname = txtSurname.Text, Address = txtAddress.Text }; if (_id == 0) { getBussinessLayer = new BussinessLayer(); getBussinessLayer.Save(getData); MessageBox.Show("Registro inserido com sucesso!"); } else { getBussinessLayer = new BussinessLayer(); getBussinessLayer.Update(getData); MessageBox.Show("Registro atualizado com sucesso!"); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } FillGrid(); }
private void FillGrid() { getBussinessLayer = new BussinessLayer(); var list = getBussinessLayer.GetAll(); dgvEmployee.DataSource = list; }
private void btnExcluir_Click(object sender, EventArgs e) { try { getData = new Employee() { Id = _id }; getBussinessLayer = new BussinessLayer(); getBussinessLayer.Delete(getData); MessageBox.Show("Registro removido!"); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } FillGrid(); }