protected void afisareEvenimenteAsemanatoare()
    {
        int        id  = Convert.ToInt32(Session["IdEvenimentSelectat"]);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection  = sqlConnection1;
        cmd.CommandText = "select * from evenimente where id=" + id + ";";
        cmd.CommandType = CommandType.Text;

        //ButtonEvenimenteCreate.ToolTip = "1";
        //ButtonSearch.ToolTip = "0";

        // iau etichetele, data inceperii si orasul penru a vedea daca mai gasesc si alte evenimente cu aceleasi caracteristici

        string   etichete = "%", oras = "%"; //in etichete este si orasul
        DateTime data = DateTime.Now;

        try
        {
            sqlConnection1.Open();
            SqlDataReader InfoEvent = cmd.ExecuteReader();
            while (InfoEvent.Read())
            {
                etichete = InfoEvent.GetString(InfoEvent.GetOrdinal("etichete"));
                oras     = InfoEvent.GetString(InfoEvent.GetOrdinal("oras"));
                data     = InfoEvent.GetDateTime(InfoEvent.GetOrdinal("data_inceperii"));
            }
            sqlConnection1.Close();
        }
        catch (Exception ex)
        {
            LabelMesajEroare.Text += "Eroare in functia afisareInfoFeatured " + ex.Message;
        }


        try
        {
            cmd.CommandText = "select * from evenimente where (etichete like '" + etichete + "' or ( data_inceperii = '" + data + "' and oras= '" + oras + "') or data_inceperii = '" + data + "' or oras= '" + oras + "') and id !=" + id + " ;";
            cmd.CommandType = CommandType.Text;

            sqlConnection1.Open();

            DataTable Table_Evenimente = new DataTable();

            if (Table_Evenimente.Columns.Count == 0)
            {
                Table_Evenimente.Columns.Add("Titlu", typeof(string));
                Table_Evenimente.Columns.Add("Data", typeof(string));
                Table_Evenimente.Columns.Add("Locatie", typeof(string));
            }

            List <int>    idevenimetfeatured   = new List <int>();
            List <string> numeFiecareEveniment = new List <string>();
            int           contor = 0;

            SqlDataReader InfoEvenimente = cmd.ExecuteReader();

            while (InfoEvenimente.Read())
            {
                DataRow NewRow = Table_Evenimente.NewRow(); //un nou rand!!!

                NewRow[0] = InfoEvenimente.GetString(1);
                //  NewRow[1] = InfoEvenimente.GetString(1);

                numeFiecareEveniment.Add(InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("nume")));
                idevenimetfeatured.Add(InfoEvenimente.GetInt32(InfoEvenimente.GetOrdinal("id")));

                NewRow[1] = InfoEvenimente.GetDateTime(InfoEvenimente.GetOrdinal("data_inceperii")).ToString("dd MM yyyy");
                //LabelMesajEroare.Text += " Opa ";
                NewRow[2] = InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("oras"));
                //LabelMesajEroare.Text += " Opa ";
                Table_Evenimente.Rows.Add(NewRow);
                // contor++;
            }
            InfoEvenimente.Close();
            // LabelMesajEroare.Text = " contor = " + contor + " ";
            //}
            GridViewFeatured.DataSource = Table_Evenimente;
            GridViewFeatured.DataBind();

            int index_eveniment = 0; //pentru fiecare id de eveniment
            foreach (GridViewRow row in GridViewFeatured.Rows)
            {
                int        i    = 0;
                LinkButton spre = new LinkButton();
                spre.ID      = "LinkEveniment" + idevenimetfeatured[index_eveniment].ToString(); //fiecare buton are id-ul evenimentului pe care il refera
                spre.Text    = numeFiecareEveniment[index_eveniment].ToString();
                spre.Click  += new EventHandler(toPaginaEvenimentAccesat);
                spre.ToolTip = "ev_creat";
                row.Cells[i].Controls.Add(spre);
                // LabelMesajEroare.Text += spre.ID + "  i = " + i + " ";
                index_eveniment++;
            }
            // LabelMesajEroare.Text += " index eveniment "+index_eveniment + " " ;
        }
        catch (Exception ex)
        {
            LabelMesajEroare.Text += "Eroare in functia afisareInfoFeatured " + ex.Message;
        }



        sqlConnection1.Close();
    }
