/// <summary> /// Dels the HTML. /// </summary> /// <param name="Model">The model.</param> /// <returns></returns> public void DelHtml(int id) { try { ROYcms.Sys.BLL.ROYcms_news BLL = new ROYcms.Sys.BLL.ROYcms_news(); ROYcms.Sys.BLL.ROYcms_class ClassBLL = new ROYcms.Sys.BLL.ROYcms_class(); ROYcms.Sys.Model.ROYcms_class Model = ClassBLL.GetModel(ClassBLL.GetClassId(Convert.ToInt32(BLL.GetClassName(id)))); ROYcms.Sys.Model.ROYcms_news NewModel = BLL.GetModel(id); string Path = null; Model.FilePath = Model.FilePath.Replace("{cmspath}", "~"); Path = (Model.ShowRules.Contains("~/") ? Model.ShowRules : (Model.FilePath + Model.ShowRules)); //文件生成地址 Path = Path.Replace("{yyyy}", Convert.ToDateTime(NewModel.time).ToString("yyyy")); Path = Path.Replace("{MM}", Convert.ToDateTime(NewModel.time).ToString("MM")); Path = Path.Replace("{dd}", Convert.ToDateTime(NewModel.time).ToString("dd")); Path = Path.Replace("{id}", id.ToString()); using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")))) { // File.Delete(HttpContext.Current.Server.MapPath(Path)); sw.WriteLine("文件已经删除!<a href='/inde.aspx'>到首页</a>"); sw.Flush(); } } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } }
/// <summary> /// 输出 /// </summary> /// <param name="output">The output.</param> protected override void Render(HtmlTextWriter output) { ROYcms.Sys.Model.ROYcms_news ROYcms_news_Model = new ROYcms.Sys.Model.ROYcms_news(); string Url = null; if (this.Pattern == "u") { ROYcms_news_Model = u_id(Convert.ToInt32(this.Rid), this.Class); } else if (this.Pattern == "d") { ROYcms_news_Model = d_id(Convert.ToInt32(this.Rid), this.Class); } if (ROYcms_news_Model != null) { Url = "<a href='show_" + ROYcms_news_Model.bh.ToString() + ".html' >" + ROYcms_news_Model.title.ToString() + "</a>"; } else { Url = "<!--无数据!-->"; } try { output.Write(Url); } catch { output.Write("<!--输出错误!-->"); } }
/// <summary> /// Shows the info.绑定数据显示到表单 /// </summary> /// <param name="bh">The bh.</param> private void ShowInfo(int bh) { ROYcms.Sys.Bll.ROYcms_news bll = new ROYcms.Sys.Bll.ROYcms_news(); ROYcms.Sys.Model.ROYcms_news model = bll.GetModel(bh); this.Date = model.time; this.txtpic.Text = model.pic; this.txttitle.Text = model.title; this.DdlMenu.SelectedValue = model.classname.ToString(); this.keyword.Text = model.keyword;//默认值 this.txtzhaiyao.Text = model.zhaiyao; FCKeditor1.Value = model.contents; this.txtinfor.Text = model.infor; this.jumpurl.Text = model.jumpurl; this.txtauthor.Text = model.author; this.txturl.Text = model.url; this.txttag.Text = model.tag; this.txthits.Text = model.hits.ToString(); this.txtdig.Text = model.dig.ToString(); this.orders.Value = model.orders.ToString(); if (model.jumpurl != "") { this.jumpurl_on_of.Checked = true; } if (model.ding == 0) { this.ding.Checked = true; } if (model.tuijian == 0) { this.tuijian.Checked = true; } if (model.switchs == 0) { this.switchs.Checked = true; } //绑定页面视图参数 this.GUID = model.GUID; this.ClassKind = Convert.ToInt32(model.type); // this.Class = model.classname.ToString(); }
/// <summary> /// 添加信息方法 Adds the specified i. /// </summary> /// <param name="i">The i.</param> int add(int i) { string pic = ROYcms.Common.input.Htmls(this.txtpic.Text); string title = ROYcms.Common.input.Htmls(this.txttitle.Text); if (this.styles.Value != "") { title = "[size=" + this.styles.Value + "]" + title + "[/size]"; } if (this.colors.Value != "") { title = "[color=" + this.colors.Value + "]" + title + "[/color]"; } string keyword = ROYcms.Common.input.Htmls(this.keyword.Text);//默认值 string zhaiyao = ROYcms.Common.input.Htmls(this.txtzhaiyao.Text); int classname = int.Parse(this.Class[i]); string contents = FCKeditor1.Value; string infor = ROYcms.Common.input.Htmls(this.txtinfor.Text); string author = ROYcms.Common.input.Htmls(this.txtauthor.Text.Trim()); string url = ROYcms.Common.input.Htmls(this.txturl.Text); string tag = ROYcms.Common.input.Htmls(this.txttag.Text); int hits = int.Parse(this.txthits.Text.Trim()); int dig = int.Parse(this.txtdig.Text.Trim()); string jumpurl = ""; if (this.jumpurl_on_of.Checked) { jumpurl = ROYcms.Common.input.Htmls(this.jumpurl.Text.Trim()); } int orders = 0; if (this.orders.Value != "") { orders = int.Parse(this.orders.Value); } int ding = 1; if (this.ding.Checked) { ding = 0; } int tuijian = 1; if (this.tuijian.Checked) { tuijian = 0; } int switchs = 1; if (this.switchs.Checked) { switchs = 0; } ROYcms.Sys.Model.ROYcms_news model = new ROYcms.Sys.Model.ROYcms_news(); model.pic = pic; model.title = title; if (keyword == "") { keyword = title; } else { model.keyword = keyword; } if (zhaiyao == "") { zhaiyao = title; } else { model.zhaiyao = zhaiyao; } model.classname = classname; model.contents = contents; model.infor = infor; model.jumpurl = jumpurl; model.author = author; model.url = url; model.tag = tag; model.orders = orders; model.ding = ding; model.tuijian = tuijian; model.dig = dig; model.hits = hits; model.switchs = switchs; model.link = ""; model.type = this.ClassKind.ToString(); model.GUID = this.GUID; ROYcms.Sys.Bll.ROYcms_news bll = new ROYcms.Sys.Bll.ROYcms_news(); if (tag != "") { AddTag(tag); } int ID = bll.Add(model); if (ID != 1) { Add_New_User(ID); ShearFile(); NewXml(ID); NewHtml(ID, classname); } return(ID); }
/// <summary> /// 编辑信息方法 Edits this instance. /// </summary> protected void edit() { int bh = Convert.ToInt32(this.bh); string pic = this.txtpic.Text; string title = this.txttitle.Text; if (this.styles.Value != "") { title = "[size=" + this.styles.Value + "]" + title + "[/size]"; } if (this.colors.Value != "") { title = "[color=" + this.colors.Value + "]" + title + "[/color]"; } string keyword = this.keyword.Text;//默认值 string zhaiyao = this.txtzhaiyao.Text; // int classname =Convert.ToInt32(this.Class);////////////////////////////////////////// int classname = int.Parse(this.DdlMenu.SelectedValue); string contents = FCKeditor1.Value; string infor = this.txtinfor.Text; string author = this.txtauthor.Text.Trim(); string url = this.txturl.Text; string tag = this.txttag.Text; int hits = int.Parse(this.txthits.Text.Trim()); int dig = int.Parse(this.txtdig.Text.Trim()); int orders = 0; string jumpurl = ""; if (this.jumpurl_on_of.Checked) { jumpurl = this.jumpurl.Text.Trim(); } if (this.orders.Value != "") { orders = int.Parse(this.orders.Value); } int ding = 1; if (this.ding.Checked) { ding = 0; } int tuijian = 1; if (this.tuijian.Checked) { tuijian = 0; } int switchs = 1; if (this.switchs.Checked) { switchs = 0; } ROYcms.Sys.Model.ROYcms_news model = new ROYcms.Sys.Model.ROYcms_news(); model.bh = bh; model.pic = pic; model.title = title; if (keyword == "") { keyword = title; } else { model.keyword = keyword; } if (zhaiyao == "") { zhaiyao = title; } else { model.zhaiyao = zhaiyao; } model.classname = classname; model.contents = contents; model.infor = infor; model.jumpurl = jumpurl; model.author = author; model.url = url; model.tag = tag; model.orders = orders; model.ding = ding; model.tuijian = tuijian; model.dig = dig; model.hits = hits; model.switchs = switchs; model.link = ""; if (this.Date != null) { model.time = this.Date; } else { model.time = DateTime.Now; } model.type = this.ClassKind.ToString(); model.GUID = this.GUID; ShearFile(); //删除临时附件信息 NewXml(bh); //生成XML if (Request["Z_url_clk"] == "0") { Add_New_Url(Convert.ToInt32(this.bh), Request["Z_url"]); //修改路径 } ROYcms.Sys.Bll.ROYcms_news bll = new ROYcms.Sys.Bll.ROYcms_news(); bll.Update(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_news GetModel(int bh) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + PubConstant.date_prefix + "news "); strSql.Append(" where bh=@bh "); SqlParameter[] parameters = { new SqlParameter("@bh", SqlDbType.Int, 4) }; parameters[0].Value = bh; ROYcms.Sys.Model.ROYcms_news model = new ROYcms.Sys.Model.ROYcms_news(); DataSet ds = ROYcms.DB.DbHelpers.GetDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["bh"].ToString() != "") { model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString()); } model.pic = ds.Tables[0].Rows[0]["pic"].ToString(); model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.keyword = ds.Tables[0].Rows[0]["keyword"].ToString(); model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString(); if (ds.Tables[0].Rows[0]["classname"].ToString() != "") { model.classname = int.Parse(ds.Tables[0].Rows[0]["classname"].ToString()); } model.contents = ds.Tables[0].Rows[0]["contents"].ToString(); model.jumpurl = ds.Tables[0].Rows[0]["jumpurl"].ToString(); model.infor = ds.Tables[0].Rows[0]["infor"].ToString(); model.author = ds.Tables[0].Rows[0]["author"].ToString(); model.url = ds.Tables[0].Rows[0]["url"].ToString(); if (ds.Tables[0].Rows[0]["ding"].ToString() != "") { model.ding = int.Parse(ds.Tables[0].Rows[0]["ding"].ToString()); } if (ds.Tables[0].Rows[0]["dig"].ToString() != "") { model.dig = int.Parse(ds.Tables[0].Rows[0]["dig"].ToString()); } model.tag = ds.Tables[0].Rows[0]["tag"].ToString(); if (ds.Tables[0].Rows[0]["hits"].ToString() != "") { model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString()); } if (ds.Tables[0].Rows[0]["time"].ToString() != "") { model.time = DateTime.Parse(ds.Tables[0].Rows[0]["time"].ToString()); } if (ds.Tables[0].Rows[0]["orders"].ToString() != "") { model.orders = int.Parse(ds.Tables[0].Rows[0]["orders"].ToString()); } if (ds.Tables[0].Rows[0]["tuijian"].ToString() != "") { model.tuijian = int.Parse(ds.Tables[0].Rows[0]["tuijian"].ToString()); } if (ds.Tables[0].Rows[0]["switchs"].ToString() != "") { model.switchs = int.Parse(ds.Tables[0].Rows[0]["switchs"].ToString()); } if (ds.Tables[0].Rows[0]["link"].ToString() != "") { model.link = ds.Tables[0].Rows[0]["link"].ToString(); } if (ds.Tables[0].Rows[0]["type"].ToString() != "") { model.type = ds.Tables[0].Rows[0]["type"].ToString(); } if (ds.Tables[0].Rows[0]["GUID"].ToString() != "") { model.GUID = ds.Tables[0].Rows[0]["GUID"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public int Update(ROYcms.Sys.Model.ROYcms_news model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + PubConstant.date_prefix + "news set "); strSql.Append("pic=@pic,"); strSql.Append("title=@title,"); strSql.Append("keyword=@keyword,"); strSql.Append("zhaiyao=@zhaiyao,"); strSql.Append("classname=@classname,"); strSql.Append("contents=@contents,"); strSql.Append("jumpurl=@jumpurl,"); strSql.Append("infor=@infor,"); strSql.Append("author=@author,"); strSql.Append("url=@url,"); strSql.Append("ding=@ding,"); strSql.Append("dig=@dig,"); strSql.Append("tag=@tag,"); strSql.Append("hits=@hits,"); strSql.Append("time=@time,"); strSql.Append("orders=@orders,"); strSql.Append("tuijian=@tuijian,"); strSql.Append("switchs=@switchs,"); strSql.Append("link=@link,"); strSql.Append("type=@type,"); strSql.Append("GUID=@GUID"); strSql.Append(" where bh=@bh "); SqlParameter[] parameters = { new SqlParameter("@bh", SqlDbType.Int, 4), new SqlParameter("@pic", SqlDbType.VarChar, 500), new SqlParameter("@title", SqlDbType.VarChar, 100), new SqlParameter("@keyword", SqlDbType.VarChar, 100), new SqlParameter("@zhaiyao", SqlDbType.VarChar, 1000), new SqlParameter("@classname", SqlDbType.Int, 4), new SqlParameter("@contents", SqlDbType.Text), new SqlParameter("@jumpurl", SqlDbType.VarChar, 100), new SqlParameter("@infor", SqlDbType.VarChar, 50), new SqlParameter("@author", SqlDbType.VarChar, 50), new SqlParameter("@url", SqlDbType.VarChar, 100), new SqlParameter("@ding", SqlDbType.Int, 4), new SqlParameter("@dig", SqlDbType.Int, 4), new SqlParameter("@tag", SqlDbType.VarChar, 100), new SqlParameter("@hits", SqlDbType.Int, 4), new SqlParameter("@time", SqlDbType.DateTime), new SqlParameter("@orders", SqlDbType.Int, 4), new SqlParameter("@tuijian", SqlDbType.Int, 4), new SqlParameter("@switchs", SqlDbType.Int, 4), new SqlParameter("@link", SqlDbType.VarChar, 50), new SqlParameter("@type", SqlDbType.VarChar, 50), new SqlParameter("@GUID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.bh; parameters[1].Value = model.pic; parameters[2].Value = model.title; parameters[3].Value = model.keyword; parameters[4].Value = model.zhaiyao; parameters[5].Value = model.classname; parameters[6].Value = model.contents; parameters[7].Value = model.jumpurl; parameters[8].Value = model.infor; parameters[9].Value = model.author; parameters[10].Value = model.url; parameters[11].Value = model.ding; parameters[12].Value = model.dig; parameters[13].Value = model.tag; parameters[14].Value = model.hits; parameters[15].Value = model.time; parameters[16].Value = model.orders; parameters[17].Value = model.tuijian; parameters[18].Value = model.switchs; parameters[19].Value = model.link; parameters[20].Value = model.type; parameters[21].Value = model.GUID; return(ROYcms.DB.DbHelpers.NonQuery(strSql.ToString(), parameters)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public int Add(ROYcms.Sys.Model.ROYcms_news model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + PubConstant.date_prefix + "news("); strSql.Append("pic,title,keyword,zhaiyao,classname,contents,jumpurl,infor,author,url,ding,dig,tag,hits,orders,tuijian,switchs,link,type,GUID)"); strSql.Append(" values ("); strSql.Append("@pic,@title,@keyword,@zhaiyao,@classname,@contents,@jumpurl,@infor,@author,@url,@ding,@dig,@tag,@hits,@orders,@tuijian,@switchs,@link,@type,@GUID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@pic", SqlDbType.VarChar, 500), new SqlParameter("@title", SqlDbType.VarChar, 100), new SqlParameter("@keyword", SqlDbType.VarChar, 100), new SqlParameter("@zhaiyao", SqlDbType.VarChar, 1000), new SqlParameter("@classname", SqlDbType.Int, 4), new SqlParameter("@contents", SqlDbType.Text), new SqlParameter("@jumpurl", SqlDbType.VarChar, 100), new SqlParameter("@infor", SqlDbType.VarChar, 50), new SqlParameter("@author", SqlDbType.VarChar, 50), new SqlParameter("@url", SqlDbType.VarChar, 100), new SqlParameter("@ding", SqlDbType.Int, 4), new SqlParameter("@dig", SqlDbType.Int, 4), new SqlParameter("@tag", SqlDbType.VarChar, 100), new SqlParameter("@hits", SqlDbType.Int, 4), new SqlParameter("@orders", SqlDbType.Int, 4), new SqlParameter("@tuijian", SqlDbType.Int, 4), new SqlParameter("@switchs", SqlDbType.Int, 4), new SqlParameter("@link", SqlDbType.VarChar, 50), new SqlParameter("@type", SqlDbType.VarChar, 50), new SqlParameter("@GUID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.pic; parameters[1].Value = model.title; parameters[2].Value = model.keyword; parameters[3].Value = model.zhaiyao; parameters[4].Value = model.classname; parameters[5].Value = model.contents; parameters[6].Value = model.jumpurl; parameters[7].Value = model.infor; parameters[8].Value = model.author; parameters[9].Value = model.url; parameters[10].Value = model.ding; parameters[11].Value = model.dig; parameters[12].Value = model.tag; parameters[13].Value = model.hits; parameters[14].Value = model.orders; parameters[15].Value = model.tuijian; parameters[16].Value = model.switchs; parameters[17].Value = model.link; parameters[18].Value = model.type; parameters[19].Value = model.GUID; object obj = ROYcms.DB.DbHelpers.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 获取一条信息 条件 Tops the news. /// </summary> /// <returns></returns> public ROYcms.Sys.Model.ROYcms_news TopNews(string where) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * "); strSql.Append(" FROM [" + PubConstant.date_prefix + "news] "); if (where.Trim() != "") { strSql.Append(" where " + where); } ROYcms.Sys.Model.ROYcms_news model = new ROYcms.Sys.Model.ROYcms_news(); DataSet ds = ROYcms.DB.DbHelpers.GetDataSet(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["bh"].ToString() != "") { model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString()); } model.pic = ds.Tables[0].Rows[0]["pic"].ToString(); model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.keyword = ds.Tables[0].Rows[0]["keyword"].ToString(); model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString(); if (ds.Tables[0].Rows[0]["classname"].ToString() != "") { model.classname = int.Parse(ds.Tables[0].Rows[0]["classname"].ToString()); } model.contents = ds.Tables[0].Rows[0]["contents"].ToString(); model.jumpurl = ds.Tables[0].Rows[0]["jumpurl"].ToString(); model.infor = ds.Tables[0].Rows[0]["infor"].ToString(); model.author = ds.Tables[0].Rows[0]["author"].ToString(); model.url = ds.Tables[0].Rows[0]["url"].ToString(); if (ds.Tables[0].Rows[0]["ding"].ToString() != "") { model.ding = int.Parse(ds.Tables[0].Rows[0]["ding"].ToString()); } if (ds.Tables[0].Rows[0]["dig"].ToString() != "") { model.dig = int.Parse(ds.Tables[0].Rows[0]["dig"].ToString()); } model.tag = ds.Tables[0].Rows[0]["tag"].ToString(); if (ds.Tables[0].Rows[0]["hits"].ToString() != "") { model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString()); } if (ds.Tables[0].Rows[0]["time"].ToString() != "") { model.time = DateTime.Parse(ds.Tables[0].Rows[0]["time"].ToString()); } if (ds.Tables[0].Rows[0]["orders"].ToString() != "") { model.orders = int.Parse(ds.Tables[0].Rows[0]["orders"].ToString()); } if (ds.Tables[0].Rows[0]["tuijian"].ToString() != "") { model.tuijian = int.Parse(ds.Tables[0].Rows[0]["tuijian"].ToString()); } if (ds.Tables[0].Rows[0]["switchs"].ToString() != "") { model.switchs = int.Parse(ds.Tables[0].Rows[0]["switchs"].ToString()); } if (ds.Tables[0].Rows[0]["link"].ToString() != "") { model.link = ds.Tables[0].Rows[0]["link"].ToString(); } if (ds.Tables[0].Rows[0]["type"].ToString() != "") { model.type = ds.Tables[0].Rows[0]["type"].ToString(); } if (ds.Tables[0].Rows[0]["GUID"].ToString() != "") { model.GUID = ds.Tables[0].Rows[0]["GUID"].ToString(); } return(model); } else { return(null); } }