예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var db = new BNB17dbDB())
            {
                var q =
                    (from c in db.News
                     orderby c.PublishDate descending
                     select new NewsClass
                {
                    Name = c.Title,
                    Msg = c.Message,
                    Date = Convert.ToDateTime(c.PublishDate).ToShortDateString(),
                }).ToList();

                //處理換行
                for (int i = 0; i < q.Count(); i++)
                {
                    var StringLineList = q[i].Msg.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    for (int k = 0; k < StringLineList.Length; k++)
                    {
                        StringLineList[k] = "<p>" + StringLineList[k] + "</p>";
                    }
                    q[i].Msg = string.Join("", StringLineList);
                }

                lv_news.DataSource = q;
                lv_news.DataBind();
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region □ 關於我們 □
            using (var db = new BNB17dbDB())
            {
                var q = db.Abouts.FirstOrDefault();

                //處理換行
                var StringLineList = q.About_Column.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                for (int k = 0; k < StringLineList.Length; k++)
                {
                    StringLineList[k] = "<p>" + StringLineList[k] + "</p>";
                }
                q.About_Column = string.Join("", StringLineList);
                ltr_about.Text = q.About_Column;
            }
            #endregion

            #region □ 最新消息 □
            using (var db = new BNB17dbDB())
            {
                var q =
                    (from c in db.News
                     orderby c.PublishDate descending
                     select new NewsClass
                {
                    Name = c.Title,
                    Msg = c.Message,
                    MsgDetail = c.Message,
                    Date = Convert.ToDateTime(c.PublishDate).ToShortDateString(),
                }).Take(3).ToList();

                //移除換行、限制字元,讓排版好看
                for (int i = 0; i < q.Count(); i++)
                {
                    q[i].Msg = q[i].Msg.Replace(Environment.NewLine, " ");
                    if (q[i].Msg.Length > 26)
                    {
                        q[i].Msg = q[i].Msg.Substring(0, 25) + "...";
                    }
                }

                //細項Modal處理換行
                for (int i = 0; i < q.Count(); i++)
                {
                    var StringLineList = q[i].MsgDetail.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    for (int k = 0; k < StringLineList.Length; k++)
                    {
                        StringLineList[k] = "<p>" + StringLineList[k] + "</p>";
                    }
                    q[i].MsgDetail = string.Join("", StringLineList);
                }

                lv_news.DataSource = q;
                lv_news.DataBind();
            }
            #endregion
        }
예제 #3
0
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            using (var db = new BNB17dbDB())
            {
                var save = new News();

                var statement = db.News
                                .Value(p => p.Title, "測試").Value(s => s.Message, textboxx.Text);
                //statement.Value(p => p.Added, () => Sql.CurrentTimestamp);
                statement.Insert();
            }
        }
예제 #4
0
        protected void bind()
        {
            using (var db = new BNB17dbDB())
            {
                var q =
                    from c in db.News
                    where c.No > 7
                    orderby c.PublishDate descending
                    select new
                {
                    Name = c.Title,
                    msg  = c.Message,
                    Date = c.PublishDate
                };

                foreach (var i in q)
                {
                    var aa = i.msg.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                }

                lv.DataSource = q;
                lv.DataBind();
            }
        }