Beispiel #2
0
    protected void ButtonCreate_Click(object sender, EventArgs e)
    {
        GridView_listaEvenimenteOrganizate.ToolTip = "0";

        int        id  = Convert.ToInt32(Session["id"]);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection  = sqlConnection1;
        cmd.CommandText = "select * from evenimente where id_proprietar=" + id + ";";
        cmd.CommandType = CommandType.Text;

        ButtonEvenimenteCreate.ToolTip = "1";
        ButtonSearch.ToolTip           = "0";
        //Button_EvenimenteOrganizate.ToolTip = "0";

        try
        {
            sqlConnection1.Open();

            DataTable Table_Evenimente = new DataTable();

            if (Table_Evenimente.Columns.Count == 0)
            {
                Table_Evenimente.Columns.Add("Titlu", typeof(string));
                Table_Evenimente.Columns.Add("Data", typeof(string));
                Table_Evenimente.Columns.Add("Locatie", typeof(string));
            }

            List <int>    idevenimetfeatured   = new List <int>();
            List <string> numeFiecareEveniment = new List <string>();
            int           contor = 0;
            //using (SqlDataReader evenimetfeatured = cmd.ExecuteReader())
            //{
            //    while (evenimetfeatured.Read())
            //    {

            //        //contor++;
            //    }
            //    evenimetfeatured.Close();
            //}
            //LabelMesajEroare.Text = " contor = "+contor +" ";

            //foreach (int idEvent in idevenimetfeatured)
            //{

            SqlDataReader InfoEvenimente = cmd.ExecuteReader();

            while (InfoEvenimente.Read())
            {
                DataRow NewRow = Table_Evenimente.NewRow();     //un nou rand!!!

                NewRow[0] = InfoEvenimente.GetString(1);
                //  NewRow[1] = InfoEvenimente.GetString(1);

                numeFiecareEveniment.Add(InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("nume")));
                idevenimetfeatured.Add(InfoEvenimente.GetInt32(InfoEvenimente.GetOrdinal("id")));

                NewRow[1] = InfoEvenimente.GetDateTime(InfoEvenimente.GetOrdinal("data_inceperii")).ToString("dd MM yyyy");
                //LabelMesajEroare.Text += " Opa ";
                NewRow[2] = InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("oras"));
                //LabelMesajEroare.Text += " Opa ";
                Table_Evenimente.Rows.Add(NewRow);
                // contor++;
            }
            InfoEvenimente.Close();
            // LabelMesajEroare.Text = " contor = " + contor + " ";
            //}
            GridViewFeatured.DataSource = Table_Evenimente;
            GridViewFeatured.DataBind();

            int index_eveniment = 0; //pentru fiecare id de eveniment
            foreach (GridViewRow row in GridViewFeatured.Rows)
            {
                ButtonEvenimenteCreate.ToolTip = "1";
                int        i    = 0;
                LinkButton spre = new LinkButton();
                spre.ID      = "LinkEveniment" + idevenimetfeatured[index_eveniment].ToString(); //fiecare buton are id-ul evenimentului pe care il refera
                spre.Text    = numeFiecareEveniment[index_eveniment].ToString();
                spre.Click  += new EventHandler(toPaginaEvenimentAccesat);
                spre.ToolTip = "ev_creat";
                row.Cells[i].Controls.Add(spre);
                // LabelMesajEroare.Text += spre.ID + "  i = " + i + " ";
                index_eveniment++;
            }
            // LabelMesajEroare.Text += " index eveniment "+index_eveniment + " " ;
        }
        catch (Exception ex)
        {
            LabelMesajEroare.Text += "Eroare in functia ButtonCreate_CLick " + ex.Message;
        }

        //if (((Label)Panelcreate.FindControl("k2")) == null)
        //{
        //    Label k = new Label();
        //    k.ID = "k2";
        //    k.Text = "Rezultatele cautarii:";
        //    Panelcreate.Controls.Add(k);
        //    Panelcreate.Controls.Add(new LiteralControl("</br>"));
        //}
        //using (SqlDataReader SRD = cmd.ExecuteReader())
        //{
        //    while (SRD.Read())
        //    {
        //        LinkButton btn = new LinkButton();
        //        btn.ID = "LinkEvenimentCreat" + SRD.GetInt32(SRD.GetOrdinal("id")).ToString();
        //        if (((LinkButton)Panelcreate.FindControl(btn.ID)) == null)
        //        {
        //            ButtonEvenimenteCreate.ToolTip = "1";
        //            btn.ID = "LinkEvenimentCreat" + SRD.GetInt32(SRD.GetOrdinal("id")).ToString();
        //            btn.Text = SRD.GetString(SRD.GetOrdinal("nume")).ToString();
        //            btn.Click += new EventHandler(butonevenimentcreat);
        //            Panelcreate.Controls.Add(btn);
        //            Panelcreate.Controls.Add(new LiteralControl("</br>"));

        //            Label l3 = new Label();

        //            if (Convert.IsDBNull(SRD["descriere"])) l3.Text = "";
        //            else l3.Text = "Descriere :" + SRD.GetString(SRD.GetOrdinal("descriere")).ToString();

        //            Panelcreate.Controls.Add(l3);

        //            Label l = new Label();
        //            l.Text = "ID: " + SRD.GetInt32(SRD.GetOrdinal("Id")).ToString();
        //            l.Visible = false;
        //            Panelcreate.Controls.Add(l);
        //            Panelcreate.Controls.Add(new LiteralControl("</br>"));
        //            Panelcreate.Controls.Add(new LiteralControl("<p></p>"));
        //        }
        //    }
        //}
        sqlConnection1.Close();
    }
