Example #1
0
 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();
 }
Example #2
0
        private void FillGrid()
        {
            getBussinessLayer = new BussinessLayer();
            var list = getBussinessLayer.GetAll();

            dgvEmployee.DataSource = list;
        }
Example #3
0
        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();
        }