Exemplo n.º 1
0
    protected void BtnLogin_Click(object sender, EventArgs e)
    {
        DataSet ds  = Pej_Pessoa_JuridicaBD.SelectLogin(LoginID.Text, Pej_Pessoa_JuridicaBD.PWD(SenhaID.Text));
        int     qtd = ds.Tables[0].Rows.Count;

        if (qtd == 1)
        {
            Pej_Pessoa_Juridica pej = new Pej_Pessoa_Juridica();
            pej.Pej_codigo                = Convert.ToInt32(ds.Tables[0].Rows[0]["pej_codigo"].ToString());
            pej.Pej_cnpj                  = Convert.ToInt64(ds.Tables[0].Rows[0]["pej_cnpj"].ToString());
            pej.Pej_nome_ficticio         = ds.Tables[0].Rows[0]["pej_nome_ficticio"].ToString();
            pej.Pej_razao_social          = ds.Tables[0].Rows[0]["pej_razao_social"].ToString();
            pej.Pej_email                 = ds.Tables[0].Rows[0]["pej_email"].ToString();
            pej.Pej_horario_funcionamento = ds.Tables[0].Rows[0]["pej_horario_funcionamento"].ToString();

            End_Endereco end = new End_Endereco();
            end.End_cep = Convert.ToInt32(ds.Tables[0].Rows[0]["end_cep"].ToString());
            pej.End_cep = end;

            Session["usuario"] = pej;

            Response.Redirect("Perfil/EspacoPerfil.aspx");
        }
        else
        {
            Response.Redirect("Principal.aspx");
        }
    }
    protected void BtnCadastrar_Click(object sender, EventArgs e)
    {
        Pej_Pessoa_Juridica pej = new Pej_Pessoa_Juridica();

        pej.Pej_razao_social  = txtNomeEmpresa.Text;
        pej.Pej_nome_ficticio = txtNomeFantasia.Text;
        pej.Pej_cnpj          = Convert.ToInt64(txtCNPJ.Text);
        pej.Pej_email         = txtEmail.Text;
        pej.Pej_senha         = Pej_Pessoa_JuridicaBD.PWD(txtSenha.Text);

        End_Endereco end = new End_Endereco();

        end.End_cep = Convert.ToInt32(cep.Text);
        pej.End_cep = end;

        switch (Pej_Pessoa_JuridicaBD.Insert(pej))
        {
        case 0:
            Response.Redirect("LoginEspacoEsportivo.aspx");
            break;

        case -2:
            ltl.Text = "<p class='text-danger'> Não foi possível efeturar o cadastro!!!</p>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);
            break;
        }
    }
