protected void BindData(Int64 nsid) { XYECOM.Business.News ns = new XYECOM.Business.News(); string strWhere = " where NS_ID="+nsid.ToString(); string newsname = ns.GetNewsName(nsid); if(string.IsNullOrEmpty(newsname)) this.caption.InnerHtml ="对《" + newsname + "》新闻的评论"; this.Page1.RecTotal = Function.GetRows("n_NewsDiscuss", "ND_ID", strWhere); DataTable dt = Function.GetPages(this.Page1.PageSize, this.Page1.CurPage, strWhere, " Order by ND_ID DESC", "n_NewsDiscuss", "ND_ID,U_ID,U_Name,NS_ID,ND_Content,ND_AddTime,ND_IsShow", "ND_ID"); if (dt.Rows.Count > 0) { this.gvlist.DataSource = dt; this.gvlist.DataBind(); } else { this.gvlist.DataBind(); this.lblMessage.Text = "没有任何评论!"; } }
private void BindData(Int64 nd, Int64 ns) { XYECOM.Business.News ne = new XYECOM.Business.News(); nsname = ne.GetNewsName(ns); this.caption.InnerHtml = nsname; ndinfo = ndis.GetItem(nd); if (ndinfo.U_ID.ToString() == "0") this.lbname.Text = ndinfo.U_Name+"(游客)"; else this.lbname.Text = ndinfo.U_Name+"(会员)"; this.lbtime.Text = ndinfo.ND_AddTime.ToString(); this.tbcontent.Text = ndinfo.ND_Content.Replace("</n>", "</br>"); if (ndinfo.ND_IsShow == true) { this.rbisshowtrue.Checked = true; } else { this.rbisshowfalse.Checked = true; } }
/// <summary> /// 获取新闻标题 /// </summary> /// <param name="nsid">新闻的编号</param> /// <returns>该新闻的标题</returns> private string GetNewsTitle(Int64 nsid) { XYECOM.Business.News ne = new XYECOM.Business.News(); if (nsid <= 0) Alert("该新闻有误,无法设置,请从新选择", backURL); return ne.GetNewsName(nsid); }
/// <summary> /// 定义确定添加事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btadadd_Click(object sender, EventArgs e) { XYECOM.Business.NewsAuthor newsAuthorBLL = new XYECOM.Business.NewsAuthor(); XYECOM.Business.News newsBLL = new XYECOM.Business.News(); XYECOM.Business.NewsTitles newsTitlesBLL = new XYECOM.Business.NewsTitles(); XYECOM.Model.NewsAuthorInfo newsAuthorInfo = new XYECOM.Model.NewsAuthorInfo(); if (this.cbnewsauthor.Checked == true && this.tbnewsauthor.Text.ToString() != "") { int authorId = 0; newsAuthorInfo.NA_Name = this.tbnewsauthor.Text.ToString().Trim(); int rowauthor = newsAuthorBLL.Insert(newsAuthorInfo, out authorId); } XYECOM.Business.NewsOrigin newsOriginBLL = new XYECOM.Business.NewsOrigin(); XYECOM.Model.NewsOriginInfo newsOriginInfo = new XYECOM.Model.NewsOriginInfo(); if (this.cbnewsorigin.Checked == true && this.tbnewsorigin.Text.ToString() != "") { int originId = 0; newsOriginInfo.NO_Name = this.tbnewsorigin.Text.ToString().Trim(); int rowOrigin = newsOriginBLL.Insert(newsOriginInfo, out originId); } newsInfo.Title = this.tbnewsname.Text.Trim(); newsInfo.SubTitle = this.tbtwoname.Text.Trim(); string titleStyle = ""; if (!this.txtTitleColor.Value.Trim().Equals("")) titleStyle += "color:" + this.txtTitleColor.Value.Trim() + ";"; if (this.chkFontBold.Checked) titleStyle += "font-weight:bold;"; if (this.chkFontItalic.Checked) titleStyle += "font-style:italic;"; if (this.chkFontUnderline.Checked) titleStyle += "text-decoration:underline"; newsInfo.TitleStyle = titleStyle; newsInfo.TopicType = hidTopicID.Value.Trim(); newsInfo.Keyword = this.reswords.Text.ToString().Replace(",", ",").Replace(" ", ""); newsInfo.Leadin = this.tbnewsness.Text.Trim(); if (this.tbaddtime.Value.ToString() != "" && this.tbaddtime.Value.StartsWith("NaN") != true) newsInfo.AddTime = this.tbaddtime.Value; else newsInfo.AddTime = DateTime.Now.ToString(); newsInfo.ClickNumber = XYECOM.Core.MyConvert.GetInt32(this.tbcount.Text.Trim()); if (this.cbIsFlag.Checked) newsInfo.IsCommend = true; else newsInfo.IsCommend = false; if (this.cbIsDiscuss.Checked) newsInfo.IsAllowComment = true; else newsInfo.IsAllowComment = false; if (this.cbIsTop.Checked) newsInfo.IsTop = true; else newsInfo.IsTop = false; if (this.cbIsHot.Checked) newsInfo.IsHot = true; else newsInfo.IsHot = false; if (this.cbIsSlide.Checked) newsInfo.IsSlide = true; else newsInfo.IsSlide = false; if (this.cbAuditing.Checked) { newsInfo.State = XYECOM.Model.AuditingState.Passed; } else { newsInfo.State = XYECOM.Model.AuditingState.NoPass; } newsInfo.AreaIds = XYECOM.Core.Utils.AppendComma(city.Value); newsInfo.TradeIds = XYECOM.Core.Utils.AppendComma(tradeid.Value); newsInfo.ProtypeIds = XYECOM.Core.Utils.AppendComma(offerid.Value); if (this.cbIsScheme.Checked) { newsInfo.IsScheme = 1; } else { newsInfo.IsScheme = 0; } if (this.HidItemStr.Value != "") { string[] HSA = this.HidItemStr.Value.Split(','); string StrIds = ""; for (int i = 0; i < HSA.Length; i++) { StrIds += HSA[i].Split(':')[0] + ","; } newsInfo.ProIds = StrIds.Substring(0, StrIds.Length - 1); } else { newsInfo.ProIds = ""; } //如果是普通新闻,获取各参数 if (rbcommonnews.Checked == true) { newsInfo.Type = XYECOM.Model.NewsType.TextNews; newsInfo.HeadlineNewsUrl = ""; newsInfo.PicUrl = ""; newsInfo.Author = ""; if (!this.tbnewsauthor.Text.Trim().Equals("")) newsInfo.Author = this.tbnewsauthor.Text.Trim(); else if (this.ddlnewsauthor.SelectedValue != "") newsInfo.Author = this.ddlnewsauthor.SelectedValue; newsInfo.Origin = ""; if (!this.tbnewsorigin.Text.Trim().Equals("")) newsInfo.Origin = this.tbnewsorigin.Text.Trim(); else if (this.ddlnewsorigin.SelectedValue != "") newsInfo.Origin = this.tbnewsorigin.Text.Trim(); newsInfo.Content = this.newsBody.Value; } //如果是图片新闻,获取各参数 else if (rbpicnews.Checked == true) { this.cbIsSlide.Visible = true; newsInfo.Type = XYECOM.Model.NewsType.ImageNews; newsInfo.HeadlineNewsUrl = ""; if (this.rbpicurl.Checked == true && this.tbpinurl.Value != "") newsInfo.PicUrl = this.tbpinurl.Value.Trim(); else if (this.rbpicupload.Checked == true) newsInfo.PicUrl = "Image"; if (this.tbnewsauthor.Text == "") { this.hipictype.Value = "-1"; newsInfo.Author = this.ddlnewsauthor.SelectedValue; } else newsInfo.Author = this.tbnewsauthor.Text; if (this.tbnewsorigin.Text == "") this.tbnewsorigin.Text = this.ddlnewsorigin.SelectedValue; else newsInfo.Origin = this.tbnewsorigin.Text; newsInfo.Content = this.newsBody.Value; } //如果是标题新闻,获取各参数 else if (rbcaptionnews.Checked == true) { this.cbIsSlide.Visible = true; newsInfo.Type = XYECOM.Model.NewsType.HeadlineNews; newsInfo.HeadlineNewsUrl = this.tblinkaddress.Text; newsInfo.Author = ""; newsInfo.Origin = ""; newsInfo.PicUrl = ""; if (this.rbpicurl.Checked == true && this.tbpinurl.Value != "") { this.hipictype.Value = "-1"; newsInfo.PicUrl = this.tbpinurl.Value.Trim(); } else if (this.rbpicupload.Checked == true) { newsInfo.PicUrl = "Image"; } newsInfo.Content = ""; } //记录发布人ID newsInfo.UM_ID = AdminId; Int64 ID = 0; int rowAff = 0; if (this.AddOrUpdate.Value.ToString() == "1") { newsInfo.HTMLPage = ""; if (this.hdgetid.Value != null) //新闻栏目编号集 { newsInfo.TypeIds = XYECOM.Core.Utils.AppendComma(this.hdgetid.Value.ToString().Trim()); int total = XYECOM.Core.MyConvert.GetInt32(this.OptionTotal.Value.ToString()); string option = ""; string filename = ""; newsInfo.FileUrl = ""; for (int i = 1; i <= total; i++) { option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim(); filename = XYECOM.Core.XYRequest.GetFormString("filename" + i).Trim(); if (string.IsNullOrEmpty(option)) continue; if (filename == "") filename = "附件" + i; if (newsInfo.FileUrl.Equals("")) newsInfo.FileUrl = filename + "$" + option.ToString(); else newsInfo.FileUrl = newsInfo.FileUrl + "|" + filename + "$" + option.ToString(); } rowAff = newsBLL.Insert(newsInfo, out ID); if (this.cbcreate.Checked) { CreateHTML(ID.ToString(), "news", "news"); } if (rowAff == -2) { Alert("添加失败,可重新操作.", "NewsList.aspx"); } else if (rowAff == -1) { Alert("添加失败,所选栏目下已有雷同新闻.", "NewsList.aspx"); } else { UploadFile2.InfoID = ID; UploadFile2.Update(); if (rbcommonnews.Checked == false) { if (this.rbpicurl.Checked == true) { AllowPicType(); } else if (this.rbpicupload.Checked == true) { AllowPicType(); UploadFile1.InfoID = ID; UploadFile1.Update(); } } Response.Redirect("NewsList.aspx"); } } } else //修改新闻(此时,栏目是单选,即上传图片也为一张) { newsInfo.TypeIds = XYECOM.Core.Utils.AppendComma(this.hdgetid.Value.Trim()); //newsInfo.NewsId = Convert.ToInt64(Request.QueryString["id"].ToString()); if (rbcaptionnews.Checked == true || rbpicnews.Checked == true) { if (this.rbpicurl.Checked == true) { AllowPicType(); } else if (this.rbpicupload.Checked == true) { AllowPicType(); UploadFile1.InfoID = newsInfo.NewsId; UploadFile1.Update(); } } UploadFile2.InfoID = newsInfo.NewsId; UploadFile2.Update(); int total = XYECOM.Core.MyConvert.GetInt32(this.OptionTotal.Value.ToString()); string option = ""; string filename = ""; newsInfo.FileUrl = ""; for (int i = 1; i <= total; i++) { option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim(); filename = XYECOM.Core.XYRequest.GetFormString("filename" + i).Trim(); if (string.IsNullOrEmpty(option)) continue; if (filename == "") filename = "附件" + i; if (newsInfo.FileUrl.Equals("")) newsInfo.FileUrl = filename + "$" + option.ToString(); else newsInfo.FileUrl = newsInfo.FileUrl + "|" + filename + "$" + option.ToString(); } rowAff = newsBLL.Update(newsInfo); if (this.cbcreate.Checked) { CreateHTML(newsInfo.NewsId.ToString(), "news", "news"); } if (rowAff >= 0) { Response.Redirect(XYECOM.Core.XYRequest.GetQueryString("backURL")); } else { Alert("修改新闻失败,可重新操作.", XYECOM.Core.XYRequest.GetQueryString("backURL")); } } newsInfo = null; }
protected void lnkDel_Click(object sender, EventArgs e) { string id = ""; XYECOM.Business.News en = new XYECOM.Business.News(); foreach (GridViewRow row in this.gvlist.Rows) { if (((CheckBox)(row.FindControl("chkExport"))).Checked == true) id += "," + this.gvlist.DataKeys[row.DataItemIndex].Value.ToString(); } if (id.IndexOf(",") == 0) id = id.Substring(1); int rowAffected = en.Delete(id); if (rowAffected >= 0) { } else { Alert("删除失败,可重新操作."); } BindData(); }
protected void gvlist_RowCommand(object sender, GridViewCommandEventArgs e) { XYECOM.Business.Auditing audBLL = new Auditing(); int row = Convert.ToInt32(e.CommandArgument); Int64 id = Convert.ToInt64(this.gvlist.DataKeys[row][0].ToString()); LinkButton lb = (LinkButton)this.gvlist.Rows[row].Cells[7].Controls[0]; LinkButton LB = (LinkButton)this.gvlist.Rows[row].Cells[6].Controls[0]; XYECOM.Business.News ne = new XYECOM.Business.News(); if (e.CommandName == "ChangeAuditing") { if (lb.Text == "通过审核") { audBLL.UpdatesAuditing(id, "n_news", XYECOM.Model.AuditingState.NoPass); } else if (lb.Text == "未通过审核") { audBLL.UpdatesAuditing(id, "n_news", XYECOM.Model.AuditingState.Passed); } } if (e.CommandName == "ChangeCommand") { if (LB.Text == "推荐") { ne.UpdateForCommand(id, false); } else if (LB.Text == "不推荐") { ne.UpdateForCommand(id, true); } } BindData(); }
protected void btnMove_Click(object sender, EventArgs e) { String num = ""; String content = "NT_ID='" + XYECOM.Core.Utils.AppendComma(this.typeId.Value) + "'"; XYECOM.Business.News news = new XYECOM.Business.News(); foreach (GridViewRow GR in this.gvlist.Rows) { if (((CheckBox)(GR.FindControl("chkExport"))).Checked == true) { num += "," + gvlist.DataKeys[GR.DataItemIndex].Value.ToString(); } } if (num.IndexOf(',') == 0) { num = num.Substring(1); String strwhere = "where NS_ID in (" + num + ")"; news.MoveNews(strwhere, content); BindData(); } }
protected void btnIsPass_Click(object sender, EventArgs e) { XYECOM.Business.News ne = new XYECOM.Business.News(); long infoId = 0; foreach (GridViewRow GR in this.gvlist.Rows) { if (((HtmlInputCheckBox)(GR.FindControl("chkExport"))).Checked == true) { infoId = XYECOM.Core.MyConvert.GetInt64(gvlist.DataKeys[GR.DataItemIndex].Value.ToString()); if (infoId <= 0) continue; ne.UpdateForCommand(infoId, true); } } BindData(); }