コード例 #1
0
ファイル: Party_CAD.cs プロジェクト: villena/StickyNotes
        public bool addNote(Note_Class note, int g_id, int author_id)
        {
            bool insertado = false;

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            SqlConnection con = new SqlConnection(connection);

            try
            {
                con.Open();
                string sql1 = "INSERT INTO NOTES (KIND,CREATION_DATE,TEXT,PARTY_ID,AUTHOR)  VALUES ('G', '" + note.Date.ToString() + "', '" + note.Text + "'," + g_id +", "+author_id+ ")";
                SqlCommand cmd1 = new SqlCommand(sql1, con);
                cmd1.ExecuteNonQuery();
                insertado = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                con.Close();
            }

            return insertado;
        }
コード例 #2
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);
                        Note_Class note = new Note_Class();

                        note.Id = id;

                        if (note.deleteNote())
                            Response.Redirect("..//Asp_forms/Notes.aspx");
                        else
                        {
                            Label l = new Label();

                            l.Text = "An error has occurred, please try again later.";
                            Panel1.Controls.Add(l);
                        }
                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
コード例 #3
0
ファイル: Note_CAD.cs プロジェクト: villena/StickyNotes
        public bool addNote(Note_Class notec, int id)
        {
            bool insertado = false;

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            SqlConnection con = new SqlConnection(connection);

            try
            {

                string sql1 = "INSERT INTO NOTES (KIND,CREATION_DATE,TEXT, AUTHOR) OUTPUT INSERTED.ID VALUES (" + "'"+notec.Type+"'" + "," + "'" + notec.Date + "'" + "," + "'" + notec.Text + "'," + id+ ")";
                int note_id = 0;

                SqlCommand cmd1 = new SqlCommand(sql1, con);

                cmd1.Connection.Open();
                SqlDataReader reader = cmd1.ExecuteReader();

                if (reader.Read())
                {
                    cmd1.Connection.Close();
                    note_id = Int32.Parse(reader["ID"].ToString());

                    string sql2 = "INSERT INTO US_NO_REL (UID,NID) VALUES (" + id + "," + note_id + ")";

                    SqlCommand cmd2 = new SqlCommand(sql2, con);
                    cmd2.Connection.Open();
                    cmd2.ExecuteNonQuery();
                    cmd2.Connection.Close();
                }

                insertado = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {

            }

            return insertado;
        }
コード例 #4
0
ファイル: Editnotes.aspx.cs プロジェクト: villena/StickyNotes
        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);

                        note.Id = id;

                        note = note.getNote(id);

                        Label2.Text = note.Text;

                    }
                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
コード例 #5
0
        protected void Create_Note(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            userCookie = Request.Cookies["UserID"];
            if (userCookie == null)
            {
                Response.Redirect("../Account/Login.aspx");
            }
            else
            {

             string s = Request.QueryString["ID"];
             if (s != null)
             {
                 Party_Class party = new Party_Class();
                 party.Id = Int32.Parse(s);

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

                 Note_Class note = new Note_Class();
                 note.Text = DescripcionNota.Text;
                 note.Date = DateTime.Now.ToShortDateString();

                 if (party.addNote(note, user.Id))
                 {
                     Page.MaintainScrollPositionOnPostBack = true;
                     Response.Redirect("~/Asp_forms/Groups_Notes.aspx?ID=" + party.Id);
                 }
                 else
                     Label2.Text = "An error has occurred";
             }

            }

            /* Create note with the button 'New Note' */
        }
コード例 #6
0
ファイル: Party_Class.cs プロジェクト: villena/StickyNotes
 public bool addNote(Note_Class note, int author_id)
 {
     Party_CAD cad = new Party_CAD();
     return cad.addNote(note, this.Id, author_id);
 }
コード例 #7
0
ファイル: Note_CAD.cs プロジェクト: villena/StickyNotes
        public List<Note_Class> notesUserPrivate(int id)
        {
            List<Note_Class> notesList = new List<Note_Class>();

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            String sql = "SELECT * FROM NOTES WHERE KIND = 'P' AND ID IN (SELECT NID FROM US_NO_REL WHERE UID = " + id + ")";
            SqlConnection con = new SqlConnection(connection);

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

                while (reader.Read())
                {
                    notaTemp = new Note_Class();

                    notaTemp.Id = int.Parse(reader["ID"].ToString());
                    notaTemp.Text = reader["TEXT"].ToString();
                    notaTemp.Date = reader["CREATION_DATE"].ToString();
                    notaTemp.Type = Convert.ToChar(reader["KIND"]);

                    notesList.Add(notaTemp);
                }
            }
            catch (Exception ex) { }
            finally
            {
                con.Close();
            }

            return notesList;
        }
