Exemple #1
0
 private void DgvJobRoles_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 3)
         {
             string id = dgvJobRoles.Rows[e.RowIndex].Cells[0].Value.ToString();
             if (id.Trim() != "")
             {
                 if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja restaurar o cargo?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                 {
                     jobRoleService.ActivateOrDeactivateById(int.Parse(id), true);
                     LoadToDataGridView();
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
 private void DgpJobRoles_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 4)
         {
             string id = dgvJobRoles.Rows[e.RowIndex].Cells[0].Value.ToString();
             if (id.Trim() != "")
             {
                 if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja excluir o cargo?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                 {
                     int idI = int.Parse(id);
                     if (!_planningService.ExistsWithJobRole(idI))
                     {
                         _service.ActivateOrDeactivateById(idI, false);
                         LoadToDataGridView();
                     }
                     else
                     {
                         MessageBox.Show("Cargos associados a projetos não podem ser excluídos!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
             }
         }
         else if (e.ColumnIndex == 3)
         {
             string      id          = dgvJobRoles.SelectedCells[0].Value.ToString();
             JobRole     jobRole     = _service.ReadById(long.Parse(id));
             JobRoleForm jobRoleForm = new JobRoleForm(jobRole.Id);
             jobRoleForm.ShowDialog();
         }
     }
     catch (Exception)
     {
     }
 }