public static int Delete(Ofe_Oferece ofe)
    {
        int retorno = 0;

        try
        {
            IDbConnection objConnection;
            IDbCommand    objCommand;

            string sql = "DELETE FROM OFE_OFERECE WHERE PEJ_CODIGO = ?pej_codigo AND ESP_CODIGO = ?esp_codigo ;";

            objConnection = Mapped.Connection();
            objCommand    = Mapped.Command(sql, objConnection);

            objCommand.Parameters.Add(Mapped.Parameter("?pej_codigo", ofe.Pej_codigo.Pej_codigo));
            objCommand.Parameters.Add(Mapped.Parameter("?esp_codigo", ofe.Esp_codigo.Esp_codigo));

            objCommand.ExecuteNonQuery();

            objConnection.Close();
            objConnection.Dispose();
            objCommand.Dispose();
        }
        catch (Exception ex)
        {
            retorno = -2;
        }
        return(retorno);
    }
    public static int Insert(Ofe_Oferece ofe)
    {
        int retorno = 0;

        try
        {
            IDbConnection objConnection;
            IDbCommand    objCommand;

            string sql = "INSERT INTO OFE_OFERECE (PEJ_CODIGO, ESP_CODIGO, OFE_ATIVO) VALUES ( ?pej_codigo, ?esp_codigo, true);";

            objConnection = Mapped.Connection();
            objCommand    = Mapped.Command(sql, objConnection);

            objCommand.Parameters.Add(Mapped.Parameter("?pej_codigo", ofe.Pej_codigo.Pej_codigo));
            objCommand.Parameters.Add(Mapped.Parameter("?esp_codigo", ofe.Esp_codigo.Esp_codigo));

            objCommand.ExecuteNonQuery();

            objConnection.Close();
            objConnection.Dispose();
            objCommand.Dispose();
        }
        catch (Exception ex)
        {
            retorno = -2;
        }
        return(retorno);
    }
    public static DataSet SelectNaoOferecidos(Ofe_Oferece ofe)
    {
        DataSet       ds = new DataSet();
        IDbConnection objConnection;
        IDbCommand    objCommand;
        IDataAdapter  objDataDadapter;

        objConnection = Mapped.Connection();
        string sql = "select esp_nome, esp_codigo from esp_esportes where esp_codigo";

        sql += " not in (select esp_codigo from ofe_oferece where pej_codigo = ?pej_codigo );";

        objCommand = Mapped.Command(sql, objConnection);

        objCommand.Parameters.Add(Mapped.Parameter("?pej_codigo", ofe.Pej_codigo.Pej_codigo));


        objDataDadapter = Mapped.Adapter(objCommand);
        objDataDadapter.Fill(ds);

        objConnection.Close();
        objCommand.Dispose();
        objConnection.Dispose();
        return(ds);
    }
Esempio n. 4
0
    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"];
        Ofe_Oferece         ofe = new Ofe_Oferece();

        if (!IsPostBack)
        {
            ofe.Pej_codigo = pej;

            DataSet ds  = Ofe_OfereceBD.SelectNaoOferecidos(ofe);
            int     qtd = ds.Tables[0].Rows.Count;

            if (qtd > 0)
            {
                cardVazio.Visible  = false;
                rptCard.DataSource = ds;
                rptCard.DataBind();
            }
            else
            {
                cardVazio.Visible = true;
                cardCheio.Visible = false;
            }

            DataSet ds2  = Ofe_OfereceBD.SelectOferecidos(ofe);
            int     qtd2 = ds2.Tables[0].Rows.Count;

            if (qtd2 > 0)
            {
                PesquisaVazia.Visible = false;
                rptCard2.DataSource   = ds2;
                rptCard2.DataBind();
            }
            else
            {
                PesquisaVazia.Visible = true;
                PesquisaCheia.Visible = false;
            }
        }
    }
Esempio n. 5
0
    protected void BtnAdicionar_Click(object sender, EventArgs e)
    {
        Button btn = (sender as Button);

        Pej_Pessoa_Juridica pej = (Pej_Pessoa_Juridica)Session["usuario"];
        Esp_Esportes        esp = new Esp_Esportes();
        Ofe_Oferece         ofe = new Ofe_Oferece();

        ofe.Pej_codigo = pej;
        esp.Esp_codigo = Convert.ToInt32(btn.CommandArgument.ToString());
        ofe.Esp_codigo = esp;

        switch (Ofe_OfereceBD.Insert(ofe))
        {
        case 0:
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
            break;

        case -2:
            break;
        }
    }
    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
        {
        }
    }