Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    int id = Int32.Parse(Request.QueryString["id"]);

                    Response.Cookies["idFormulario"].Value   = id.ToString();
                    Response.Cookies["idFormulario"].Expires = DateTime.Now.AddMinutes(10);

                    FormulariosDAL fd = new FormulariosDAL();

                    Formulario f = fd.BuscaPorId(id);

                    ltrNome.Text          = f.Nome;
                    ltrEmpresa.Text       = f.Empresa;
                    ltrDataCriacao.Text   = f.DataCriacao.ToString("dd/MM/yyyy");
                    ltrDataConclusao.Text = f.DataConclusao.ToString() != "" ? DateTime.Parse(f.DataConclusao).ToString("dd/MM/yyyy") : "N/A";
                    ltrUltimoAcesso.Text  = f.UltimoAcesso.ToString() != "" ? DateTime.Parse(f.UltimoAcesso).ToString("dd/MM/yyyy") : "N/A";
                    ltrAcessado.Text      = f.Acessado;

                    PerguntasPorFormulariosDAL ppfd = new PerguntasPorFormulariosDAL();
                    gridPerguntas.DataSource = ppfd.ListaPerguntasVinculadas(id);
                    gridPerguntas.DataBind();
                }
                catch (Exception ex)
                {
                    lblMensagem.Text = ex.Message;;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    EmailDAL       decrip = new EmailDAL();
                    FormulariosDAL fd     = new FormulariosDAL();

                    int    idForm  = Int32.Parse(decrip.Descriptografar(Request.QueryString["form"]));
                    string empresa = decrip.Descriptografar(Request.QueryString["ep"]);
                    string email   = decrip.Descriptografar(Request.QueryString["em"]);

                    if (fd.FormularioRespondido(idForm) == 1)
                    {
                        lblMensagem.Text  = "<h1>Formulário já respondido!!</h1>";
                        btnEnviar.Visible = false;
                        return;
                    }
                    if (fd.ValidaLink(idForm, empresa, email))
                    {
                        lblMensagem.Text  = "<h1>Não existe Formulários para este Link</h1>";
                        btnEnviar.Visible = false;
                        return;
                    }

                    Response.Cookies["idFormulario"].Value   = idForm.ToString();
                    Response.Cookies["idFormulario"].Expires = DateTime.Now.AddHours(4);

                    fd.AtualizaUltimoAcesso(idForm);

                    List <Perguntas> perguntas = new List <Perguntas>();

                    PerguntasPorFormulariosDAL ppfd = new PerguntasPorFormulariosDAL();
                    perguntas = ppfd.ListaPerguntasVinculadas(idForm);

                    string campos      = "";
                    int    numPergunta = 1;

                    foreach (Perguntas pergunta in perguntas)
                    {
                        campos += "<h4>" + numPergunta + " - " + pergunta.Descricao + "</h4><br />";
                        campos += "<textarea name=\"resposta" + pergunta.IdPergunta + "\" class=\"contact textarea\" rows=\"5\" cols=\"100\" style=\"height: 70px; width: 800px;\" runat=\"server\"></textarea><br /><br />";

                        Response.Cookies["idPergunta"].Values[numPergunta.ToString()] = pergunta.IdPergunta.ToString();
                        numPergunta++;
                    }

                    Response.Cookies["idPergunta"].Expires = DateTime.Now.AddHours(4);

                    ltrConteudo.Text = campos;
                }
            }
            catch (Exception)
            {
                lblMensagem.Text  = "<h1>Não foi possível acessar o formulário. </h1>";
                btnEnviar.Visible = false;
            }
        }
Esempio n. 3
0
        protected void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                int    idFormulario = Int32.Parse(Request.Cookies["idFormulario"].Value);
                Button btnExcluir   = (Button)sender;
                //resgatar o id enviado pelo CommandArgumment
                int idPergunta = Int32.Parse(btnExcluir.CommandArgument);

                PerguntasPorFormulariosDAL pd = new PerguntasPorFormulariosDAL();
                pd.Excluir(idFormulario, idPergunta);

                lblMensagem.Text = "Pergunta excluida com sucesso!";
                Response.Redirect("FormulariosDetalhes?id=" + idFormulario);
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }