private void dt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { PegarID.IDN = Convert.ToInt16(dt.CurrentRow.Cells[0].Value); //Abre a notificação var notificacao = bd.notificacao.Where(y => y.FK_usuario == UsuarioDados.Id).Where(x => x.idNotificacao == PegarID.IDN).FirstOrDefault(); if (notificacao.situacaoNotificacao == false) { notificacao.situacaoNotificacao = true; bd.SaveChanges(); } this.Hide(); TelaNotificacaoAberta f = new TelaNotificacaoAberta(); f.Closed += (s, args) => this.Close(); f.ShowDialog(); } catch (Exception) { Mensagem.aviso = "Erro de conexão com o banco!"; TelaMensagemAviso f = new TelaMensagemAviso(); f.ShowDialog(); } } }
private void dt_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { PegarID.IDN = Convert.ToInt16(dt.CurrentRow.Cells[0].Value); //Abre a notificação var notificacao = bd.notificacao.Where(y => y.FK_usuario == UsuarioDados.Id).Where(x => x.idNotificacao == PegarID.IDN).FirstOrDefault(); if (notificacao.situacaoNotificacao == false) { notificacao.situacaoNotificacao = true; bd.SaveChanges(); } this.Hide(); TelaNotificacaoAberta f = new TelaNotificacaoAberta(); f.Closed += (s, args) => this.Close(); f.ShowDialog(); }