partial void Deletenormal_class(normal_class instance);
 partial void Insertnormal_class(normal_class instance);
 partial void Updatenormal_class(normal_class instance);
		private void detach_normal_class(normal_class entity)
		{
			this.SendPropertyChanging();
			entity.normal_channel = null;
		}
        private void getClassSinglePageListBody(normal_class _class, ref System.Collections.ArrayList ContentList, int _pagecount, int _page)
        {
            string whereStr = string.Empty;
            string _pagestr = ContentList[0].ToString();
            whereStr = " [ClassId] in (SELECT ID FROM [normal_class] WHERE [IsOut]=0 and id=" + _class.Id + ")";
            whereStr += " AND [IsPass]=1 AND [ChannelId]=" + _class.ChannelId;
            int _pagesize = (_class.PageSize < 1) ? 5 : _class.PageSize;

            System.Collections.ArrayList TagArray = WeiXin.Core.Strings.GetHtmls(_pagestr, "{$zuxia:class(", "{$/zuxia:class}", false, false);
            if (TagArray.Count > 0)//标签存在
            {
                string LoopBody = string.Empty;
                string TempStr = string.Empty;
                string FiledsStr = string.Empty;
                int StartTag, EndTag;
                StartTag = TagArray[0].ToString().IndexOf(")}", 0);
                FiledsStr = TagArray[0].ToString().Substring(0, StartTag).ToLower();
                if (!("," + FiledsStr + ",").Contains(",adddate,")) FiledsStr += ",adddate";
                EndTag = TagArray[0].ToString().Length;
                LoopBody = "{$zuxia:class(" + TagArray[0].ToString() + "{$/zuxia:class}";
                TempStr = TagArray[0].ToString().Substring(StartTag + 2, EndTag - StartTag - 2).Replace("<#foreach content>", "<#foreach collection=\"${contents}\" var=\"field\" index=\"i\">");//需要循环的部分
                ContentList.Add(LoopBody);

                if (_pagecount > 0)
                {
                    if (_page == 0)
                    {
                        for (int i = 1; i < _pagecount + 1; i++)
                        {
                            NameValueCollection orders = new NameValueCollection();
                            orders.Add("AddDate", "desc");
                            orders.Add("Id", "desc");
                            string wStr = WeiXin.Core.SqlHelp.GetMultiOrderPagerSQL("Id,ChannelId,ClassId,[IsPass],[FirstPage]," + FiledsStr,
                                "module_" + _class.normal_channel.Type,
                                _pagesize,
                                i,
                                orders,
                                whereStr);
                            DataSet dtContent = ArticleBll.GetArticleBySql2(wStr);
                            ContentList.Add(operateContentTag(_class.normal_channel.Type, dtContent, TempStr));
                            dtContent.Clear();
                            dtContent.Dispose();
                        }
                    }
                    else
                    {
                        _page = _page == 0 ? 1 : _page;
                        NameValueCollection orders = new NameValueCollection();
                        orders.Add("AddDate", "desc");
                        orders.Add("Id", "desc");
                        string wStr = WeiXin.Core.SqlHelp.GetMultiOrderPagerSQL("Id,ChannelId,ClassId,[IsPass],[FirstPage]," + FiledsStr,
                              "module_" + _class.normal_channel.Type,
                            _pagesize,
                            _page,
                            orders,
                            whereStr);
                        DataSet dtContent = ArticleBll.GetArticleBySql2(wStr);
                        ContentList.Add(operateContentTag(_class.normal_channel.Type, dtContent, TempStr));
                        dtContent.Clear();
                        dtContent.Dispose();
                    }
                }
                else
                    ContentList.Add("  ");
            }
        }
        private System.Collections.ArrayList getClassSinglePage(normal_class _class, int _pagecount, int _page, int eid)
        {
            string pId = string.Empty;
            string _pagestr = string.Empty;

            //得到模板方案组ID/模板内容

            _pagestr = GetClassListContent(eid, _class.normal_channel.Type, "class", _class.ChannelId);
            ReplacePublicTag(ref _pagestr);

            //   ReplaceChannelClassLoopTag(ref _pagestr);
            // ReplaceClassTag(ref _pagestr, _class.Id);
            //   ReplaceContentLoopTag(ref _pagestr);
            System.Collections.ArrayList ContentList = new System.Collections.ArrayList();
            ContentList.Add(_pagestr);
            getClassSinglePageListBody(_class, ref ContentList, _pagecount, _page);

            return ContentList;
        }
 /// <summary>
 /// 修改栏目
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public int UpdateClass(normal_class c)
 {
     string sql = string.Format(@"update normal_class set title='{0}',pagesize={1}, templateid={3}, contenttemp={4} where id={2}", c.Title, c.PageSize, c.Id,c.TemplateId,c.ContentTemp);
     return SqlHelper.ExecuteNonQuery(System.Data.CommandType.Text, sql);
 }
 /// <summary>
 /// 添加栏目
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public int InsertClass(normal_class c)
 {
     db.normal_class.InsertOnSubmit(c);
     db.SubmitChanges();
     return c.Id;
 }