Exemple #1
0
        public List<Category_Class> Categories()
        {
            List<Category_Class> list = new List<Category_Class>();
            SqlConnection c = new SqlConnection(conection);
            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("SELECT * FROM CATEGORY", c);
                SqlDataReader reader = com.ExecuteReader();

                while (reader.Read())
                {
                    Category_Class category = new Category_Class();
                    category.Id = int.Parse(reader["ID"].ToString());
                    category.Nombre = reader["NAME"].ToString();
                    list.Add(category);
                }
            }
            catch (Exception ex) { }
            finally
            {
                c.Close();
            }
            return list;
        }
Exemple #2
0
        public bool addCategoria(Category_Class categoria)
        {
            bool añadido;

            SqlConnection con = new SqlConnection(conection);

            try
            {
                con.Open();
                string sql = "INSERT INTO CATEGORIES (NAME) VALUES (" + categoria.Nombre + ")";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                añadido = true;
            }
            catch (Exception ex)
            {
                añadido = false;
            }
            finally
            {
                con.Close();
            }

            return añadido;
        }
        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)
                {

                    List<Category_Class> lista = new List<Category_Class>();
                    Category_Class category = new Category_Class();

                    if (Request.QueryString["cadena"] != null)
                        lista = filterCategories(Request.QueryString["cadena"], category.Categories());
                    else
                        lista = category.Categories();

                    if (lista.Count() == 0)
                    {
                        Label label = new Label();
                        label.ID = "LabelX";
                        label.Text = "<h2> No categories found! </h2>";
                        Panel2.Controls.Add(label);
                    }

                    for (int j = 0; j < lista.Count(); j++)
                    {
                        Panel2.Controls.Add(createNotesButton(lista.ElementAt(j).Id, lista.ElementAt(j).Nombre));

                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
        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)
                {
                    int categoryid = int.Parse(Request.QueryString["id"]);
                    Category_Class category = new Category_Class();
                    category = category.getCategoria(categoryid);

                    CategoryLabel.Text = category.Nombre + " Notes";
                    Panel p = new Panel();

                    Label t = new Label();
                    Label f = new Label();
                    Image ie = new Image();
                    ie.ImageUrl = "../Images/editButton.png";
                    ImageButton imgbuttone = new ImageButton();
                    ImageButton imgbuttonb = new ImageButton();

                    Panel psub = new Panel();

                    Note_CAD notaTemp = new Note_CAD();
                    List<Note_Class> notes = new List<Note_Class>();

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

                    notes = notaTemp.notesCategory(userTemp.Id, category.Id);

                    int i = notes.Count() - 1;
                    if (notes.Count() == 0)
                    {
                        noCategories.Text = "No " + category.Nombre + " notes found. Start creating one up here!";
                    }
                    else
                    {
                        while (i >= 0)
                        {
                            p = new Panel();
                            psub = new Panel();

                            t = new Label();
                            f = new Label();

                            imgbuttone = new ImageButton();
                            imgbuttonb = new ImageButton();

                            imgbuttone.ImageUrl = "../Images/editButton.png";
                            imgbuttone.PostBackUrl = "~/Asp_forms/Editnotes.aspx?ID=" + notes[i].Id.ToString();
                            imgbuttone.Width = 30;
                            imgbuttone.ToolTip = "Edit";

                            imgbuttonb.ImageUrl = "../Images/deleteButton.png";
                            imgbuttonb.PostBackUrl = "~/Asp_forms/Deletenote.aspx?ID=" + notes[i].Id.ToString();
                            imgbuttonb.Width = 30;
                            imgbuttonb.ToolTip = "Delete";

                            psub.CssClass = "default_panel";
                            psub.HorizontalAlign = HorizontalAlign.Right;

                            psub.Controls.Add(imgbuttonb);
                            psub.Controls.Add(imgbuttone);

                            string id = notes[i].Id.ToString();

                            p.ID = "p" + id;
                            p.CssClass = "postitnotes";
                            t.ID = "t" + id;
                            f.ID = "f" + id;

                            t.Text = notes[i].Text.ToString() + "<BR>";

                            p.Controls.Add(t);
                            p.Controls.Add(f);

                            p.Controls.Add(psub);
                            Panelnota.Controls.Add(p);

                            i--;
                        }

                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
Exemple #5
0
        protected void Send(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            userCookie = Request.Cookies["UserID"];
            user = new User_Class();
            user = user.getUser(userCookie.Value);
            user.getFriends();

            Note_Class note = new Note_Class();

            note.Text = TextBox1.Text;
            note.Date = DateTime.Now.ToShortDateString();

            foreach (ListItem li in ListBox1.Items)
            {
                if (li.Selected == true)
                {
                    if (Int32.Parse(li.Value) == 0)
                    {
                        note.Type = 'O';
                    }
                    else if (Int32.Parse(li.Value) == 1)
                    {
                        note.Type = 'P';
                    }

                }
            }

            Category_Class category = new Category_Class();
            if (TextBox2.Text != null && TextBox2.Text != "")
            {
                category.Nombre = TextBox2.Text;
                note.Category = category.getCategoryId();
            }
            else
                note.Category = -1;

            List<User_Class> users = new List<User_Class>();
            int indice = 0;
            foreach (ListItem li in ListBox2.Items)
            {
                indice = Int32.Parse(li.Value);
                users.Add(user.Friends[indice]);
            }

            if (note.Type!=' ' && note.addNote(user.Id, users))
                Response.Redirect("../Asp_forms/Notes.aspx");
            else
                Label4.Text = "An error has occurred";
        }
Exemple #6
0
        public Category_Class obtainCategoria(int id)
        {
            Category_Class categoria = new Category_Class();

            SqlConnection con = new SqlConnection(conection);

            try
            {
                con.Open();
                string sql = "SELECT * FROM CATEGORY WHERE ID = " + id;
                SqlCommand cmd = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    categoria.Id = id;
                    categoria.Nombre = reader["NAME"].ToString();
                }
            }
            catch (Exception ex) { }
            finally
            {
                con.Close();
            }

            return categoria;
        }