private void CB_Visivel_CheckedChanged(object sender, EventArgs e) { if (alterarpergunta) { foreach (var item in perguntas.Where(x => x.ID == Convert.ToInt32(Grid_Perguntas.CurrentRow.Cells[1].Value))) { try { PerguntaDAL dal = new PerguntaDAL(); if (CB_Visivel.Checked) { item.Visibilidade = true; } else { item.Visibilidade = false; } dal.Alterar(item); } catch { MessageBox.Show("Erro de Conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { foreach (var item in respostas.Where(x => x.ID == Convert.ToInt32(Grid_Respostas.CurrentRow.Cells[1].Value))) { try { RespostaDAL dal = new RespostaDAL(); if (CB_Visivel.Checked) { item.Visibilidade = true; } else { item.Visibilidade = false; } dal.Alterar(item); } catch (Exception) { MessageBox.Show("Erro de Conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void Alterar(Resposta r) { RespostaDAL dal = new RespostaDAL(); dal.Alterar(r); }