Exemplo n.º 3
0
    protected void BtnSalvar_Click(object sender, EventArgs e)
    {
        Pej_Pessoa_Juridica pej = (Pej_Pessoa_Juridica)Session["usuario"];

        pej.Pej_razao_social  = txtNomeEmpresa.Text;
        pej.Pej_nome_ficticio = txtNomeFantasia.Text;
        pej.Pej_cnpj          = Convert.ToInt64(txtCNPJ.Text);
        pej.Pej_email         = txtEmail.Text;
        pej.Pej_senha         = Pef_Pessoa_FisicaBD.PWD(txtSenha.Text);

        End_Endereco end = new End_Endereco();

        end.End_cep = pej.End_cep.End_cep;
        pej.End_cep = end;

        switch (Pej_Pessoa_JuridicaBD.Update(pej))
        {
        case 0:
            Page.Response.Redirect("EspacoPerfil.aspx");
            break;

        case -2:
            Response.Redirect("QuemSomos.aspx");
            break;
        }
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string foto = "";

        if (FileUploadControl.PostedFile.ContentLength < 8388608)
        {
            try
            {
                if (FileUploadControl.HasFile)
                {
                    try
                    {
                        //Aqui ele vai filtrar pelo tipo de arquivo
                        if (FileUploadControl.PostedFile.ContentType == "image/jpeg" ||
                            FileUploadControl.PostedFile.ContentType == "image/png" ||
                            FileUploadControl.PostedFile.ContentType == "image/gif" ||
                            FileUploadControl.PostedFile.ContentType == "image/bmp")
                        {
                            try
                            {
                                //Obtem o  HttpFileCollection
                                HttpFileCollection hfc = Request.Files;
                                for (int i = 0; i < hfc.Count; i++)
                                {
                                    HttpPostedFile hpf = hfc[i];
                                    if (hpf.ContentLength > 0)
                                    {
                                        //Pega o nome do arquivo
                                        string nome = System.IO.Path.GetFileName(hpf.FileName);
                                        //Pega a extensão do arquivo
                                        string extensao = Path.GetExtension(hpf.FileName);
                                        //Gera nome novo do Arquivo numericamente
                                        string filename = string.Format("{0:00000000000000}", GerarID());
                                        //Caminho a onde será salvo
                                        hpf.SaveAs(Server.MapPath("~/uploads/fotos/") + filename + i
                                                   + extensao);

                                        //Prefixo p/ img pequena
                                        var prefixoP = "-p";
                                        //Prefixo p/ img grande
                                        var prefixoG = "-g";

                                        //pega o arquivo já carregado
                                        string pth = Server.MapPath("~/uploads/fotos/")
                                                     + filename + i + extensao;
                                        foto = filename + "0" + extensao;

                                        //Redefine altura e largura da imagem e Salva o arquivo + prefixo
                                        Redefinir.resizeImageAndSave(pth, 70, 53, prefixoP);
                                        Redefinir.resizeImageAndSave(pth, 500, 331, prefixoG);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            // Mensagem se tudo ocorreu bem
                            StatusLabel.Text = "Todas imagens carregadas com sucesso!";

                            Pej_Pessoa_Juridica pej = (Pej_Pessoa_Juridica)Session["usuario"];

                            pej.Pej_foto_perfil = foto;
                            switch (Pej_Pessoa_JuridicaBD.UpdateFoto(pej))
                            {
                            case 0:
                                break;

                            case -2:
                                break;
                            }
                            Page.Response.Redirect(Page.Request.Url.ToString(), true);
                        }
                        else
                        {
                            // Mensagem notifica que é permitido carregar apenas
                            // as imagens definida la em cima.
                            StatusLabel.Text = "É permitido carregar apenas imagens!";
                        }
                    }
                    catch (Exception ex)
                    {
                        // Mensagem notifica quando ocorre erros
                        StatusLabel.Text = "O arquivo não pôde ser carregado.  O seguinte erro ocorreu: " + ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                // Mensagem notifica quando ocorre erros
                StatusLabel.Text = "O arquivo não pôde ser carregado.  O seguinte erro ocorreu: " + ex.Message;
            }
        }
        else
        {
            // Mensagem notifica quando imagem é superior a 8 MB
            StatusLabel.Text = "Não é permitido carregar mais do que 8 MB";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["usuario"] == null)
        {
            Response.Redirect("../Erro.aspx");
        }

        Pej_Pessoa_Juridica pej = (Pej_Pessoa_Juridica)Session["usuario"];

        //EVENTOS DO LOCAL
        try
        {
            DataSet ds  = Eve_EventosBD.SelectEventosLocal(pej);
            int     qtd = ds.Tables[0].Rows.Count;

            int eve_codigo = Convert.ToInt32(ds.Tables[0].Rows[0]["eve_codigo"]);
            if (qtd > 0 && eve_codigo != 0)
            {
                cardVazio.Visible  = false;
                rptCard.DataSource = ds;
                rptCard.DataBind();
            }
        }
        catch (Exception ex)
        {
        }

        //HISTÓRICO DE EVENTOS
        try
        {
            DataSet ds2  = Eve_EventosBD.SelectHistoricoEventos(pej);
            int     qtd2 = ds2.Tables[0].Rows.Count;

            int eve_codigo2 = Convert.ToInt32(ds2.Tables[0].Rows[0]["eve_codigo"]);
            if (qtd2 > 0 && eve_codigo2 != 0)
            {
                historicoVazio.Visible  = false;
                RptHistorico.DataSource = ds2;
                RptHistorico.DataBind();
            }
        }
        catch (Exception ex)
        {
        }

        if (!IsPostBack)
        {
            CarregarDDL();
        }

        DataSet dsEnd  = Pej_Pessoa_JuridicaBD.GetEndereco(pej.End_cep.End_cep);
        string  cidade = Convert.ToString(dsEnd.Tables[0].Rows[0]["end_cidade"]);
        string  uf     = Convert.ToString(dsEnd.Tables[0].Rows[0]["end_uf"]);

        ltlEnd.Text  = "<h5>" + cidade + " - " + uf + "</h5>";
        ltlNome.Text = "<h3 class='nomePerfil'>" + pej.Pej_nome_ficticio + "</h3>";

        DataSet ds3  = Pej_Pessoa_JuridicaBD.Select(pej);
        int     qtd3 = ds3.Tables[0].Rows.Count;

        if (qtd3 > 0)
        {
            RptImage.DataSource = ds3;
            RptImage.DataBind();
        }
        else
        {
        }

        //ESPORTES ADICIONADOS
        Ofe_Oferece ofe = new Ofe_Oferece();

        ofe.Pej_codigo = pej;
        DataSet ds4  = Ofe_OfereceBD.SelectOferecidos(ofe);
        int     qtd4 = ds4.Tables[0].Rows.Count;

        if (qtd4 > 0)
        {
            espVazio.Visible      = false;
            RptEsporte.DataSource = ds4;
            RptEsporte.DataBind();
        }
        else
        {
            espVazio.Visible = true;
        }

        //MODAL DE ATUALIZAÇÃO DA FOTO DE PERFIL
        DataSet ds5  = Pej_Pessoa_JuridicaBD.Select(pej);
        int     qtd5 = ds5.Tables[0].Rows.Count;

        if (qtd5 > 0)
        {
            RptImageEdit.DataSource = ds5;
            RptImageEdit.DataBind();
        }
        else
        {
        }
    }