private void DgpCustomers_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 4) { string id = dgvCustomers.Rows[e.RowIndex].Cells[0].Value.ToString(); if (id.Trim() != "") { if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja excluir o cliente?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { int idI = int.Parse(id); if (!_projectService.ExistsWithCustomerId(idI)) { _service.ActivateOrDeactivateById(idI, false); LoadToDataGridView(); } else { MessageBox.Show("Clientes associados a projetos não podem ser excluídos!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else if (e.ColumnIndex == 3) { string id = dgvCustomers.SelectedCells[0].Value.ToString(); CustomerForm customerForm = new CustomerForm(long.Parse(id)); customerForm.ShowDialog(); } } catch (Exception) { } }
private void DgvCustomers_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 3) { string id = dgvCustomers.Rows[e.RowIndex].Cells[0].Value.ToString(); if (id.Trim() != "") { if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja restaurar o cliente?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { customerService.ActivateOrDeactivateById(int.Parse(id), true); LoadToDataGridView(); } } } } catch (Exception) { } }