コード例 #1
0
        public static List <RelationPost> getRelationPost(string userID)
        {
            SqlConnection myConnection = new SqlConnection();

            myConnection.ConnectionString = System.Configuration.ConfigurationManager.
                                            ConnectionStrings["myConnection"].ConnectionString;
            List <RelationPost> rList = new List <RelationPost>();

            try
            {
                myConnection.Open();
                SqlDataReader myReader = null;
                SqlCommand    command  = new SqlCommand("getRelationPost", myConnection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("userID", userID));
                myReader = command.ExecuteReader();

                while (myReader.Read())
                {
                    int          relationID = Convert.ToInt32(myReader["relationID"]);
                    string       postedBy   = myReader["postedBy"].ToString();
                    int          postID     = Convert.ToInt32(myReader["postID"]);
                    string       postTitle  = myReader["postTitle"].ToString();
                    RelationPost r          = new RelationPost(postedBy, Relation.getRelationByRelationID(relationID), postTitle, postID);

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

            return(rList);
        }
コード例 #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");
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public void postRelation(object sender, EventArgs e)
        {
            Relation r = null;

            if (userMode == 1)
            {
                r = Relation.getRelationByID(MentorList.SelectedItem.Value, userID);
            }
            else if (userMode == 2)
            {
                r = Relation.getRelationByID(userID, MentorList.SelectedItem.Value);
            }
            RelationPost p      = new RelationPost(userID, r, topic.Text);
            int          result = p.post(content.Text);

            if (result == 1)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Successfully posted topic'); window.location='" +
                                                        "/Mentorship.aspx';", true);
            }
        }