コード例 #1
0
 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);
             }
         }
     }
 }
コード例 #2
0
        void CarregarRespostas()
        {
            RespostaDAL dal = new RespostaDAL();

            respostas = dal.ConsultarPorUsuario(UsuarioAtual.ID);
            int linha = 0;

            foreach (var item in respostas)
            {
                Grid_Respostas.Rows.Add();
                Grid_Respostas.Rows[linha].Cells[0].Value = item.Titulo;
                Grid_Respostas.Rows[linha].Cells[1].Value = item.ID;
                linha += 1;
            }
        }
コード例 #3
0
 void Salvar()
 {
     if (Txt_Titulo.Text.Trim() == "")
     {
         MessageBox.Show("Digite o título da resposta", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
         processar = false;
     }
     if (Txt_PerguntaResposta.Text.Trim() == "")
     {
         MessageBox.Show("Digite a resposta", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
         processar = false;
     }
     if (processar)
     {
         Form load = new Form_Load();
         load.Show();
         load.Refresh();
         try
         {
             Resposta r = new Resposta
             {
                 Imagem   = Imagens,
                 Pergunta = new Pergunta {
                     ID = idpergunta
                 },
                 Texto        = Txt_PerguntaResposta.Text.Trim(),
                 Titulo       = Txt_Titulo.Text.Trim(),
                 Usuario      = UsuarioAtual.ID,
                 Visibilidade = true
             };
             RespostaDAL dal = new RespostaDAL();
             dal.Inserir(r);
             MessageBox.Show("Resposta publicada com sucesso", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         catch
         {
             MessageBox.Show("Erro de Conexão. Tente novamente", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         load.Close();
     }
     processar = true;
 }
コード例 #4
0
        public void Inserir(Resposta r)
        {
            RespostaDAL dal = new RespostaDAL();

            dal.Inserir(r);
        }