コード例 #1
0
 private void Grid_Respostas_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (Grid_Respostas.Rows.Count > 0)
     {
         foreach (var item in respostas.Where(x => x.ID == Convert.ToInt32(Grid_Respostas.CurrentRow.Cells[1].Value)))
         {
             Form frm = new Form_Load();
             try
             {
                 frm.Show();
                 frm.Refresh();
                 alterarpergunta           = false;
                 Lbl_PerguntaResposta.Text = item.Titulo;
                 CB_Visivel.Visible        = true;
                 AvaliacaoDAL dal = new AvaliacaoDAL();
                 Lbl_Likes.Text            = dal.AvaliacaoPossitiva(0, item.ID).ToString();
                 Lbl_Numeros_Dislikes.Text = dal.AvaliacaoNegativa(0, item.ID).ToString();
                 Lbl_Numeros_Denucias.Text = dal.Denuncias(0, item.ID).ToString();
                 CB_Visivel.Checked        = item.Visibilidade;
                 frm.Close();
             }
             catch
             {
                 MessageBox.Show("Erro de Conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 frm.Close();
             }
         }
     }
 }
コード例 #2
0
 void Cadastrar()
 {
     LimparErros();
     if (Txt_Nome.Text.Trim() == "")
     {
         Lbl_ErroNome.Visible = true;
         processar            = false;
     }
     if (Txt_Email.Text.Trim() == "")
     {
         Lbl_ErroEmail.Text    = "Digite o Email";
         Lbl_ErroEmail.Visible = true;
         processar             = false;
     }
     else
     {
         if (!Txt_Email.Text.Trim().Contains("@") || !Txt_Email.Text.Trim().Contains(".com"))
         {
             Lbl_ErroEmail.Text    = "Email inválido";
             Lbl_ErroEmail.Visible = true;
             processar             = false;
         }
         else
         {
             Usuario    usuario = new Usuario();
             UsuarioDAL dal     = new UsuarioDAL();
             usuario = dal.Consultar(Txt_Email.Text.Trim());
             if (usuario.ID != 0)
             {
                 Lbl_ErroEmail.Text    = "Email já cadastrado";
                 Lbl_ErroEmail.Visible = true;
                 processar             = false;
             }
         }
     }
     if (Txt_Senha.Text.Trim() == "")
     {
         Lbl_ErroSenha.Text    = "Digite a senha";
         Lbl_ErroSenha.Visible = true;
         processar             = false;
     }
     else
     {
         if (Txt_Senha.Text.Trim().Length != 8)
         {
             Lbl_ErroSenha.Text    = "A senha deve conter 8 dígitos";
             Lbl_ErroSenha.Visible = true;
             processar             = false;
         }
         else
         {
             if (Txt_Senha.Text.Trim() != Txt_Confirmar.Text.Trim())
             {
                 Lbl_ErroConfirmar.Visible = true;
                 processar = false;
             }
         }
     }
     if (processar)
     {
         Form frm = new Form_Load();
         frm.Show();
         frm.Refresh();
         try
         {
             Usuario novo = new Usuario
             {
                 Nome      = Txt_Nome.Text.Trim(),
                 Email     = Txt_Email.Text.Trim().ToLower(),
                 Foto      = null,
                 Senha     = Txt_Senha.Text.Trim(),
                 TipoConta = "E"
             };
             UsuarioDAL dal = new UsuarioDAL();
             dal.Inserir(novo);
             Program.Email = novo.Email;
             frm.Close();
             this.Close();
         }
         catch
         {
             MessageBox.Show("Erro de conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
             frm.Close();
         }
     }
     processar = true;
 }
コード例 #3
0
 private void PTB_Logar_Click(object sender, EventArgs e)
 {
     if (Txt_Login.Text.Trim() == "")
     {
         MessageBox.Show("Preencha o Login", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
         processar = false;
     }
     if (Txt_Senha.Text.Trim() == "")
     {
         MessageBox.Show("Preencha a Senha", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
         processar = false;
     }
     if (processar)
     {
         Form frm = new Form_Load();
         frm.Show();
         frm.Refresh();
         try
         {
             UsuarioDAL dal = new UsuarioDAL();
             if (dal.Logar(Txt_Login.Text.Trim(), Txt_Senha.Text.Trim()))
             {
                 Usuario atual = dal.Consultar(Txt_Login.Text.Trim());
                 if (atual.TipoConta != "B")
                 {
                     Form menu = new Form_Menu();
                     this.Visible           = false;
                     Program.Email          = "";
                     UsuarioAtual.ID        = atual.ID;
                     UsuarioAtual.Nome      = atual.Nome;
                     UsuarioAtual.Email     = atual.Email;
                     UsuarioAtual.Foto      = atual.Foto;
                     UsuarioAtual.TipoConta = atual.TipoConta;
                     UsuarioAtual.Senha     = "";
                     Program.Login          = this;
                     frm.Close();
                     menu.ShowDialog();
                     Txt_Login.Clear();
                     Txt_Senha.Clear();
                     Program.Email = "";
                     Txt_Login.Focus();
                 }
                 else
                 {
                     MessageBox.Show("Essa conta foi banida", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     frm.Close();
                 }
             }
             else
             {
                 MessageBox.Show("Login e/ou Senha estão incorretos", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 frm.Close();
             }
         }
         catch
         {
             MessageBox.Show("Erro de conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
             frm.Close();
         }
     }
     processar = true;
 }
コード例 #4
0
 private void Btn_Publicar_Click(object sender, EventArgs e)
 {
     SumirErro();
     if (Txt_Titulo.Text.Trim() == "")
     {
         Lbl_ErroTitulo.Visible = true;
         processar = false;
     }
     if (Txt_PerguntaResposta.Text.Trim() == "")
     {
         if (cadastrarpergunta)
         {
             Lbl_ErroPerguntaResposta.Text = "Digite o pergunta";
         }
         else
         {
             Lbl_ErroPerguntaResposta.Text = "Digite a resposta";
         }
         Lbl_ErroPerguntaResposta.Visible = true;
         processar = false;
     }
     if (processar)
     {
         Form frm = new Form_Load();
         frm.Show();
         frm.Refresh();
         if (cadastrarpergunta)
         {
             Pergunta Novapergunta = new Pergunta
             {
                 Resposta     = null,
                 Imagem       = new List <Imagem>(),
                 Texto        = Txt_PerguntaResposta.Text.Trim(),
                 Titulo       = Txt_Titulo.Text.Trim(),
                 Usuario      = UsuarioAtual.ID,
                 Visibilidade = true
             };
             if (imagens.Count > 0)
             {
                 Novapergunta.Imagem = imagens;
             }
             try
             {
                 PerguntaDAL dal = new PerguntaDAL();
                 dal.Inserir(Novapergunta);
                 frm.Close();
                 this.Close();
             }
             catch
             {
                 MessageBox.Show("Erro de Conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 frm.Close();
             }
         }
         else
         {
             Resposta resposta = new Resposta
             {
                 Pergunta     = this.pergunta,
                 Imagem       = new List <Imagem>(),
                 Texto        = Txt_PerguntaResposta.Text.Trim(),
                 Titulo       = Txt_Titulo.Text.Trim(),
                 Usuario      = UsuarioAtual.ID,
                 Visibilidade = true
             };
             if (imagens.Count > 0)
             {
                 resposta.Imagem = imagens;
             }
             try
             {
                 RespostaDAL dal = new RespostaDAL();
                 dal.Inserir(resposta);
                 frm.Close();
                 this.Close();
             }
             catch
             {
                 MessageBox.Show("Erro de Conexão, tente novamente", "Enigma", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 frm.Close();
             }
         }
     }
     processar = true;
 }