private void init() { if (!AppUtils.CheckPath()) { Message.Alert(Page, "Không tạo được thư mục!"); } News _News = new News() { NewsID = AppUtils.Request("id") }; _News = _News.Get(); if (_News == null || _News.Status < 2) { Response.Redirect(Constant.ADMIN_PATH + Resources.Url.SignOut); } txtTitle.Text = _News.Title; txtSubTitle.Text = _News.SubTitle; txtLead.Text = _News.Lead; txtSubLead.Text = _News.SubLead; ftbContent.Text = _News.Content; chkIsPhoto.Checked = _News.IsPhoto; chkIsVideo.Checked = _News.IsVideo; chkIsAudio.Checked = _News.IsAudio; txtPublishTime.Text = _News.PublishedTime.ToString(); imgImageUrl.ImageUrl = Constant.MEDIA_PATH + _News.ImageUrl; txtTags.Text = _News.Tags; lblMediaPath.Text = _News.CreatedTime.ToString("yyyy/MM/dd/") + _News.NewsID.ToString() + "/"; lblMediaPathFull.Text = Constant.MEDIA_PATH + lblMediaPath.Text; NewsPublish _NewsPublish = new NewsPublish(); List <NewsPublish> list = _NewsPublish.GetList(_News.NewsID); var _NewsAdmin = new NewsAdmin(); List <NewsAdmin> listNews; for (int i = 0; i < list.Count; i++) { _NewsPublish = (NewsPublish)list[i]; string title = _News.Title; if (title.Length > 50) { title = title.Substring(0, 50); } switch (i) { case 0: drpCate1.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder1.Items.Clear(); drpOrder1.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate1.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder1.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder1.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder1.SelectedIndex == 0) { drpOrder1.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder1.SelectedValue = _NewsPublish.Order.ToString(); } break; case 1: drpCate2.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder2.Items.Clear(); drpOrder2.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate2.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder2.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder2.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder2.SelectedIndex == 0) { drpOrder2.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder2.SelectedValue = _NewsPublish.Order.ToString(); } break; case 2: drpCate3.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder3.Items.Clear(); drpOrder3.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate3.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder3.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder3.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder3.SelectedIndex == 0) { drpOrder3.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder3.SelectedValue = _NewsPublish.Order.ToString(); } break; case 3: drpCate4.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder4.Items.Clear(); drpOrder4.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate4.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder4.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder4.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder4.SelectedIndex == 0) { drpOrder4.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder4.SelectedValue = _NewsPublish.Order.ToString(); } break; case 4: drpCate5.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder5.Items.Clear(); drpOrder5.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate5.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder5.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder5.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder5.SelectedIndex == 0) { drpOrder5.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder5.SelectedValue = _NewsPublish.Order.ToString(); } break; default: break; } } // Tin liên quan NewsRelated _NewsRelated = new NewsRelated(); rptRelatedList.DataSource = _NewsRelated.GetList(_News.NewsID); rptRelatedList.DataBind(); ftbContent.ImageGalleryPath = lblMediaPathFull.Text; if (_News.Status == 3) { btPublish.Visible = false; } // Lấy danh sách ảnh BindMedia(); }
private void init() { News _News = new News(); _News.NewsID = AppUtils.Request("id"); if (_News.NewsID > 0) { _News = _News.Get(); } // Tạo một tin bài tạm if (_News.NewsID == 0) { _News.Title = Resources.Config.TitleContent; _News.SubTitle = ""; _News.ImageUrl = ""; _News.Lead = Resources.Config.LeadContent; _News.SubLead = Resources.Config.SubLeadContent; _News.Content = ""; _News.IsTop = false; _News.IsPhoto = false; _News.IsVideo = false; _News.IsAudio = false; _News.PublishedTime = DateTime.Now.AddMinutes(20); _News.CateID = Constant.CateID; _News.Tags = ""; _News.UserID = AppUtils.UserID(); _News.Status = 1; _News.Add(); Response.Redirect(Resources.Url.NewsAdd + "?id=" + _News.NewsID.ToString()); } lblMediaPath.Text = _News.CreatedTime.ToString("yyyy/MM/dd/") + _News.NewsID.ToString() + "/"; lblMediaPathFull.Text = Constant.MEDIA_PATH + lblMediaPath.Text; // Kiểm tra trạng thái, tác giả if (_News.Status > 1 || AppUtils.UserID() != _News.UserID) { Response.Redirect(Constant.ADMIN_PATH + Resources.Url.SignOut); } lblNewsID.Text = _News.NewsID.ToString(); txtTitle.Text = _News.Title; txtSubTitle.Text = _News.SubTitle; txtLead.Text = _News.Lead; txtSubLead.Text = _News.SubLead; ftbContent.Text = _News.Content; chkIsPhoto.Checked = _News.IsPhoto; chkIsVideo.Checked = _News.IsVideo; chkIsAudio.Checked = _News.IsAudio; txtPublishTime.Text = _News.PublishedTime.ToString(); if (_News.ImageUrl.Length > 0) { imgImageUrl.ImageUrl = Constant.MEDIA_PATH + _News.ImageUrl; } txtTags.Text = _News.Tags; NewsPublish _NewsPublish = new NewsPublish(); List <NewsPublish> list = _NewsPublish.GetList(_News.NewsID); var _NewsAdmin = new NewsAdmin(); List <NewsAdmin> listNews; for (int i = 0; i < list.Count; i++) { _NewsPublish = (NewsPublish)list[i]; string title = _News.Title; if (title.Length > 50) { title = title.Substring(0, 50); } switch (i) { case 0: drpCate1.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder1.Items.Clear(); drpOrder1.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate1.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder1.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder1.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder1.SelectedIndex == 0) { drpOrder1.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder1.SelectedValue = _NewsPublish.Order.ToString(); } break; case 1: drpCate2.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder2.Items.Clear(); drpOrder2.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate2.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder2.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder2.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder2.SelectedIndex == 0) { drpOrder2.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder2.SelectedValue = _NewsPublish.Order.ToString(); } break; case 2: drpCate3.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder3.Items.Clear(); drpOrder3.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate3.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder3.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder3.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder3.SelectedIndex == 0) { drpOrder3.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder3.SelectedValue = _NewsPublish.Order.ToString(); } break; case 3: drpCate4.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder4.Items.Clear(); drpOrder4.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate4.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder4.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder4.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder4.SelectedIndex == 0) { drpOrder4.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder4.SelectedValue = _NewsPublish.Order.ToString(); } break; case 4: drpCate5.SelectedValue = _NewsPublish.CateID.ToString(); drpOrder5.Items.Clear(); drpOrder5.Items.Insert(0, new ListItem("Thứ tự:", "0")); listNews = _NewsAdmin.GetList(Convert.ToInt32(drpCate5.SelectedValue), 100); for (int j = 0; j < listNews.Count; j++) { _NewsAdmin = listNews[j]; if (_NewsAdmin.Title.Length > 50) { _NewsAdmin.Title = _NewsAdmin.Title.Substring(0, 50) + "..."; } drpOrder5.Items.Add(new ListItem("(" + _NewsAdmin.Order.ToString() + ") " + _NewsAdmin.Title, _NewsAdmin.Order.ToString())); } drpOrder5.SelectedValue = _NewsPublish.Order.ToString(); if (drpOrder5.SelectedIndex == 0) { drpOrder5.Items.Add(new ListItem("(" + _NewsPublish.Order.ToString() + ") " + title, _NewsPublish.Order.ToString())); drpOrder5.SelectedValue = _NewsPublish.Order.ToString(); } break; default: break; } } // Tin liên quan NewsRelated _NewsRelated = new NewsRelated(); rptRelatedList.DataSource = _NewsRelated.GetList(_News.NewsID); rptRelatedList.DataBind(); // Ảnh trong bài BindMedia(); ftbContent.ImageGalleryPath = lblMediaPathFull.Text; }