コード例 #8
0
ファイル: Note_CAD.cs プロジェクト: villena/StickyNotes
        public bool modifyNote(Note_Class notec)
        {
            bool modificacion = false;

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            SqlConnection con = new SqlConnection(connection);

            try
            {
                con.Open();
                string sql = "UPDATE NOTES SET TEXT = " + "'" + notec.Text + "'" + "WHERE ID =" + notec.Id;
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.ExecuteNonQuery();
                modificacion = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                con.Close();
            }

            return modificacion;
        }
コード例 #9
0
ファイル: Note_CAD.cs プロジェクト: villena/StickyNotes
        public Note_Class getNote(int id)
        {
            Note_Class note = new Note_Class();

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            SqlConnection con = new SqlConnection(connection);

            try
            {
                con.Open();
                SqlCommand com = new SqlCommand("SELECT * FROM NOTES WHERE ID=" + id, con);
                SqlDataReader dr = com.ExecuteReader();
                if (dr.Read())
                {

                    note.Id = id;
                    note.Type = Convert.ToChar(dr["KIND"]);
                    note.Date = dr["CREATION_DATE"].ToString();
                    note.Text = dr["TEXT"].ToString();
                    note.Author = Convert.ToInt32(dr["AUTHOR"]);
                }
            }
            catch (Exception ex) { }
            finally
            {
                con.Close();
            }
            return note;
        }
コード例 #10
0
ファイル: Note_CAD.cs プロジェクト: villena/StickyNotes
        public bool deleteNote(Note_Class notec)
        {
            bool borrado = false;

            String connection = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\Database.mdf;User Instance=true";
            SqlConnection con = new SqlConnection(connection);

            try
            {
                con.Open();
                string sql1 = "DELETE FROM US_NO_REL WHERE NID=" + notec.Id;
                string sql2 = "DELETE FROM NOTES WHERE ID =" + notec.Id;
                SqlCommand cmd1 = new SqlCommand(sql1, con);
                SqlCommand cmd = new SqlCommand(sql2, con);
                cmd1.ExecuteNonQuery();
                cmd.ExecuteNonQuery();
                borrado = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                con.Close();
            }

            return borrado;
        }
コード例 #11
0
ファイル: Party_CAD.cs プロジェクト: villena/StickyNotes
        public List<Note_Class> obtainNotes(int id_party)
        {
            SqlConnection con = new SqlConnection(connection);

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

                while (reader.Read())
                {
                    Note_Class notaAux = new Note_Class();

                    notaAux.Id = int.Parse(reader["ID"].ToString());
                    notaAux.Type = Convert.ToChar(reader["KIND"]);
                    notaAux.Date = reader["CREATION_DATE"].ToString();
                    notaAux.Text = reader["TEXT"].ToString();
                    notaAux.Author = Int32.Parse(reader["AUTHOR"].ToString());

                    myNotes.Add(notaAux);
                }

                con.Close();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                con.Close();
            }

            return myNotes;
        }
コード例 #12
0
ファイル: UserTable.aspx.cs プロジェクト: villena/StickyNotes
        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"];
                    User_Class user = new User_Class();
                    int uid = -1;

                    if (s != null || s == "")
                    {

                        uid = Int32.Parse(s);
                        user=user.getUser(uid);
                        Name.Text = user.Name + " "+ user.Surname + " |";
                        Nick.Text = user.Nick;
                        HyperLink3.NavigateUrl = "~//Asp_forms/UserTable.aspx/?ID=" + uid.ToString();
                        HyperLink3.Text = user.Nick;
                        Page.Title = user.Nick;

                    }
                    else
                        Response.Redirect("~//Asp_forms/Friends.aspx");

                    Panel p = new Panel();

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

                    Panel psub = new Panel();

                    Note_Class note=new Note_Class();

                    user.Notes=note.getNotesUserOpen(uid);

                   foreach(Note_Class personalnote in user.Notes)
                    {
                        p = new Panel();
                        psub = new Panel();

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

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

                        string id = personalnote.Id.ToString();

                        p.ID = "p" + id;
                        if (personalnote.Type == 'O')
                            p.CssClass = "postitnotes";
                        else if (personalnote.Type == 'P')
                            p.CssClass = "postitnotespink";

                        t.ID = "t" + id;
                        f.ID = "f" + id;

                        t.Text = personalnote.Text.ToString() + "<BR>";
                        a.Text = "<br/>" + user.getUser(personalnote.Author).Nick;
                        a.CssClass = "noteauthor";

                        psub.Controls.Add(a);

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

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

                    }

                }
                else
                {
                    Response.Redirect("../Account/Login.aspx");
                }
            }
        }
コード例 #13
0
ファイル: Note_Class.cs プロジェクト: villena/StickyNotes
 //Modify text
 public bool modifyNote(Note_Class notec)
 {
     Note_CAD u = new Note_CAD();
     if (u.modifyNote(notec))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #14
0
ファイル: AddNote.aspx.cs プロジェクト: villena/StickyNotes
        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";
        }