Ejemplo n.º 1
0
        protected void newEvent(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            userCookie = Request.Cookies["UserID"];

            User_Class myUser = new User_Class();
            myUser = myUser.getUser(userCookie.Value);
            myUser.getFriends();

            Events_Class events = new Events_Class();
            //events.Date = TextBoxDate.Text;
            //TextBoxDate.Text = "disabled";

            events.Date = Calendar1.SelectedDate.ToString();
            events.Location = TextBoxLocation.Text;
            events.Description = TextBoxDescription.Text;
            int indice = 0;

            events.Users.Add(myUser);

            foreach (ListItem li in ListBox2.Items)
            {
                indice = Int32.Parse(li.Value);
                events.Users.Add(myUser.Friends[indice]);

            }

            events.addEvent();
            Response.Redirect("Events.aspx", true);
        }
Ejemplo n.º 2
0
        public bool addEvent(Events_Class item)
        {
            bool añadido=false;

            try
            {
                if(item.Description.Length>=50)
                    item.Description=item.Description.ToString().Substring(0,50);
                if (item.Location.Length >= 50)
                    item.Location=item.Location.ToString().Substring(0, 50);

                SqlConnection con = new SqlConnection(connection);
                string sql = "INSERT INTO EVENTS (DATE,DESCRIPTION,LOCATION) OUTPUT INSERTED.ID VALUES ('" + item.Date.ToString() + "', '" + item.Description.ToString() + "', '" + item.Location.ToString()+ "')";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    item.Id = Int32.Parse(reader["ID"].ToString());
                }
                cmd.Connection.Close();

                SqlCommand cmd1;
                String sql2;
                foreach (User_Class user in item.Users)
                {

                    sql2 = "INSERT INTO US_EV_REL(UID, EID) VALUES (" + user.Id + "," + item.Id + ")";
                    cmd1 = new SqlCommand(sql2, con);
                    cmd1.Connection.Open();
                    cmd1.ExecuteNonQuery();
                    cmd1.Connection.Close();
                }
                añadido = true;
            }
            catch (Exception ex)
            {
                añadido = false;
            }
            finally
            {
            }

            return añadido;
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            HttpCookie passCookie;

            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];

            if (userCookie == null || passCookie == null)
            {
                Response.Redirect("../Account/Login.aspx");
            }
            else
            {
                User_Class usuario_sesion = new User_Class();
                usuario_sesion = usuario_sesion.getUser(userCookie.Value);

                if (usuario_sesion.Pass == passCookie.Value)
                {
                    String s;
                    s = Request.QueryString["ID"];

                    if (s != null)
                    {

                        int id = Int32.Parse(s);

                        User_Class myUser = new User_Class();
                        myUser = myUser.getUser(userCookie.Value);

                        Events_Class events = new Events_Class();
                        events = events.getEvent(id);
                        events.addUser(myUser);
                        Label1.Text = events.ToString();
                        Response.Redirect("..//Asp_forms/Events.aspx");

                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
Ejemplo n.º 4
0
        protected void Search(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            userCookie = Request.Cookies["UserID"];

            User_Class myUser = new User_Class();
            myUser = myUser.getUser(userCookie.Value);

            Events_Class events = new Events_Class();
            List<Events_Class> eventsList = new List<Events_Class>();

            eventsList = events.searchEvents(TextBox1.Text, myUser.Id);

            int totalEvents = eventsList.Count();
            int counter = 0;
            Panel p = new Panel();
            Label t = new Label();
            HyperLink le = new HyperLink();

            while (counter < totalEvents)
            {
                string id = eventsList[counter].Id.ToString();
                p = new Panel();
                t = new Label();
                le = new HyperLink();

                p.ID = "panel" + id;
                t.ID = "t" + id;
                le.ID = "le" + id;

                t.Text = eventsList[counter].ToString()+ "<BR>";
                le.Text = "ADD";

                le.NavigateUrl = "~/Asp_forms/AddToEvents.aspx?ID=" + eventsList[counter].Id;

                p.Controls.Add(t);
                p.Controls.Add(le);
                Panel2.Controls.Add(p);

                counter++;
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            HttpCookie passCookie;

            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];

            if (userCookie == null || passCookie == null)
            {
                Response.Redirect("../Account/Login.aspx");
            }
            else
            {
                User_Class usuario_sesion = new User_Class();
                usuario_sesion = usuario_sesion.getUser(userCookie.Value);

                if (usuario_sesion.Pass == passCookie.Value)
                {
                    User_Class myUser = new User_Class();
                    myUser = myUser.getUser(userCookie.Value);

                    Events_Class events = new Events_Class();
                    List<Events_Class> eventsList = new List<Events_Class>();

                    eventsList = events.userEvents(myUser.Id);

                    int totalEvents = eventsList.Count();
                    int counter = 0;
                    Panel p = new Panel();
                    Label t = new Label();
                    HyperLink le = new HyperLink();

                    Panel header = new Panel();
                    Panel content = new Panel();
                    Panel footer = new Panel();

                    Panel cal = new Panel();
                    Panel textcontent = new Panel();
                    Label texto2 = new Label();

                    while (counter < totalEvents)
                    {
                        string id = eventsList[counter].Id.ToString();
                        p = new Panel();
                        t = new Label();
                        Label t2 = new Label();
                        Label t3 = new Label();
                        le = new HyperLink();
                        ImageButton removeButton = new ImageButton();

                        p.ID = "panel" + id;
                        t.ID = "t" + id;
                        le.ID = "le" + id;

                        t3.Text = "<BR><BR>" + eventsList[counter].Date.ToString();
                        t2.Text = "<BR>" + eventsList[counter].Description.ToString() + "<BR><BR>";
                        t.Text = eventsList[counter].Location.ToString() + "<BR>";
                        t.CssClass = "cal_location";
                        t2.CssClass = "cal_description";
                        t3.CssClass = "cal_date";

                        removeButton.ToolTip = "Remove";
                        removeButton.ImageUrl = "../Images/deleteButton.png";
                        removeButton.PostBackUrl = "~/Asp_forms/RemoveUserFromEvents.aspx?ID=" + eventsList[counter].Id;
                        removeButton.Width = 20;

                        header = new Panel();
                        content = new Panel();
                        footer = new Panel();

                        cal = new Panel();
                        textcontent = new Panel();

                        texto2 = new Label();

                        header.ID = "header" + id;
                        content.ID = "content" + id;
                        footer.ID = "footer" + id;
                        cal.ID = "cal" + id;

                        footer.CssClass = "calfooter";
                        header.CssClass = "calheader";
                        header.HorizontalAlign = HorizontalAlign.Center;
                        content.CssClass = "calcontent";
                        textcontent.CssClass = "caldefault";
                        cal.CssClass = "cal";
                        content.BackColor = System.Drawing.Color.White;

                        header.Height = 82;
                        header.Width = 300;
                        footer.Height = 50;

                        header.Controls.Add(t3);
                        textcontent.Controls.Add(t);
                        textcontent.Controls.Add(t2);
                        textcontent.Controls.Add(le);
                        textcontent.Controls.Add(removeButton);

                        content.Controls.Add(textcontent);

                        cal.Controls.Add(header);
                        cal.Controls.Add(content);
                        cal.Controls.Add(footer);

                        cal.Width = 300;

                        Panel2.Controls.Add(cal);

                        counter++;
                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //When the page reloads keeps the cursor on the same position
            Page.MaintainScrollPositionOnPostBack = true;

            HttpCookie userCookie;
            HttpCookie passCookie;

            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];

            if (userCookie == null || passCookie == null)
            {
                Response.Redirect("../Account/Login.aspx");
            }
            else
            {
                User_Class usuario_sesion = new User_Class();
                usuario_sesion = usuario_sesion.getUser(userCookie.Value);

                if (usuario_sesion.Pass == passCookie.Value)
                {
                    if (!IsPostBack)
                    {
                        User_Class myUser = new User_Class();
                        myUser = myUser.getUser(userCookie.Value);

                        Events_Class events = new Events_Class();

                        myUser.getFriends();

                        ListBox1.Items.Clear();
                        ListBox1.Width = 100;
                        ListBox2.Width = 100;

                        int i = 0;

                        ListItem l = new ListItem();

                        while (i < myUser.Friends.Count)
                        {
                            l = new ListItem();

                            l.Text = myUser.Friends[i].Name;
                            l.Value = i.ToString();
                            ListBox1.Items.Add(l);
                            i++;
                        }
                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
Ejemplo n.º 7
0
        public List<Events_Class> userNewEvents(int userID)
        {
            SqlConnection con = new SqlConnection(connection);
            List<Events_Class> eventsList = new List<Events_Class>();

            try
            {

                string sql = "SELECT * FROM EVENTS WHERE ID NOT IN(SELECT EID FROM US_EV_REL WHERE UID = " + userID + ")";
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                Events_Class events = new Events_Class();

                while (reader.Read())
                {
                    events = new Events_Class();
                    events.Id = int.Parse(reader["ID"].ToString());
                    events.Date = reader["DATE"].ToString();
                    events.Description = reader["DESCRIPTION"].ToString();
                    events.Location = reader["LOCATION"].ToString();

                    eventsList.Add(events);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                con.Close();
            }

            return eventsList;
        }
Ejemplo n.º 8
0
        public void updateEvent(Events_Class item)
        {
            SqlConnection con = new SqlConnection(connection);
            string sql = "UPDATE EVENTS SET DATE = " + item.Date + ", DESCRIPTION = " + item.Description + ", LOCATION = " + item.Location + "WHERE ID = " + item.Id;
            SqlCommand cmd = new SqlCommand(sql, con);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
            }
            catch { }
            finally
            {
                con.Close();
            }
        }
Ejemplo n.º 9
0
        public Events_Class obtainEvent(int id)
        {
            SqlConnection con = new SqlConnection(connection);
            string sql = "SELECT * FROM EVENTS WHERE ID = " + id;
            Events_Class events = new Events_Class();

            try
            {
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    events = new Events_Class();
                    events.Id = int.Parse(reader["ID"].ToString());
                    events.Date = DateTime.Parse(reader["DATE"].ToString()).ToShortDateString();
                    events.Description = reader["DESCRIPTION"].ToString();
                    events.Location = reader["LOCATION"].ToString();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                con.Close();
            }

            return events;
        }
Ejemplo n.º 10
0
        public bool deleteEvent(Events_Class item)
        {
            bool borrado;

            SqlConnection con = new SqlConnection(connection);
            string sql = "DELETE FROM EVENTS WHERE ID = " + item.Id;
            SqlCommand cmd = new SqlCommand(sql, con);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                borrado = true;
            }
            catch (Exception ex)
            {
                borrado = false;
            }
            finally
            {
                con.Close();
            }

            return borrado;
        }
Ejemplo n.º 11
0
 public void unirEvento(Events_Class ec)
 {
     events.Add(ec);
     this.updateUser();
 }