Beispiel #3
0
    protected void featurednelogat(object sender, EventArgs e)
    {
        SqlCommand cmd   = new SqlCommand();
        String     query = "select TOP 5 id_eveniment,count(id_utilizator) from participa group by id_eveniment order by id_eveniment desc";

        sqlConnection1.Open();
        cmd.CommandText = query;
        cmd.CommandType = CommandType.Text;
        cmd.Connection  = sqlConnection1;

        DataTable Table_Evenimente = new DataTable();

        if (Table_Evenimente.Columns.Count == 0)
        {
            Table_Evenimente.Columns.Add("Titlu", typeof(string));
            Table_Evenimente.Columns.Add("Locatie", typeof(string));
            Table_Evenimente.Columns.Add("Data", typeof(string));
        }

        List <int>    idevenimetfeatured   = new List <int>();
        List <string> numeFiecareEveniment = new List <string>();

        using (SqlDataReader evenimetfeatured = cmd.ExecuteReader())
        {
            while (evenimetfeatured.Read())
            {
                idevenimetfeatured.Add(evenimetfeatured.GetInt32(evenimetfeatured.GetOrdinal("id_eveniment")));
            }
            evenimetfeatured.Close();
        }

        foreach (int idEvent in idevenimetfeatured)
        {
            //LabelMesajEroare.Text += idEvent + "s#";
            query           = "SELECT id,nume,data_inceperii,oras from evenimente where id = " + idEvent;
            cmd.CommandText = query;
            SqlDataReader InfoEvenimente = cmd.ExecuteReader();

            while (InfoEvenimente.Read())
            {
                DataRow NewRow = Table_Evenimente.NewRow(); //un nou rand!!!

                NewRow[0] = InfoEvenimente.GetString(1);
                //  NewRow[1] = InfoEvenimente.GetString(1);
                numeFiecareEveniment.Add(InfoEvenimente.GetString(1));

                NewRow[2] = InfoEvenimente.GetDateTime(2).ToString("dd MM yyyy");
                //LabelMesajEroare.Text += " Opa ";
                NewRow[1] = InfoEvenimente.GetString(3);
                //LabelMesajEroare.Text += " Opa ";
                Table_Evenimente.Rows.Add(NewRow);
            }
            InfoEvenimente.Close();
        }
        GridViewFeatured.DataSource = Table_Evenimente;
        GridViewFeatured.DataBind();

        int index_eveniment = 0; //pentru fiecare id de eveniment

        foreach (GridViewRow row in GridViewFeatured.Rows)
        {
            int        i    = 0;
            LinkButton spre = new LinkButton();
            spre.ID     = "LinkEveniment" + idevenimetfeatured[index_eveniment].ToString(); //fiecare buton are id-ul evenimentului pe care il refera
            spre.Text   = numeFiecareEveniment[index_eveniment].ToString();
            spre.Click += new EventHandler(butoneveniment);
            row.Cells[i].Controls.Add(spre);
            //i++;

            //Label refuza = new Label();
            //refuza.ID = "r" + idevenimetfeatured[index_eveniment].ToString();
            //refuza.Text = row.Cells[2].Text.ToString();
            //row.Cells[i].Controls.Add(refuza);
            //i++;
            //Label nume = new Label();
            //nume.ID = "n" + idevenimetfeatured[index_eveniment].ToString();
            //nume.Text = row.Cells[1].Text.ToString();
            //nume.ToolTip = "toEvent";
            //row.Cells[i].Controls.Add(nume);
            index_eveniment++;
        }
        sqlConnection1.Close();
    }
