コード例 #1
0
        void fillpost()
        {
            SqlConnection cn = new SqlConnection();

            cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString();
            SqlCommand        cmd  = new SqlCommand("select * from wallpost order by wid desc", cn);
            DataSet           ds   = new DataSet();
            SqlDataAdapter    ad   = new SqlDataAdapter(cmd);
            SqlCommandBuilder cmdb = new SqlCommandBuilder(ad);

            ad.Fill(ds);
            r = new returnname();
            validfriend v1 = new validfriend();

            a.Add(Session["uname"].ToString());
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (a.Contains(dr[1].ToString()))
                {
                    if (v1.stat(dr[1].ToString()))
                    {
                        LinkButton l1 = new LinkButton();
                        l1.Text = "Like";
                        TextBox text = new TextBox();
                        text.Attributes["class"] = "form-control";
                        l1.CommandName           = dr[0].ToString();
                        l1.Click += new EventHandler(like_post);

                        text.ID = dr[0].ToString();

                        string s = r.name(dr[1].ToString());
                        text.AutoPostBack = true;
                        text.TextChanged += new EventHandler(send_comment);
                        A = new abc();
                        int t1 = A.chkpicstat(dr[1].ToString());
                        if (t1 == 0)
                        {
                            if (A.chkgender(dr[1].ToString()))
                            {
                                wall.Controls.Add(new LiteralControl("<div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='temp/b.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on&nbsp;" + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>"));
                            }
                            else
                            {
                                wall.Controls.Add(new LiteralControl("<div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='temp/g.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on&nbsp;" + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>"));
                            }
                        }
                        else
                        {
                            wall.Controls.Add(new LiteralControl(" <div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='Account/" + dr[1].ToString() + "/p.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on&nbsp;" + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>"));
                        }
                        string[] b = dr[4].ToString().Split('/');
                        if (!A.islike(Session["uname"].ToString(), l1.CommandName))
                        {
                            wall.Controls.Add(l1);
                        }
                        if (dr[5].ToString() == "0")
                        {
                            wall.Controls.Add(new LiteralControl("</a><span></span></div><ul class='comments'>"));
                        }
                        else
                        {
                            wall.Controls.Add(new LiteralControl("</a><span> "));
                            for (int i = 0; i < b.Length; i++)
                            {
                                wall.Controls.Add(new LiteralControl(" " + b[i] + ""));
                            }
                            wall.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;" + dr[5].ToString() + "Likes</a></span></div><ul class='comments'>"));
                        }
                        cmd.Dispose();
                        cn.Close();
                        SqlConnection cn1 = new SqlConnection();
                        cn1.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString();
                        SqlCommand        cmd1  = new SqlCommand("select * from comment order by cid asc", cn1);
                        DataSet           ds1   = new DataSet();
                        SqlDataAdapter    ad1   = new SqlDataAdapter(cmd1);
                        SqlCommandBuilder cmdb1 = new SqlCommandBuilder(ad1);
                        ad1.Fill(ds1);
                        foreach (DataRow dr1 in ds1.Tables[0].Rows)
                        {
                            string[] st = dr1[4].ToString().Split(' ');
                            if (dr1[1].ToString().Contains(text.ID))
                            {
                                wall.Controls.Add(new LiteralControl("<li class='media'><div class='media-left'><a href='#'>"));

                                int t = A.chkpicstat(dr1[2].ToString());
                                if (t == 0)
                                {
                                    if (A.chkgender(dr1[2].ToString()))
                                    {
                                        wall.Controls.Add(new LiteralControl("<img src='temp/b.jpg' class='media-object' width='60' height='60'>"));
                                    }
                                    else
                                    {
                                        wall.Controls.Add(new LiteralControl("<img src='temp/g.jpg' class='media-object' width='60' height='60'>"));
                                    }
                                }
                                else
                                {
                                    wall.Controls.Add(new LiteralControl("<img src='Account/" + dr1[2].ToString() + "/p.jpg' class='media-object' width='60' height='60'>"));
                                }
                                wall.Controls.Add(new LiteralControl("</a></div><div class='media-body'><a href='#' class='comment-author pull-left'>" + r.name(dr1[2].ToString()) + "</a><span>" + dr1[3].ToString() + "</span><div class='comment-date'>" + st[0] + "</div></div></li>"));
                            }
                        }
                        wall.Controls.Add(new LiteralControl(" <li class='comment-form'><div class='input-group'><span class='input-group-btn'><a href='#' class='btn btn-default'><i class='fa fa-comments'></i></a></span>"));

                        wall.Controls.Add(text);
                        wall.Controls.Add(new LiteralControl("</div></li></ul></div></div>"));

                        cmd1.Dispose();
                        cn1.Close();
                    }
                }
            }
        }