public static List <RelationPostContent> getRelationContent(int postID)
        {
            List <RelationPostContent> pList = new List <RelationPostContent>();
            SqlConnection myConnection       = new SqlConnection();

            myConnection.ConnectionString = System.Configuration.ConfigurationManager.
                                            ConnectionStrings["myConnection"].ConnectionString;
            try
            {
                myConnection.Open();
                SqlDataReader myReader = null;
                SqlCommand    command  = new SqlCommand("getRelationContent ", myConnection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("postID", postID));
                myReader = command.ExecuteReader();

                while (myReader.Read())
                {
                    string              postBody   = myReader["relationPostBody"].ToString();
                    string              postedBy   = myReader["postedBy"].ToString();
                    int                 postID2    = Convert.ToInt32(myReader["postID"]);
                    DateTime            threadTime = Convert.ToDateTime(myReader["threadTime"]);
                    RelationPostContent r          = new RelationPostContent(postID2, postBody, threadTime, postedBy);

                    pList.Add(r);
                }
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1.ToString());
            }

            return(pList);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["postID"] != null)
            {
                postID = Convert.ToInt32(Request.QueryString["postID"]);

                reply.Click += replyTopic;
                if (checkAccess() == 1)
                {
                    RelationPost rp = RelationPost.getRelationPostByID(postID);
                    List <RelationPostContent> cList = RelationPostContent.getRelationContent(postID);
                    title.Text = "Title: " + rp.title;

                    foreach (RelationPostContent c in cList)
                    {
                        Debug.WriteLine("This is running");
                        Panel post = new Panel();
                        post.CssClass = "post";

                        Panel userDetails = new Panel();
                        userDetails.CssClass = "user-detail";

                        Label user = new Label();
                        user.Text = c.postedBy;
                        userDetails.Controls.Add(user);

                        post.Controls.Add(userDetails);

                        Panel contentText = new Panel();
                        content.CssClass = "contentText";

                        TextBox b = new TextBox();
                        b.CssClass = "contentBox";
                        b.Wrap     = true;
                        b.Rows     = 5;
                        b.ReadOnly = true;
                        b.TextMode = TextBoxMode.MultiLine;

                        b.Text = c.postBody;
                        contentText.Controls.Add(b);

                        post.Controls.Add(contentText);

                        Panel padding = new Panel();
                        padding.CssClass = "padding";
                        Label l = new Label();
                        l.Text = c.threadTime.ToString();
                        padding.Controls.Add(l);

                        content.Controls.Add(post);
                        content.Controls.Add(padding);
                    }
                }
            }
            Logger.accessLogging(DateTime.Now + "," + userID + ",Ment_Post.aspx"); Logger.accessLogging(DateTime.Now + "," + userID + ",Post_Content.aspx");
        }
Esempio n. 3
0
        public void replyTopic(object sender, EventArgs e)
        {
            string postBody       = replyContent.Text;
            string postedBy       = userID;
            RelationPostContent p = new RelationPostContent(postID, postBody, postedBy);
            int success           = p.replyContent();

            Debug.WriteLine(success);
            if (success != 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Successfully reply topic'); window.location='" +
                                                        "/Mentorship/Mentorship.aspx';", true);
            }
        }
        public void getRelationPost()
        {
            TableHeaderRow  header = new TableHeaderRow();
            TableHeaderCell headerCell;

            string[] texts = { "Title ", "Posts", "Posted By" };
            for (int i = 0; i < texts.Length; i++)
            {
                headerCell          = new TableHeaderCell();
                headerCell.Text     = texts[i];
                headerCell.CssClass = "forumHeader";
                header.Cells.Add(headerCell);

                if (i == 0)
                {
                    headerCell.Style.Add("width", "600px");
                    headerCell.Style.Add("padding-left", "15px");
                }
            }
            forum.Rows.Add(header);

            rList = RelationPost.getRelationPost(userID);
            for (int i = 0; i < rList.Count; i++)
            {
                TableRow  row  = new TableRow();
                TableCell cell = new TableCell();

                HyperLink link = new HyperLink();
                link.NavigateUrl = "Post_Content.aspx?postID=" + rList[i].postID;
                link.Text        = rList[i].title;
                cell.CssClass    = "forumCell";
                cell.Controls.Add(link);
                cell.Style.Add("padding-left", "15px");
                row.Cells.Add(cell);

                cell          = new TableCell();
                cell.Text     = "" + RelationPostContent.retrieveNumOfPost(rList[i].postID);
                cell.CssClass = "forumCell";
                row.Cells.Add(cell);

                cell          = new TableCell();
                cell.Text     = rList[i].postedBy;
                cell.CssClass = "forumCell";
                row.Cells.Add(cell);


                forum.Rows.Add(row);
            }
        }