Ejemplo n.º 1
0
        public List <GetEssay> GetAllEssay()
        {
            string          sql       = "select * from UserEssay";
            List <GetEssay> essayList = new List <GetEssay>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        GetEssay ess = new GetEssay();
                        ess.Id     = reader.GetInt32(0);
                        ess.Title  = reader.GetString(1);
                        ess.Author = reader.GetString(2);
                        essayList.Add(ess);
                    }
                }
            }
            return(essayList);
        }
Ejemplo n.º 2
0
        public GetEssay GetSingleEssayById(int id)
        {
            string        sql    = "select id,title,author,textpath from UserEssay where id = @id";
            SqlParameter  para   = new SqlParameter("@id", id);
            SqlDataReader reader = SqlHelper.ExecuteReader(sql, para);
            GetEssay      essay  = null;

            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    essay          = new GetEssay();
                    essay.Id       = Convert.ToInt32(reader["id"]);
                    essay.Title    = reader["title"].ToString();
                    essay.Author   = reader["author"].ToString();
                    essay.Textpath = reader["textpath"].ToString();
                }
            }
            reader.Close();
            return(essay);
        }
Ejemplo n.º 3
0
        public List <GetEssay> GetEssayByAuthor(string author)
        {
            string          sql       = "select id,title,author,textpath from UserEssay where author = @author";
            SqlParameter    para      = new SqlParameter("@author", author);
            SqlDataReader   reader    = SqlHelper.ExecuteReader(sql, para);
            List <GetEssay> essayList = new List <GetEssay>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    GetEssay essay = new GetEssay();
                    essay.Id       = Convert.ToInt32(reader["id"]);
                    essay.Title    = reader["title"].ToString();
                    essay.Author   = reader["author"].ToString();
                    essay.Textpath = reader["textpath"].ToString();
                    essayList.Add(essay);
                }
            }
            reader.Close();
            return(essayList);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null)
            {
                //未登录则跳转到登录页面
                Response.Redirect("/Login.aspx");
            }
            //if (Request.QueryString["UserName"] == null)
            //{
            //    Response.Redirect("/Login.aspx");
            // }
            string        username = Session["UserName"].ToString();
            UserLogin     user     = bll.GetUserByUserName(username);
            StringBuilder sb       = new StringBuilder();

            sb.Append("<div>");
            sb.Append(string.Format("<p><img src='{0}' alt='' /></p><p>{1}</p><p>{2}</p>", user.Head, user.UserName, user.Sex));
            sb.Append("</div>");
            person.InnerHtml = sb.ToString();

            int           id          = Convert.ToInt32(Request.QueryString["SEssid"]);
            GetEssay      singleEssay = bll3.GetSingleEssayById(id);
            StringBuilder sbSingleEss = new StringBuilder();

            if (singleEssay != null)
            {
                sbSingleEss.Append(string.Format("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号:{0}</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'>标题:{1}</span><span style ='display: block;float: left; width:203.6px;color: #2ed4b4;'>作者:{2}</span></span> ", singleEssay.Id, singleEssay.Title, singleEssay.Author));

                sbSingleEss.Append(string.Format("<div>{0}</div>", GetInterIDList(singleEssay.Textpath)));
                ess.InnerHtml = sbSingleEss.ToString();
            }
            else
            {
                //sbSingleEss.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> ");
                ess.InnerHtml = "";
            }
        }