protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { long news_ID = 0; if (!string.IsNullOrEmpty(Request.QueryString["nid"])) { news_ID = Convert.ToInt64(Request.QueryString["nid"]); } if (news_ID > 0) { NewsRow objNewsRow = NewsEditHelper.GetNewsInfo_News(news_ID, false); NewsRow objNewsRow_Ex = NewsEditHelper.GetNewsInfo_NewsExtension(news_ID, false); string title = LCSFinder.GetEditor(objNewsRow.News_Title, objNewsRow_Ex.News_Title)[0]; string Sapo = LCSFinder.GetEditor(objNewsRow.News_InitialContent, objNewsRow_Ex.News_InitialContent)[0]; string Content = LCSFinder.GetEditor(objNewsRow.News_Content, objNewsRow_Ex.News_Content)[0]; ltrTitle.Text = title; ltrInit.Text = Sapo; ltrContent.Text = Content; } } }
private void BindNewsEdit(long _news_id) { NewsRow objNewsRow = NewsEditHelper.GetNewsInfo_NewsExtension(_news_id, false); MainSecurity objSercu = new MainSecurity(); Permission objPer = objSercu.GetPermission(Page.User.Identity.Name); if (objPer.isXuat_Ban_Bai) { //Kiểm tra nếu có quyền xuất bản thì sẽ hiện dầy đủ thông tin btnPublish.Visible = true; // pnControl.Visible = true; } else { btnPublish.Visible = false; } if (objNewsRow != null) { if (!objPer.isXuat_Ban_Bai && Page.User.Identity.Name.Trim().ToLower() != objNewsRow.News_Author.Trim().ToLower()) { throw new SecurityException("Bạn không có quyền truy cập vào trang này"); return; } ltrXuatBan.Text = "Bài viết do \"" + objNewsRow.News_Approver.ToUpper() + "\" xuất bản lúc " + objNewsRow.News_PublishDate.ToString("dd/MM/yyyy hh:mm"); lstCat.SelectedValue = objNewsRow.Cat_ID.ToString(); txtTitle.Text = objNewsRow.News_Title != null ? objNewsRow.News_Title : ""; txtSubTitle.Text = objNewsRow.News_Subtitle != null ? objNewsRow.News_Subtitle : ""; txtSource.Text = objNewsRow.News_Source != null ? objNewsRow.News_Source : ""; txtInit.Text = objNewsRow.News_InitialContent != null?NewsEditHelper.ReplaceImageSrcToEmoticon(objNewsRow.News_InitialContent) : ""; txtInit.Text = txtInit.Text.Replace("<br/>", System.Environment.NewLine); if (Request.QueryString["redirect"] == null) { NewsContent.Text = objNewsRow.News_Content != null ? objNewsRow.News_Content : ""; Session["NewsContent"] = NewsContent.Text; } else { NewsContent.Text = Session["NewsContent"].ToString(); } chkIsFocus.Checked = objNewsRow.IsNews_isFocusNull != true ? objNewsRow.News_isFocus : false; cboIsHot.SelectedValue = objNewsRow.IsNews_ModeNull != true?objNewsRow.News_Mode.ToString() : "0"; hdRelatNews.Value = objNewsRow.News_Relation != null ? objNewsRow.News_Relation : ""; chkShowComment.Checked = objNewsRow.IsisCommentNull != true ? objNewsRow.isComment : false; //Cho phép hiện ảnh hay ko? chkShowRate.Checked = objNewsRow.IsisUserRateNull != true ? objNewsRow.isUserRate : false; txtSelectedFile.Text = objNewsRow.News_Image != null ? objNewsRow.News_Image : ""; txtImageTitle.Text = objNewsRow.News_ImageNote != null ? objNewsRow.News_ImageNote : ""; txtIcon.Text = objNewsRow.Icon != null ? objNewsRow.Icon : ""; txtMaCP.Text = objNewsRow.Extension1 != null ? objNewsRow.Extension1 : ""; txtExtension2.Text = objNewsRow.Extension2 != null ? objNewsRow.Extension2 : ""; txtSourceLink.Text = objNewsRow.Extension3 != null ? objNewsRow.Extension3 : ""; ddlAuthor.SelectedValue = objNewsRow.IsExtension4Null != true?objNewsRow.Extension4.ToString() : "0"; if (objNewsRow.Template != 0) { ddlProvinces.SelectedValue = objNewsRow.Template.ToString(); } if (objNewsRow.News_OtherCat != null) { string[] strOthers = objNewsRow.News_OtherCat.Split(",".ToCharArray()); for (int i = 0; i < lstOtherCat.Items.Count; i++) { foreach (string strItem in strOthers) { if (strItem == lstOtherCat.Items[i].Value) { lstOtherCat.Items[i].Selected = true; break; } } } } if (!objNewsRow.IsNews_PublishDateNull) { SetValueForCombo(cboMonth, objNewsRow.News_PublishDate.Month.ToString()); SetValueForCombo(cboDay, objNewsRow.News_PublishDate.Day.ToString()); SetValueForCombo(cboYear, objNewsRow.News_PublishDate.Year.ToString()); SetValueForCombo(cboSercond, objNewsRow.News_PublishDate.Second.ToString()); SetValueForCombo(cboMinute, objNewsRow.News_PublishDate.Minute.ToString()); SetValueForCombo(cboHour, objNewsRow.News_PublishDate.Hour.ToString()); } else { SetValueForCombo(cboMonth, "0"); SetValueForCombo(cboDay, "0"); SetValueForCombo(cboYear, "2000"); SetValueForCombo(cboSercond, "-1"); SetValueForCombo(cboMinute, "-1"); SetValueForCombo(cboHour, "-1"); } if (!IsPostBack) { hdMedia.Value = DFISYS.BO.Editoral.NewsMedia.NewsMediaHelper.Get_ObjectId_By_NewsId(_news_id); DataTable dtThread = ThreadHelper.SelectThreadByNewsID(_news_id); if (dtThread != null && dtThread.Rows.Count > 0) { hidLuongSuKien.Value = dtThread.Rows[0]["Thread_ID"].ToString(); } } //Load data to Combobox Tin lien quan; string str; if (hdRelatNews.Value.TrimEnd(',') != "") { str = NewsEditHelper.Get_Media_By_ListsId("News_ID", "News_Title", "News", hdRelatNews.Value); BindToDropdown(cboNews, str); } string strThread; if (hidLuongSuKien.Value.TrimEnd(',') != "") { strThread = NewsEditHelper.Get_Media_By_ListsId("Thread_ID", "Title", "NewsThread", hidLuongSuKien.Value); BindToDropdown(lstThread, strThread); string[] arrThread = hidLuongSuKien.Value.Split(','); if (arrThread != null && arrThread.Length > 0) { for (int i = 0; i < cblTags.Items.Count; i++) { foreach (string strItem in arrThread) { if (strItem == cblTags.Items[i].Value) { cblTags.Items[i].Selected = true; break; } } } } } if (hdMedia.Value.TrimEnd(',').Length > 0) { str = NewsEditHelper.Get_Media_By_ListsId("Object_ID", "Object_Url", "MediaObject", hdMedia.Value); //BindToDropdown(cboMedia, str); } LoadAttachmentsType(_news_id); } }