示例#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 btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                int idFormulario = Int32.Parse(Request.Cookies["idFormulario"].Value);

                foreach (GridViewRow linha in gridPerguntas.Rows)
                {
                    //pegar o checkbox contido em cada linha do grid..
                    CheckBox chkPergunta = (CheckBox)linha.FindControl("chkPergunta");

                    if (chkPergunta.Checked) //se o checkbox esta marcado..
                    {
                        //resgatar o id da conta armazenado no HiddenField
                        HiddenField txtIdPergunta = (HiddenField)linha.FindControl("IdPergunta");
                        int         idPergunta    = Int32.Parse(txtIdPergunta.Value);

                        FormulariosDAL fd = new FormulariosDAL();
                        fd.AdicionarPerguntas(idFormulario, idPergunta);
                    }
                }
                Response.Redirect("FormulariosDetalhes?id=" + idFormulario);
                lblMensagem.Text = "Perguntas associadas com sucesso!!";
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                Formulario f = new Formulario();
                f.Nome          = txtNome.Text;
                f.Empresa       = txtEmpresa.Text;
                f.DataCriacao   = DateTime.Now;
                f.DataConclusao = "NULL";
                f.UltimoAcesso  = "NULL";
                f.Acessado      = "NAO";
                f.Email         = txtEmail.Text;
                f.Enviado       = false;

                FormulariosDAL fd = new FormulariosDAL();
                fd.Inserir(f);

                txtNome.Text     = string.Empty;
                txtEmpresa.Text  = string.Empty;
                lblMensagem.Text = "Formulário cadastrado com sucesso!";
            }
            catch (Exception ex)
            {
                lblMensagem.Text = "Erro ao inserir formulário: " + 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;
            }
        }
        protected void gridFormularios_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gridFormularios.PageIndex = e.NewPageIndex;

            FormulariosDAL fd = new FormulariosDAL();

            gridFormularios.DataSource = fd.BuscarTodos();
            gridFormularios.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         FormulariosDAL fd = new FormulariosDAL();
         gridFormularios.DataSource = fd.BuscarTodos();
         gridFormularios.DataBind();
     }
 }
示例#7
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtAltCodigo.Text == "")
            {
                MessageBox.Show("Um escritório deve ser selecionado para alteração!");
            }
            else
            {
                try
                {
                    DadosInformation dados = new DadosInformation();

                    dados.Cod_empresa = Convert.ToInt32(txtAltCodigo.Text);
                    dados.CNPJ        = txtAltCnpj.Text;
                    dados.Data        = Convert.ToDateTime(mskAltData.Text);
                    dados.Empresa     = txtAltEmpresa.Text;
                    dados.Nire        = txtAltNire.Text;
                    dados.Parametro   = txtAltParametro.Text;
                    dados.Registro    = txtAltRegistro.Text;

                    FormulariosDAL frmDal = new FormulariosDAL();
                    frmDal.Alterar(dados);
                    MessageBox.Show("Empresa atualizada com sucesso!");

                    mskAltData.Text      = "";
                    txtAltCnpj.Text      = "";
                    txtAltCodigo.Text    = "";
                    txtAltEmpresa.Text   = "";
                    txtAltNire.Text      = "";
                    txtAltParametro.Text = "";
                    txtAltRegistro.Text  = "";

                    if (this.dgvAltEmpresa.DataSource != null)
                    {
                        this.dgvAltEmpresa.DataSource = null;
                    }
                    else
                    {
                        this.dgvAltEmpresa.Rows.Clear();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro: " + ex.Message);
                }
            }
        }
        protected void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                //sender -> sempre é o elemento que chamou o evento.. (Button)
                Button btnExcluir = (Button)sender;
                //resgatar o id enviado pelo CommandArgumment
                int id = Int32.Parse(btnExcluir.CommandArgument);

                FormulariosDAL fd = new FormulariosDAL();
                fd.Excluir(id);

                Response.Redirect("FormulariosListar.aspx");
                lblMensagem.Text = "Formulário excluido com sucesso!";
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                Formulario f = new Formulario();
                f.IdFormulario = Int32.Parse(Request.QueryString["id"].ToString());
                f.Nome         = txtNome.Text;
                f.Empresa      = txtEmpresa.Text;
                f.Email        = txtEmail.Text;

                FormulariosDAL fd = new FormulariosDAL();
                fd.Atualizar(f);

                lblMensagem.Text = "Formulário atualizado com sucesso.";
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (String.IsNullOrEmpty(Request.QueryString["id"].ToString()))
                {
                    lblMensagem.Text = "Não foi Possível achar o formulário.";
                    return;
                }

                int            idForm = Int32.Parse(Request.QueryString["id"].ToString());
                Formulario     f      = new Formulario();
                FormulariosDAL fd     = new FormulariosDAL();

                f = fd.BuscaPorId(idForm);

                txtNome.Text    = f.Nome;
                txtEmpresa.Text = f.Empresa;
                txtEmail.Text   = f.Email;
            }
        }
示例#11
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            FormulariosDAL dados = new FormulariosDAL();

            dgvAltEmpresa.DataSource = dados.AlterarEmpresa(txtBuscar.Text);
        }