Пример #1
0
 private void BindNewsRelative()
 {
     var newsBo = new NewsBO();
     List<Entities.News> news = newsBo.GetNewsByType(0);
     var htmlNews = new StringBuilder();
     foreach (Entities.News newse in news.OrderByDescending(t => t.CreatedOn))
     {
         htmlNews.Append("<li><span>");
         htmlNews.AppendFormat("<a href='/tin-tuc/2/{0}'>{1}</a>", newse.Id, newse.Title);
         htmlNews.Append("</li></span>");
     }
     ltNewRelative.Text = htmlNews.ToString();
 }
Пример #2
0
 protected void rgNews_ItemCommand(object sender, GridCommandEventArgs e)
 {
     switch (e.CommandName)
     {
         case "delete":
             int id = int.Parse(e.CommandArgument.ToString());
             var newsBo = new NewsBO();
             int res = newsBo.DeleteNews(id);
             string msg = string.Format("Xóa bài viết {0}", res > 0 ? "thành công" : "bị lỗi");
             ltScript.Text = string.Format("<script>alert('{0}');</script>", msg);
             break;
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     var news = new NewsBE();
     BindControlToEntity(news);
     if (string.IsNullOrEmpty(news.Contents))
         return;
     var newBo = new NewsBO();
     news.Id = Id;
     int res = Id == 0 ? newBo.AddNews(news) : newBo.UpdateNews(news);
     string confirmMsg =
         string.Format(
             "<script>confirmDialog('{0} bản tin thành công, bạn trở về trang quản lý bản tin?');</script>",
             Id == 0 ? "Tạo mới" : "Cập nhật");
     string alertMsg = string.Format("<script>alert('{0} bản tin không thành công');</script>",
                                     Id == 0 ? "Tạo mới" : "Cập nhật");
     ltScript.Text = string.Format("{0}", res > 0 ? confirmMsg : alertMsg);
 }
 private void BindContent()
 {
     if (Id == 0)
     {
         const string defaultContent = @"<p style='font-size: 13pt;'>Chuyên trang thiết kế nhà ở</p>
                             <p>
                                 Kiến trúc và nội thất nhà ở có lẽ là lĩnh vực được nhiều sự quan tâm nhất. Bạn cũng như
                                 chúng tôi, mỗi người đều có một mái nhà và dù chúng là những ngôi biệt thự sang trọng hay những
                                 căn hộ bình dị thì chúng vẫn thật gần gũi với tất cả chúng ta.
                             </p>
                             <p>
                                 Cùng với sự phát triển về kinh tế xã hội, khi nhu cầu của mỗi người không chỉ dừng ở 'ăn no, mặc ấm' mà đang chuyển thành 'ăn ngon, mặc đẹp' thì một ngôi nhà không chỉ cần bền chắc mà còn phải đẹp và thật sự tiện nghi. Để làm được điều đó không thể thiếu vai trò của các Kiến trúc sư. Một bản thiết kế tốt sẽ đem lại cho bạn cái Đẹp sự Tiện nghi, giúp bạn Tiết kiệm chi phí đầu tư, hạn chế phát sinh chi phí khi thi công... </p>";
         ltContents.Text = defaultContent;
         return;
     }
     var bo = new NewsBO();
     Entities.News res = bo.GetNewsById(Id);
     ltContents.Text = res.Contents ?? string.Empty;
 }
Пример #5
0
 private void BindEntityToControl()
 {
     var newsBo = new NewsBO();
     if (Id == 0)
     {
         pnlTopNews.Visible = true;
         pnlDetails.Visible = false;
         List<Entities.News> news = newsBo.GetTopNews(5);
         rptTopNews.DataSource = news;
         rptTopNews.DataBind();
     }
     else
     {
         pnlTopNews.Visible = false;
         pnlDetails.Visible = true;
         Entities.News news = newsBo.GetNewsById(Id);
         lbTitle.Text = news.Title;
         ltSubContent.Text = news.SubContent;
         ltContents.Text = news.Contents;
     }
 }
 private void BindEntityToControl()
 {
     var newsBo = new NewsBO();
     NewsBE news = newsBo.GetNewsById(Id);
     hdfNewKind.Value = news.Type.ToString();
     tbTitle.Text = news.Title;
     tbSubcontent.Text = news.SubContent;
     radContent.Content = news.Contents;
     ltScript.Text = string.Format("<script>newsKindClick('{0}')</script>", news.Type);
     if (string.IsNullOrEmpty(news.ImageUrl)) return;
     Filename = news.ImageUrl;
     ImageUrl = string.Format("{0}{1}", Path, news.ImageUrl);
 }
 private void BindContent()
 {
     var bo = new NewsBO();
     Entities.News res = bo.GetNewsById(Id);
     ltContents.Text = res.Contents ?? string.Empty;
 }
 private List<Entities.News> GetNews()
 {
     var newsBo = new NewsBO();
     List<Entities.News> res = newsBo.GetNewsByType(1);
     return res;
 }