Beispiel #4
0
    protected void ButtonSearch_Click(object sender, EventArgs e)
    {
        ButtonEvenimenteCreate.ToolTip = "0";
        // Button_EvenimenteOrganizate.ToolTip = "0";
        ButtonSearch.ToolTip = "1";
        GridView_listaEvenimenteOrganizate.ToolTip = "0";

        SqlCommand cmd = new SqlCommand();

        cmd.Connection = sqlConnection1;
        // cmd.CommandText = "select * from evenimente where nume = '" + SearchBox.Text + "';";
        cmd.CommandType = CommandType.Text;

        cmd.CommandText = "select * from evenimente ";

        if (SearchBox.Text != "")
        {
            String[]  cuvinteSearchBox = SearchBox.Text.Split(' ');
            ArrayList cuvinteCautate   = new ArrayList();
            foreach (String cuvant in cuvinteSearchBox)
            { // elimin elementele de tipul ""
                if (cuvant != "")
                {
                    cuvinteCautate.Add(cuvant);
                }
            }

            if (cuvinteCautate.Count == 0)
            { // caz special cand se introduce in search box doar spatiu
                return;
            }

            for (int pasCuvant = 0; pasCuvant < cuvinteCautate.Count; pasCuvant++)
            {
                if (pasCuvant == cuvinteCautate.Count - 1)
                {
                    if (pasCuvant == 0)
                    {
                        cmd.CommandText += " where ( etichete like '%" + cuvinteCautate[pasCuvant] + "%' )" + " or nume = '" + SearchBox.Text + "';";
                    }
                    else
                    {
                        cmd.CommandText += " ( etichete like '%" + cuvinteCautate[pasCuvant] + "%' )" + " or nume = '" + SearchBox.Text + "';";
                    }
                }
                else
                {
                    if (pasCuvant == 0)
                    {
                        cmd.CommandText += " where ( etichete like '%" + cuvinteCautate[pasCuvant] + "%' )" + " or ";
                    }
                    else
                    {
                        cmd.CommandText += " ( etichete like '%" + cuvinteCautate[pasCuvant] + "%' )" + " or ";
                    }
                }
            }
            //LabelMesajEroare.Text = cmd.CommandText;
            //-----------------------------------

            try
            {
                sqlConnection1.Open();

                DataTable Table_Evenimente = new DataTable();

                if (Table_Evenimente.Columns.Count == 0)
                {
                    Table_Evenimente.Columns.Add("Titlu", typeof(string));
                    Table_Evenimente.Columns.Add("Data", typeof(string));
                    Table_Evenimente.Columns.Add("Locatie", typeof(string));
                }

                List <int>    idevenimetfeatured   = new List <int>();
                List <string> numeFiecareEveniment = new List <string>();
                int           contor = 0;
                //using (SqlDataReader evenimetfeatured = cmd.ExecuteReader())
                //{
                //    while (evenimetfeatured.Read())
                //    {

                //        //contor++;
                //    }
                //    evenimetfeatured.Close();
                //}
                //LabelMesajEroare.Text = " contor = "+contor +" ";

                //foreach (int idEvent in idevenimetfeatured)
                //{

                SqlDataReader InfoEvenimente = cmd.ExecuteReader();

                while (InfoEvenimente.Read())
                {
                    DataRow NewRow = Table_Evenimente.NewRow(); //un nou rand!!!

                    NewRow[0] = InfoEvenimente.GetString(1);
                    //  NewRow[1] = InfoEvenimente.GetString(1);

                    numeFiecareEveniment.Add(InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("nume")));
                    idevenimetfeatured.Add(InfoEvenimente.GetInt32(InfoEvenimente.GetOrdinal("id")));

                    NewRow[1] = InfoEvenimente.GetDateTime(InfoEvenimente.GetOrdinal("data_inceperii")).ToString("dd MM yyyy");
                    //LabelMesajEroare.Text += " Opa ";
                    NewRow[2] = InfoEvenimente.GetString(InfoEvenimente.GetOrdinal("oras"));
                    //LabelMesajEroare.Text += " Opa ";
                    Table_Evenimente.Rows.Add(NewRow);
                    // contor++;
                }
                InfoEvenimente.Close();
                // LabelMesajEroare.Text = " contor = " + contor + " ";
                //}
                GridViewFeatured.DataSource = Table_Evenimente;
                GridViewFeatured.DataBind();

                int index_eveniment = 0; //pentru fiecare id de eveniment
                foreach (GridViewRow row in GridViewFeatured.Rows)
                {
                    int        i    = 0;
                    LinkButton spre = new LinkButton();
                    spre.ID      = "LinkEveniment" + idevenimetfeatured[index_eveniment].ToString(); //fiecare buton are id-ul evenimentului pe care il refera
                    spre.Text    = numeFiecareEveniment[index_eveniment].ToString();
                    spre.Click  += new EventHandler(toPaginaEvenimentAccesat);
                    spre.ToolTip = "ev_creat";
                    row.Cells[i].Controls.Add(spre);
                    // LabelMesajEroare.Text += spre.ID + "  i = " + i + " ";
                    index_eveniment++;
                }
                //  LabelMesajEroare.Text += " index eveniment " + index_eveniment + " ";
            }
            catch (Exception ex)
            {
                LabelMesajEroare.Text += "Eroare in functia ButtonCreate_CLick " + ex.Message;
            }


            //sqlConnection1.Open();
            //if (((Label)Panelsearch.FindControl("k1")) == null)
            //{
            //    Label k = new Label();
            //    k.ID = "k1";
            //    k.Text = "<h2>Rezultatele cautarii:</h2>";
            //    Panelsearch.Controls.Add(k);
            //}
            //using (SqlDataReader SRD = cmd.ExecuteReader())
            //{
            //    while (SRD.Read())
            //    {
            //        LinkButton btn = new LinkButton();
            //        btn.ID = "LinkEveniment" + SRD.GetInt32(SRD.GetOrdinal("id")).ToString();
            //        if (((LinkButton)Panelsearch.FindControl(btn.ID)) == null)
            //        {
            //            ButtonSearch.ToolTip = "1";
            //            btn.ID = "LinkEveniment" + SRD.GetInt32(SRD.GetOrdinal("id")).ToString();
            //            btn.Text = SRD.GetString(SRD.GetOrdinal("nume")).ToString();
            //            btn.Click += new EventHandler(butoneveniment);
            //            Panelsearch.Controls.Add(btn);
            //            //Panelsearch.Controls.Add(new LiteralControl("<br />"));


            //            //Label l2 = new Label();
            //            //l2.Text = "Nume: " + SRD.GetString(SRD.GetOrdinal("nume")).ToString();
            //            //Panelsearch.Controls.Add(l2);
            //            //Panelsearch.Controls.Add(new LiteralControl("</br>"));

            //            Label l3 = new Label();

            //            if (Convert.IsDBNull(SRD["descriere"])) l3.Text = "";
            //            else l3.Text = "<br />Descriere :" + SRD.GetString(SRD.GetOrdinal("descriere")).ToString();
            //            l3.Visible = false;
            //            Panelsearch.Controls.Add(l3);

            //            Label l4 = new Label();

            //            if (Convert.IsDBNull(SRD["data_inceperii"])) l4.Text = "";
            //            else l4.Text =  "<br />"+"Data :" + SRD.GetDateTime(SRD.GetOrdinal("data_inceperii")).ToString();

            //            Panelsearch.Controls.Add(l4);

            //            Label l5 = new Label();
            //            l5.Text = "<br />";
            //            if (Convert.IsDBNull(SRD["oras"])) l5.Text += "";
            //            else l5.Text += " "+SRD.GetString(SRD.GetOrdinal("oras")).ToString();
            //            if (Convert.IsDBNull(SRD["judet"])) l5.Text += "";
            //            else l5.Text += " "+SRD.GetString(SRD.GetOrdinal("judet")).ToString();
            //            if (Convert.IsDBNull(SRD["tara"])) l5.Text += "";
            //            else l5.Text += " "+SRD.GetString(SRD.GetOrdinal("tara")).ToString();

            //            Panelsearch.Controls.Add(l5);

            //            Label l = new Label();
            //            l.Text = "<p>ID: " + SRD.GetInt32(SRD.GetOrdinal("Id")).ToString() + "</p>";
            //            l.Visible = false;
            //            Panelsearch.Controls.Add(l);
            //            //Panelsearch.Controls.Add(new LiteralControl("<br />"));
            //            Panelsearch.Controls.Add(new LiteralControl("<p></p>"));
            //        }
            //    }
            //}
            sqlConnection1.Close();
        }
    }