using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace JumboTCMS.WebFile.PeiXue { public partial class Default : JumboTCMS.UI.AdminCenter { protected void Page_Load(object sender, EventArgs e) { } /// /// 获取栏目 /// /// 站点编号 /// 频道编号 /// public System.Data.DataTable GetClass(String SiteId,String ChannelId) { doh.Reset(); doh.SqlCmd= "SELECT [ID],[Title],[Code],[IsPaging],[PageSize],[IsOut],[SortRank],len(Code) as codelength,[ChannelId],[IsTop],[topicnum],(select title from [jcms_normal_theme] where id=[jcms_normal_class].ThemeId) as templatename,(select title from [jcms_normal_theme] where id=[jcms_normal_class].ContentTheme) as contenttempname FROM [jcms_normal_class] WHERE [ChannelId]=" + ChannelId + " and SiteId='" + SiteId + "' ORDER BY code"; // doh.SqlCmd = "select * from jcms_normal_class where ChannelId='"+ChannelId+ "'and SiteId='"+SiteId+"' order by sortid"; return doh.GetDataTable(); } /// /// 获取文章、图片信息 /// /// 列表编号 /// 是否发布 /// 是否有缩略图 /// 是否推荐 /// 是否焦点 /// 是否置顶 /// 页数 /// 分页数 /// 是否文章 /// public System.Data.DataSet GetArticle(String ClassId,String IsPass,String IsImg, String IsTop,String IsFocus, String IsHead,int page,int pagesize,bool IsArticle) { doh.Reset(); var tablename = "jcms_module_article"; if (!IsArticle) tablename = "jcms_module_photo"; var sql = "select top "+pagesize+ " *,(select title from jcms_normal_class as b where b.Id=a.ClassId) as ClassName from "+tablename+" as a where 1=1"; var sqlcount = "select count(*) from "+tablename+" where 1=1"; var sqlwhere = ""; if (!string.IsNullOrWhiteSpace(ClassId)) { sqlwhere += " and ClassId='"+ ClassId+"'"; } if (!string.IsNullOrWhiteSpace(IsPass)) { sqlwhere += " and IsPass='"+ IsPass+"'"; } if (!string.IsNullOrWhiteSpace(IsImg)) { sqlwhere += " and IsImg='"+ IsImg+"'"; } if (!string.IsNullOrWhiteSpace(IsTop)) { sqlwhere += " and IsTop='"+ IsTop+"'"; } if (!string.IsNullOrWhiteSpace(IsFocus)) { sqlwhere += " and IsFocus='"+ IsFocus+"'"; } if (!string.IsNullOrWhiteSpace(IsHead)) { sqlwhere += " and IsHead='" + IsHead + "'"; } var sql2 = " and Id not in( select top "+(page-1)*pagesize+ " Id from "+ tablename + " where 1=1 "+sqlwhere + " order by AddTime desc) order by AddTime desc;"; doh.SqlCmd = sql+sqlwhere+sql2+ sqlcount + sqlwhere; return doh.GetDataSet(); } /// /// 根据编号获取文章信息 /// /// /// public System.Data.DataTable GetArticle(string Id) { doh.Reset(); doh.SqlCmd = "select * from jcms_module_article where id='"+ Id + "'"; return doh.GetDataTable(); } /// /// 更新浏览次数 /// /// public void UpdateViewNum(string Id) { doh.Reset(); doh.SqlCmd = " update jcms_module_article set ViewNum=ViewNum+1 where Id='"+Id+"'"; doh.ExecuteSqlNonQuery(); } public System.Data.DataTable GetCountByClassId(string ClassId) { doh.Reset(); doh.SqlCmd = "select count(*) from jcms_module_article where ClassId='"+ClassId+"' and IsPass=1"; return doh.GetDataTable(); } /// /// 获取文章评论 /// /// /// public System.Data.DataTable GetReview(string Id) { doh.Reset(); doh.SqlCmd = "select * from jcms_normal_review where ContentId='"+Id+ "' and Ispass='1' order by AddDate desc"; return doh.GetDataTable(); } /// /// 获取文章评论数量 /// /// /// public int GetReviewCount(string Id) { doh.Reset(); doh.SqlCmd = "select count(*) as count from jcms_normal_review where ContentId='" + Id + "' and Ispass='1'"; var dt= doh.GetDataTable(); if (dt.Rows.Count > 0) { return int.Parse(dt.Rows[0][0].ToString()); } else { return 0; } } } }